Skip to content

Instantly share code, notes, and snippets.

@jes
Created October 21, 2019 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jes/1d561d4a034c841a083ce80d4520e27f to your computer and use it in GitHub Desktop.
Save jes/1d561d4a034c841a083ce80d4520e27f to your computer and use it in GitHub Desktop.
VGA Serial output for RC2014 (19x10 character display)
// 19x10 VGA serial display
// James Stanley <james@incoherency.co.uk>
// Note that this needs a modified version of VGAX.h that only uses 1bpp instead of 2bpp else there isn't enough RAM
#include <VGAX.h>
//font generated from BITFONZI - by Sandro Maffiodo
#define FNT_NANOFONT_HEIGHT 6
#define FNT_NANOFONT_SYMBOLS_COUNT 95
//data size=570 bytes
const unsigned char fnt_nanofont_data[FNT_NANOFONT_SYMBOLS_COUNT][1+FNT_NANOFONT_HEIGHT] PROGMEM={
{ 5, 128, 128, 128, 0, 128, 0, }, //glyph '!' code=0
{ 5, 160, 160, 0, 0, 0, 0, }, //glyph '"' code=1
{ 5, 80, 248, 80, 248, 80, 0, }, //glyph '#' code=2
{ 5, 120, 160, 112, 40, 240, 0, }, //glyph '$' code=3
{ 5, 136, 16, 32, 64, 136, 0, }, //glyph '%' code=4
{ 5, 96, 144, 104, 144, 104, 0, }, //glyph '&' code=5
{ 5, 128, 64, 0, 0, 0, 0, }, //glyph ''' code=6
{ 5, 64, 128, 128, 128, 64, 0, }, //glyph '(' code=7
{ 5, 128, 64, 64, 64, 128, 0, }, //glyph ')' code=8
{ 5, 0, 160, 64, 160, 0, 0, }, //glyph '*' code=9
{ 5, 0, 64, 224, 64, 0, 0, }, //glyph '+' code=10
{ 5, 0, 0, 0, 0, 128, 64, }, //glyph ',' code=11
{ 5, 0, 0, 224, 0, 0, 0, }, //glyph '-' code=12
{ 5, 0, 0, 0, 0, 128, 0, }, //glyph '.' code=13
{ 5, 8, 16, 32, 64, 128, 0, }, //glyph '/' code=14
{ 5, 96, 144, 144, 144, 96, 0, }, //glyph '0' code=15
{ 5, 64, 192, 64, 64, 224, 0, }, //glyph '1' code=16
{ 5, 224, 16, 96, 128, 240, 0, }, //glyph '2' code=17
{ 5, 224, 16, 96, 16, 224, 0, }, //glyph '3' code=18
{ 5, 144, 144, 240, 16, 16, 0, }, //glyph '4' code=19
{ 5, 240, 128, 224, 16, 224, 0, }, //glyph '5' code=20
{ 5, 96, 128, 224, 144, 96, 0, }, //glyph '6' code=21
{ 5, 240, 16, 32, 64, 64, 0, }, //glyph '7' code=22
{ 5, 96, 144, 96, 144, 96, 0, }, //glyph '8' code=23
{ 5, 96, 144, 112, 16, 96, 0, }, //glyph '9' code=24
{ 5, 0, 128, 0, 128, 0, 0, }, //glyph ':' code=25
{ 5, 0, 128, 0, 0, 128, 64, }, //glyph ';' code=26
{ 5, 32, 64, 128, 64, 32, 0, }, //glyph '<' code=27
{ 5, 0, 224, 0, 224, 0, 0, }, //glyph '=' code=28
{ 5, 128, 64, 32, 64, 128, 0, }, //glyph '>' code=29
{ 5, 224, 16, 96, 0, 64, 0, }, //glyph '?' code=30
{ 5, 96, 144, 176, 128, 112, 0, }, //glyph '@' code=31
{ 5, 96, 144, 240, 144, 144, 0, }, //glyph 'A' code=32
{ 5, 224, 144, 224, 144, 224, 0, }, //glyph 'B' code=33
{ 5, 112, 128, 128, 128, 112, 0, }, //glyph 'C' code=34
{ 5, 224, 144, 144, 144, 224, 0, }, //glyph 'D' code=35
{ 5, 240, 128, 224, 128, 240, 0, }, //glyph 'E' code=36
{ 5, 240, 128, 224, 128, 128, 0, }, //glyph 'F' code=37
{ 5, 112, 128, 176, 144, 112, 0, }, //glyph 'G' code=38
{ 5, 144, 144, 240, 144, 144, 0, }, //glyph 'H' code=39
{ 5, 224, 64, 64, 64, 224, 0, }, //glyph 'I' code=40
{ 5, 240, 16, 16, 144, 96, 0, }, //glyph 'J' code=41
{ 5, 144, 160, 192, 160, 144, 0, }, //glyph 'K' code=42
{ 5, 128, 128, 128, 128, 240, 0, }, //glyph 'L' code=43
{ 5, 136, 216, 168, 136, 136, 0, }, //glyph 'M' code=44
{ 5, 144, 208, 176, 144, 144, 0, }, //glyph 'N' code=45
{ 5, 96, 144, 144, 144, 96, 0, }, //glyph 'O' code=46
{ 5, 224, 144, 224, 128, 128, 0, }, //glyph 'P' code=47
{ 5, 96, 144, 144, 144, 96, 16, }, //glyph 'Q' code=48
{ 5, 224, 144, 224, 160, 144, 0, }, //glyph 'R' code=49
{ 5, 112, 128, 96, 16, 224, 0, }, //glyph 'S' code=50
{ 5, 224, 64, 64, 64, 64, 0, }, //glyph 'T' code=51
{ 5, 144, 144, 144, 144, 96, 0, }, //glyph 'U' code=52
{ 5, 160, 160, 160, 160, 64, 0, }, //glyph 'V' code=53
{ 5, 136, 168, 168, 168, 80, 0, }, //glyph 'W' code=54
{ 5, 144, 144, 96, 144, 144, 0, }, //glyph 'X' code=55
{ 5, 160, 160, 64, 64, 64, 0, }, //glyph 'Y' code=56
{ 5, 240, 16, 96, 128, 240, 0, }, //glyph 'Z' code=57
{ 5, 192, 128, 128, 128, 192, 0, }, //glyph '[' code=58
{ 5, 128, 64, 32, 16, 8, 0, }, //glyph '\' code=59
{ 5, 192, 64, 64, 64, 192, 0, }, //glyph ']' code=60
{ 5, 32, 80, 136, 0, 0, 0, }, //glyph '^' code=61
{ 5, 0, 0, 0, 0, 240, 0, }, //glyph '_' code=62
{ 5, 128, 64, 0, 0, 0, 0, }, //glyph '`' code=63
{ 5, 0, 224, 32, 224, 224, 0, }, //glyph 'a' code=64
{ 5, 128, 224, 160, 160, 224, 0, }, //glyph 'b' code=65
{ 5, 0, 224, 128, 128, 224, 0, }, //glyph 'c' code=66
{ 5, 32, 224, 160, 160, 224, 0, }, //glyph 'd' code=67
{ 5, 0, 224, 224, 128, 224, 0, }, //glyph 'e' code=68
{ 5, 64, 128, 192, 128, 128, 0, }, //glyph 'f' code=69
{ 5, 0, 224, 160, 224, 32, 224, }, //glyph 'g' code=70
{ 5, 128, 224, 160, 160, 160, 0, }, //glyph 'h' code=71
{ 5, 128, 0, 128, 128, 128, 0, }, //glyph 'i' code=72
{ 5, 0, 192, 64, 64, 64, 128, }, //glyph 'j' code=73
{ 5, 128, 160, 192, 160, 160, 0, }, //glyph 'k' code=74
{ 5, 128, 128, 128, 128, 128, 0, }, //glyph 'l' code=75
{ 5, 0, 248, 168, 168, 168, 0, }, //glyph 'm' code=76
{ 5, 0, 224, 160, 160, 160, 0, }, //glyph 'n' code=77
{ 5, 0, 224, 160, 160, 224, 0, }, //glyph 'o' code=78
{ 5, 0, 224, 160, 160, 224, 128, }, //glyph 'p' code=79
{ 5, 0, 224, 160, 160, 224, 32, }, //glyph 'q' code=80
{ 5, 0, 224, 128, 128, 128, 0, }, //glyph 'r' code=81
{ 5, 0, 192, 128, 64, 192, 0, }, //glyph 's' code=82
{ 5, 64, 224, 64, 64, 64, 0, }, //glyph 't' code=83
{ 5, 0, 160, 160, 160, 224, 0, }, //glyph 'u' code=84
{ 5, 0, 160, 160, 160, 64, 0, }, //glyph 'v' code=85
{ 5, 0, 168, 168, 168, 80, 0, }, //glyph 'w' code=86
{ 5, 0, 160, 64, 160, 160, 0, }, //glyph 'x' code=87
{ 5, 0, 160, 160, 224, 32, 224, }, //glyph 'y' code=88
{ 5, 0, 192, 64, 128, 192, 0, }, //glyph 'z' code=89
{ 5, 96, 64, 192, 64, 96, 0, }, //glyph '{' code=90
{ 5, 128, 128, 128, 128, 128, 0, }, //glyph '|' code=91
{ 5, 192, 64, 96, 64, 192, 0, }, //glyph '}' code=92
{ 5, 96, 192, 0, 0, 0, 0, }, //glyph '~' code=93
{ 5, 48, 64, 224, 64, 240, 0, }, //glyph '£' code=94
};
VGAX vga;
char *line[10];
int ptr = 0;
int linep = 0;
char topline = 0;
char seentop = 0;
int strp = 0;
int maxstr=10;
static char x=-VGAX_WIDTH;
void setup() {
for (int i = 0; i < 10; i++) {
line[i] = malloc(20);
line[i][0] = 0;
}
Serial.begin(4800);
vga.begin();
vga.noTone();
vga.clear(0);
}
void scroll(){
linep++;
ptr = 0;
if (linep >= 10 || seentop) {
linep = topline;
topline++;
if (topline >= 10) {
seentop = 1;
topline = 0;
}
}
line[linep][0] = 0;
}
void loop() {
int redraw = 0;
while (Serial.available() > 0) {
redraw = 1;
int ch = Serial.read();
if (ch == '\n') {
scroll();
} else if (ch != '\r') {
line[linep][ptr++] = ch;
line[linep][ptr] = 0;
if (ptr >= 19) {
scroll();
}
}
}
if(redraw) {
vga.clear(0);
for (int i = 0; i < 10; i++) {
int l = (topline + i)%10;
vga.printSRAM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 0, line[l], 0, i*6, 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment