First Commit

Uploading Current Source
This commit is contained in:
Damian Peckett 2015-04-08 17:12:07 +10:00
parent f380964ea3
commit 0b4deef806
10 changed files with 3977 additions and 1 deletions

View File

@ -1,2 +1,31 @@
# arduino-vga
Generating VGA video with an Arduino Uno / Atmega16u2 Microcontroller
Generating VGA video with an Arduino Uno / Atmega16u2 Microcontroller.
**To Connect (atmega16u2):**
Connect all grounds on the VGA connector together.
Connect VGA ground to the Arduino Gnd.
Place a 120ohm resistor from the MOSI2 pin (Pin 4 on ICSP) to PB7 (Pin 4 on JP2)
*Optional Protection* Place a 1N4148 diode from PB7 (anode) to Gnd (cathode).
Connect the VGA red, blue and green inputs together and connect to PB7.
Connect VGA vsync to PB5 (Pin 3 on JP2).
Connect VGA hsync to PB4 (Pin 1 on JP2).
**To Assemble:**
avr-as -mmcu=atmega16u2 -o ghettovga.o ghettovga.s
avr-ld -m avr35 -o ghettovga.bin ghettovga.o
avr-objcopy -j .text -j .data -O ihex ghettovga.bin vghettovga.hex
**To Upload:**
Temporarily short pins 5 and 6 on the atmega16u2 ICSP header.
dfu-programmer atmega16u2 erase
dfu-programmer atmega16u2 flash "./ghettovga.hex"
dfu-programmer atmega16u2 reset
**To Restore Arduino Bootloader**
Temporarily short pins 5 and 6 on the atmega16u2 ICSP header.
Retrieve the appropriate usb-serial hex from:
https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbserial
Use dfu-programmer to flash hex to atmega16u2
Font glyphs copyright (c) 1981 Michael C. Koss http://mckoss.com/jscript/tinyalice.htm

5
apple/assemble.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
avr-as -mmcu=atmega16u2 -o vga.o sync.s
avr-ld -m avr35 -o vga.bin vga.o
avr-objcopy -j .text -j .data -O ihex vga.bin vga.hex

5
apple/dfu-upload.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
dfu-programmer atmega16u2 erase
dfu-programmer atmega16u2 flash "./vga.hex"
dfu-programmer atmega16u2 reset

2319
apple/sync.s Normal file

File diff suppressed because it is too large Load Diff

4
ascii/README Normal file
View File

@ -0,0 +1,4 @@
README
This is a very old branch of the apple code that was used to generate ascii based characters.
Needs a very serious clean up.

5
ascii/assemble.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
avr-as -mmcu=atmega16u2 -o vga.o ghettovga.s
avr-ld -m avr35 -o vga.bin vga.o
avr-objcopy -j .text -j .data -O ihex vga.bin vga.hex

5
ascii/dfu-upload.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
dfu-programmer atmega16u2 erase
dfu-programmer atmega16u2 flash "./vga.hex"
dfu-programmer atmega16u2 reset

1070
ascii/ghettovga.s Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
/*
* GhettoVGA Interface Library Example
*/
// Only supports upper case characters, ASCII 0x20 - 0x40
void writeCharacter(unsigned char row, unsigned char col, unsigned char val) {
unsigned char buf[4] = {0x8D, 0, 0, 0};
buf[1] = col;
buf[2] = row;
buf[3] = val-0x20;
Serial.write(buf, 4);
}
void writeString(unsigned char row, unsigned char col, const char *str) {
const char *ptr;
for(ptr = str; *ptr; ptr++, col++) writeCharacter(row, col, *ptr);
}
unsigned char readCharacter(unsigned char row, unsigned char col) {
unsigned char buf[4] = {0x8A, 0, 0, 0};
buf[1] = col;
buf[2] = row;
Serial.write(buf, 4);
return Serial.read() + 0x20;
}
void clearRow(unsigned char row) {
for(int col = 0; col < 32; ++col) writeCharacter(row, col, ' ');
}
void clearScreen() {
unsigned char buf[4] = {0x8C, 0, 0, 0};
Serial.write(buf, 4);
}
void setup() {
Serial.begin(115200);
}
void loop() {
writeString(0, 0, "HELLO WORLD!");
delay(1000);
clearScreen();
delay(1000);
}

489
fontgen/fontgen.c Normal file
View File

