-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sandro
committed
Apr 14, 2019
1 parent
70885fd
commit 002fff3
Showing
11 changed files
with
615 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
# VGAX Library for Arduino UNO | ||
# VGAX Library for Arduino UNO and MEGA | ||
|
||
COPYRIGHT (C) 2014 Sandro Maffiodo | ||
[[email protected]](mailto:[email protected]) | ||
[http://www.assezeta.com/sandromaffiodo](http://www.assezeta.com/sandromaffiodo) | ||
[http://www.sandromaffiodo.com](http://www.sandromaffiodo.com) | ||
|
||
 | ||
|
||
YouTube videos: | ||
|
||
[<img width='30%' src='https://i.ytimg.com/vi/PfN_sQffLkg/mqdefault.jpg'/>](https://youtu.be/PfN_sQffLkg) | ||
[<img width='30%' src='https://i.ytimg.com/vi/Yvdf-pfneA4/mqdefault.jpg'/>](https://youtu.be/Yvdf-pfneA4) | ||
[<img width='30%' src='https://i.ytimg.com/vi/W9ebehFDDRA/mqdefault.jpg'/>](https://youtu.be/W9ebehFDDRA) | ||
[<img width='20%' src='https://i.ytimg.com/vi/PfN_sQffLkg/mqdefault.jpg'/>](https://youtu.be/PfN_sQffLkg) | ||
[<img width='20%' src='https://i.ytimg.com/vi/Yvdf-pfneA4/mqdefault.jpg'/>](https://youtu.be/Yvdf-pfneA4) | ||
[<img width='20%' src='https://i.ytimg.com/vi/W9ebehFDDRA/mqdefault.jpg'/>](https://youtu.be/W9ebehFDDRA) | ||
[<img width='20%' src='https://i.ytimg.com/vi/Qs3uyhzUcfA/mqdefault.jpg'/>](https://youtu.be/Qs3uyhzUcfA) | ||
|
||
Some photos: | ||
|
||
[<img width='20%' src='docs/screenshot1.jpg'/>](docs/screenshot1.jpg) | ||
[<img width='20%' src='docs/screenshot5.jpg'/>](docs/screenshot5.jpg) | ||
[<img width='20%' src='docs/screenshot2.jpg'/>](docs/screenshot2.jpg) | ||
[<img width='20%' src='docs/screenshot6.jpg'/>](docs/screenshot6.jpg) | ||
|
||
## What is VGAX? | ||
|
||
This is a VGA library for Arduino UNO. | ||
This is a VGA library for Arduino UNO and Arduino MEGA. | ||
To use this library you need only 4 resistors and one DSUB15 connector. | ||
This library require an ATMega328 MCU (or higher) MCU. Does not work with ATTINY family or ATMega168. | ||
|
||
|
@@ -33,13 +35,21 @@ Thanks to Roberto Melzi [RobCai](https://www.youtube.com/channel/UCgQK0QAMUV5L4O | |
|
||
## Video | ||
|
||
The library implement a 120x60px framebuffer where each pixel is stored as 2 bits (4 colors). | ||
The framebuffer is stored inside SRAM and require 1800 bytes. Your programs cannot use more than 200 bytes so be carefull! If you want, you can use another Arduino UNO to drive the one that use VGAX library. | ||
The library implement a 120x60px framebuffer where each pixel is stored as 2 bits (4 colors). On Arduino MEGA resolution can be increased to 120x240px. | ||
The framebuffer is stored inside SRAM and require at least 1800 bytes. This mean that on ATMega328 your programs cannot use more than 200 bytes so be carefull! If you want, you can use another Arduino UNO to drive the one that use VGAX library. On ATMega2560 you have more SRAM but if you expand the framebuffer to 120x240px free SRAM will be 800 bytes. | ||
|
||
VGAX framebuffer use 2bit for each pixel. Inside each byte are stored 4 pixels, packed in this order: leftmost pixel is in the highest 2bits, rightmost pixel is on the lowest 2bits: | ||
|
||
 | ||
|
||
On Arduino MEGA (ATMega2560) framebuffer can be extended to 120x90px with squared pixels or 120x240px with rectangular pixels. You can enable these alternatives resolutions by uncommenting these constants on VGAX.h header: | ||
|
||
//uncomment ATMEGA2560_HIGHRES to use 120x90px squared pixels | ||
//#define ATMEGA2560_HIGHRES | ||
|
||
//uncomment ATMEGA2560_HIGHRES to use 120x240px rectangular pixels | ||
//#define ATMEGA2560_MAXRES | ||
|
||
## Audio | ||
|
||
This library implement an async tone (audio) generation too! The audio signal is | ||
|
@@ -58,11 +68,12 @@ You need: | |
Then connect them like the following schema. | ||
*NOTE: The DSUB15 connector is shown from rear view* | ||
|
||
 | ||
 | ||
 | ||
|
||
### 4 Colors | ||
The 4 colors generated from the library are not predefined. | ||
You can connect the PIN6 and PIN7 with two of the VGA DSUB15 RGB pins, selecting the color combination that you prefer. | ||
On Arduino UNO you can connect the pin 6 and pin 7 with two of the VGA DSUB15 RGB pins, selecting the color combination that you prefer. | ||
|
||
These are some of the possible combinations, done without additional components: | ||
|
||
|
@@ -78,6 +89,7 @@ These are some of the possible combinations, done without additional components: | |
|
||
 | ||
|
||
Pin 6 and pin 7 on Arduino MEGA must be changed to pin 30 and pin 31 but the same logic of choosing colors can be applyed on MEGA. | ||
|
||
## PIN and PORT | ||
|
||
|
@@ -87,6 +99,8 @@ PORTD pins**. | |
The vertical synchronization signal is generated on pin 9. Gammon's version use | ||
the pin 10 but i prefer to keep pins 10 11 12 13 free for common SPI usage. | ||
|
||
On Arduino MEGA PORTD is substituted to PORTA, vertical sync is pin 11 and horizontal pin is 9. | ||
|
||
## Interrupt | ||
|
||
VGAX library generate the video signal using only interrupts, so, inside main() function, you can do anything you want. Your code will be interrupted when VGA signal needs to be generated. | ||
|
@@ -97,11 +111,11 @@ VGAX library generate the video signal using only interrupts, so, inside main() | |
|
||
## Timers | ||
|
||
This library uses **all the 3 timers** of ATMega328 MCU. | ||
This library uses **all the 3 timers** of ATMega328 MCU. On ATMega2560 there are more unused timers. | ||
|
||
*TIMER1* and *TIMER2* are configured to generate HSYNC and VSYNC pulses. | ||
The setup code for these two timers has been [created by Nick Gammon](http://www.gammon.com.au/forum/?id=11608). | ||
I have only made some modifications to use pin 9 instead of pin 10. | ||
I have only made some modifications to use pin 9 instead of pin 10. On ATMega2560 HSYNC and VSYNC are different. | ||
|
||
*TIMER0* is used to fix the interrupt jitter. I have modified an assembler trick | ||
originally writen by [Charles CNLOHR](https://github.com/cnlohr/avrcraft/tree/master/terminal). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/* | ||
VGAX Library for Arduino UNO (ATMega328 MCU) | ||
VGAX Library for Arduino UNO (ATMega328) and Arduino MEGA (ATMega2560) | ||
Source code url: https://github.com/smaffer/vgax | ||
120x60px VGA framebuffer with 4 colors | ||
COPYRIGHT (C) 2014 Sandro Maffiodo | ||
[email protected] | ||
http://www.assezeta.com/sandromaffiodo | ||
http://www.sandromaffiodo.com | ||
based on the "VGA color video generation" by Nick Gammon: | ||
http://www.gammon.com.au/forum/?id=11608. | ||
|
@@ -28,7 +28,19 @@ HERE you can find some inline documentation about the VGAX library class | |
#endif | ||
#include <avr/pgmspace.h> | ||
|
||
#define VGAX_HEIGHT 60 //number of lines | ||
//uncomment ATMEGA2560_HIGHRES to use 120x90px squared pixels | ||
//#define ATMEGA2560_HIGHRES | ||
|
||
//uncomment ATMEGA2560_HIGHRES to use 120x240px rectangular pixels | ||
#define ATMEGA2560_MAXRES | ||
|
||
#if defined(ATMEGA2560_MAXRES) | ||
#define VGAX_HEIGHT 240 //number of lines | ||
#elif defined(ATMEGA2560_HIGHRES) | ||
#define VGAX_HEIGHT 80 //number of lines | ||
#else | ||
#define VGAX_HEIGHT 60 //number of lines | ||
#endif | ||
#define VGAX_BWIDTH 30 //number of bytes in a row | ||
#define VGAX_WIDTH (VGAX_BWIDTH*4) //number of pixels in a row | ||
#define VGAX_BSIZE (VGAX_BWIDTH*VGAX_HEIGHT) //size of framebuffer in bytes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ Utils for VGAX Library | |
COPYRIGHT (C) 2014 Sandro Maffiodo | ||
[email protected] | ||
http://www.assezeta.com/sandromaffiodo | ||
http://www.sandromaffiodo.com | ||
Some of these methods are from TVOut library created by Myles Metzer (thank you!) | ||
https://code.google.com/p/arduino-tvout/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.