From 50aac4425a1b028555f68abfb7a7db8cc6c1c565 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Thu, 21 Jan 2016 13:13:57 +0000 Subject: [PATCH] Dispay Init --- Arduino/Display/Display.ino | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Arduino/Display/Display.ino diff --git a/Arduino/Display/Display.ino b/Arduino/Display/Display.ino new file mode 100644 index 0000000..204f465 --- /dev/null +++ b/Arduino/Display/Display.ino @@ -0,0 +1,85 @@ +#include + +#define MAX_STORE_DATA 8 + +void setup() { + Serial.begin(9600); + Serial.println("Init...."); + Rb.init(); + Serial.println("Init finished!"); +} + +String store[MAX_STORE_DATA]; +int count = 0; + +String msg; +char c; +void loop() { + if (Serial.available()) { + c = Serial.read(); + if (c == '\n') { + parse(msg); + msg = ""; + } else { + msg += c; + } + } +} + +void parse(String text) { + text.trim(); + String action = ""; + String value = ""; + if (text.indexOf("=") != -1) { + action = text.substring(0, text.indexOf("=")); + value = text.substring(text.indexOf("=") + 1); + doJob(action, value); + } +} +int job = -1; +int online = -1; +void doJob(String task, String value) { + if (task == "job") { + char b = '!'; + uint32_t co = 0; + if(value.toInt() == 1) { + b = 'F'; //Fraunhofer + co = 0x00FF22; //Fraunhofer Color + } else if(value.toInt() == 2) { + b = 'R'; //Rwth Aachen + co = 0x00539F; //Rwth Color + } + job = value.toInt(); + Rb.fillRectangle(1, 2, 6, 7, 0x000000); + Rb.drawChar(b, 1, 1, co); + } else if(task == "online") { + Rb.setPixelXY(0,7,value.toInt()==0?0xFF0000:0x00FF00); + online = value.toInt(); + } else if(task == "getJob") { + Serial.println("setJob="+String(job)); + } else if(task == "getOnline") { + Serial.println("setOnline="+String(online)); + } else if(task == "tag") { + Rb.fillRectangle(0, 0, 8, 1, 0x000000); + if(count < MAX_STORE_DATA) { + count++; + store[count-1] = String("tag="+value); + //Serial.println("d: "+ store[count-1]); + //Serial.println("d: "+ String(count)); + } + Rb.fillRectangle(7-(count-1), 0, 8, 1, 0xFFFF00); + } else if(task == "getStoreCount") { + Serial.println("hasCount="+String(count)); + } else if(task == "getStoreData") { + if(count > 0) { + Serial.print("dataStore="); + for(int i=0; i < count-1; i++) { + Serial.print(store[i]+"|"); + } + Serial.println(store[count-1]); + count = 0; + Rb.fillRectangle(0, 0, 8, 1, 0x000000); + } + } +} +