@ -0,0 +1,489 @@
// Generate Encoded Font Glyph Table
// Apple II Character Set.
#include <stdio.h>
#include <stdlib.h>
unsigned char glyphs[64][5][3] = {
// '@'
{{0,1,0},
{1,0,1},
{1,1,1},
{1,0,0},
{0,1,1}},
// 'A'
{{0,1,0},
{1,0,1},
{1,1,1},
{1,0,1},
{1,0,1}},
// 'B'
{{1,1,0},
{1,0,1},
{1,1,0},
{1,0,1},
{1,1,0}},
// 'C'
{{0,1,0},
{1,0,1},
{1,0,0},
{1,0,1},
{0,1,0}},
// 'D'
{{1,1,0},
{1,0,1},
{1,0,1},
{1,0,1},
{1,1,0}},
// 'E'
{{1,1,1},
{1,0,0},
{1,1,0},
{1,0,0},
{1,1,1}},
// 'F'
{{1,1,1},
{1,0,0},
{1,1,0},
{1,0,0},
{1,0,0}},
// 'G'
{{0,1,1},
{1,0,0},
{1,0,1},
{1,0,1},
{0,1,0}},
// 'H'
{{1,0,1},
{1,0,1},
{1,1,1},
{1,0,1},
{1,0,1}},
// 'I'
{{1,1,1},
{0,1,0},
{0,1,0},
{0,1,0},
{1,1,1}},
// 'J'
{{1,1,1},
{0,1,0},
{0,1,0},
{0,1,0},
{1,1,0}},
// 'K'
{{1,0,1},
{1,0,1},
{1,1,0},
{1,0,1},
{1,0,1}},
// 'L'
{{1,0,0},
{1,0,0},
{1,0,0},
{1,0,0},
{1,1,1}},
// 'M'
{{1,0,1},
{1,1,1},
{1,0,1},
{1,0,1},
{1,0,1}},
// 'N'
{{1,0,1},
{1,1,1},
{1,1,1},
{1,1,1},
{1,0,1}},
// 'O'
{{0,1,0},
{1,0,1},
{1,0,1},
{1,0,1},
{0,1,0}},
// 'P'
{{1,1,0},
{1,0,1},
{1,1,0},
{1,0,0},
{1,0,0}},
// 'Q'
{{0,1,0},
{1,0,1},
{1,0,1},
{0,1,0},
{0,0,1}},
// 'R'
{{1,1,0},
{1,0,1},
{1,1,0},
{1,0,1},
{1,0,1}},
// 'S'
{{0,1,1},
{1,0,0},
{0,1,0},
{0,0,1},
{1,1,0}},
// 'T'
{{1,1,1},
{0,1,0},
{0,1,0},
{0,1,0},
{0,1,0}},
// 'U'
{{1,0,1},
{1,0,1},
{1,0,1},
{1,0,1},
{0,1,0}},
// 'V'
{{1,0,1},
{1,0,1},
{1,0,1},
{0,1,0},
{0,1,0}},
// 'W'
{{1,0,1},
{1,0,1},
{1,1,1},
{1,1,1},
{0,1,0}},
// 'X'
{{1,0,1},
{1,0,1},
{0,1,0},
{1,0,1},
{1,0,1}},
// 'Y'
{{1,0,1},
{1,0,1},
{0,1,0},
{0,1,0},
{0,1,0}},
// 'Z'
{{1,1,1},
{0,0,1},
{0,1,0},
{1,0,0},
{1,1,1}},
// '['
{{0,1,1},
{0,1,0},
{0,1,0},
{0,1,0},
{0,1,1}},
// '\'
{{1,0,0},
{1,0,0},
{0,1,0},
{0,1,0},
{0,0,1}},
// ']'
{{1,1,0},
{0,1,0},
{0,1,0},
{0,1,0},
{1,1,0}},
// '^'
{{0,1,0},
{1,0,1},
{0,0,0},
{0,0,0},
{0,0,0}},
// '_'
{{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{1,1,1}},
// ' '
{{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0}},
// '!'
{{0,1,0},
{0,1,0},
{0,1,0},
{0,0,0},
{0,1,0}},
// '"'
{{1,0,1},
{1,0,1},
{0,0,0},
{0,0,0},
{0,0,0}},
// '#'
{{1,0,1},
{1,1,1},
{1,0,1},
{1,1,1},
{1,0,1}},
// '$'
{{0,1,1},
{1,1,0},
{1,1,1},
{0,1,1},
{1,1,0}},
// '%'
{{1,0,1},
{0,0,1},
{0,1,0},
{1,0,0},
{1,0,1}},
// '&'
{{0,1,0},
{1,0,1},
{0,1,0},
{1,0,1},
{0,1,1}},
// '\''
{{0,1,0},
{0,1,0},
{0,0,0},
{0,0,0},
{0,0,0}},
// '('
{{0,0,1},
{0,1,0},
{0,1,0},
{0,1,0},
{0,0,1}},
// ')'
{{1,0,0},
{0,1,0},
{0,1,0},
{0,1,0},
{1,0,0}},
// '*'
{{0,0,0},
{1,0,1},
{0,1,0},
{1,0,1},
{0,0,0}},
// '+'
{{0,0,0},
{0,1,0},
{1,1,1},
{0,1,0},
{0,0,0}},
// ''
{{0,0,0},
{0,0,0},
{0,0,0},
{0,1,0},
{1,0,0}},
// '-'
{{0,0,0},
{0,0,0},
{1,1,1},
{0,0,0},
{0,0,0}},
// '.'
{{0,0,0},
{0,0,0},
{0,0,0},
{0,0,0},
{0,1,0}},
// '/'
{{0,0,1},
{0,0,1},
{0,1,0},
{0,1,0},
{1,0,0}},
// '0'
{{1,1,1},
{1,0,1},
{1,0,1},
{1,0,1},
{1,1,1}},
// '1'
{{0,1,0},
{1,1,0},
{0,1,0},
{0,1,0},
{1,1,1}},
// '2'
{{0,1,0},
{1,0,1},
{0,0,1},
{1,1,0},
{1,1,1}},
// '3'
{{1,1,0},
{0,0,1},
{0,1,0},
{0,0,1},
{1,1,0}},
// '4'
{{1,0,1},
{1,0,1},
{1,1,1},
{0,0,1},
{0,0,1}},
// '5'
{{1,1,1},
{1,0,0},
{1,1,1},
{0,0,1},
{1,1,0}},
// '6'
{{0,1,1},
{1,0,0},
{1,1,0},
{1,0,1},
{0,1,0}},
// '7'
{{1,1,1},
{0,0,1},
{0,1,0},
{1,0,0},
{1,0,0}},
// '8'
{{1,1,1},
{1,0,1},
{1,1,1},
{1,0,1},
{1,1,1}},
// '9'
{{0,1,0},
{1,0,1},
{0,1,1},
{0,0,1},
{1,1,0}},
// ':'
{{0,0,0},
{0,1,0},
{0,0,0},
{0,1,0},
{0,0,0}},
// ';'
{{0,0,0},
{0,1,0},
{0,0,0},
{0,1,0},
{1,0,0}},
// '<'
{{0,0,1},
{0,1,0},
{1,0,0},
{0,1,0},
{0,0,1}},
// '='
{{0,0,0},
{1,1,1},
{0,0,0},
{1,1,1},
{0,0,0}},
// '>'
{{1,0,0},
{0,1,0},
{0,0,1},
{0,1,0},
{1,0,0}},
// '?'
{{0,1,0},
{1,0,1},
{0,0,1},
{0,1,0},
{0,1,0}}
};
int main() {
int i;
unsigned char character;
printf("\nROW_GLYPH_1:\n");
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][0][0]<<3) | (glyphs[i][0][1]<<2) | (glyphs[i][0][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][0][0]<<3) | (glyphs[i][0][1]<<2) | (glyphs[i][0][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][0][0]<<3) | (glyphs[i][0][1]<<2) | (glyphs[i][0][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = ((glyphs[i][0][0]<<3) | (glyphs[i][0][1]<<2) | (glyphs[i][0][2]<<1))&0xF;
printf(".byte 0x%02x\n", character);
}
printf("\nROW_GLYPH_2:\n");
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][1][0]<<3) | (glyphs[i][1][1]<<2) | (glyphs[i][1][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][1][0]<<3) | (glyphs[i][1][1]<<2) | (glyphs[i][1][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][1][0]<<3) | (glyphs[i][1][1]<<2) | (glyphs[i][1][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = ((glyphs[i][1][0]<<3) | (glyphs[i][1][1]<<2) | (glyphs[i][1][2]<<1))&0xF;
printf(".byte 0x%02x\n", character);
}
printf("\nROW_GLYPH_3:\n");
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][2][0]<<3) | (glyphs[i][2][1]<<2) | (glyphs[i][2][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][2][0]<<3) | (glyphs[i][2][1]<<2) | (glyphs[i][2][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][2][0]<<3) | (glyphs[i][2][1]<<2) | (glyphs[i][2][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = ((glyphs[i][2][0]<<3) | (glyphs[i][2][1]<<2) | (glyphs[i][2][2]<<1))&0xF;
printf(".byte 0x%02x\n", character);
}
printf("\nROW_GLYPH_4:\n");
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][3][0]<<3) | (glyphs[i][3][1]<<2) | (glyphs[i][3][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][3][0]<<3) | (glyphs[i][3][1]<<2) | (glyphs[i][3][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][3][0]<<3) | (glyphs[i][3][1]<<2) | (glyphs[i][3][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = ((glyphs[i][3][0]<<3) | (glyphs[i][3][1]<<2) | (glyphs[i][3][2]<<1))&0xF;
printf(".byte 0x%02x\n", character);
}
printf("\nROW_GLYPH_5:\n");
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][4][0]<<3) | (glyphs[i][4][1]<<2) | (glyphs[i][4][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][4][0]<<3) | (glyphs[i][4][1]<<2) | (glyphs[i][4][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = (~((glyphs[i][4][0]<<3) | (glyphs[i][4][1]<<2) | (glyphs[i][4][2]<<1)))&0xF;
printf(".byte 0x%02x\n", character);
}
for(i = 0; i < 64; ++i) {
character = ((glyphs[i][4][0]<<3) | (glyphs[i][4][1]<<2) | (glyphs[i][4][2]<<1))&0xF;
printf(".byte 0x%02x\n", character);
}
return 0;
}