commit 592c96758f353cd5e6ce2574d342f429da0bc4ba Author: kirbylife Date: Sun Aug 16 15:23:38 2020 -0500 initial commit diff --git a/arduino_graphics_renderer.ino b/arduino_graphics_renderer.ino new file mode 100644 index 0000000..049f324 --- /dev/null +++ b/arduino_graphics_renderer.ino @@ -0,0 +1,61 @@ +#include +VGAX vga; + +char mystr[5]; + +void setup() { + //pinMode(LED_BUILTIN, OUTPUT); + vga.begin(); + Serial.begin(9600); + vga.clear(1); +} + +void loop() { + boolean sync = getIns() == '|'; + if(!sync) + return; + + switch(getIns()) { + case 0: { + Serial.readBytes(mystr,1); + // byte color = getIns(); + byte color = mystr[0]; + vga.clear(color); + break; + }; + case 1: { + Serial.readBytes(mystr,3); + /*byte x = getIns(); + byte y = getIns(); + byte color = getIns();*/ + byte x = mystr[0]; + byte y = mystr[1]; + byte color = mystr[2]; + vga.putpixel(x, y, color); + }; + case 2: { + Serial.readBytes(mystr,5); + /*byte x = getIns(); + byte y = getIns(); + byte width = getIns(); + byte height = getIns(); + byte color = getIns();*/ + byte x = mystr[0]; + byte y = mystr[1]; + byte width = mystr[2]; + byte height = mystr[3]; + byte color = mystr[4]; + vga.fillrect(x, y, width, height, color); + } + } +} + +byte getIns() { + while(Serial.available() < 0) { + } + byte output; + do { + output = Serial.read(); + } while(output == 255); + return output; +}