From 592c96758f353cd5e6ce2574d342f429da0bc4ba Mon Sep 17 00:00:00 2001
From: kirbylife <gabriel13m@gmail.com>
Date: Sun, 16 Aug 2020 15:23:38 -0500
Subject: [PATCH] initial commit

---
 arduino_graphics_renderer.ino | 61 +++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 arduino_graphics_renderer.ino

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.h>
+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;
+}