Dispay Init
This commit is contained in:
parent
f1f799adfe
commit
50aac4425a
85
Arduino/Display/Display.ino
Normal file
85
Arduino/Display/Display.ino
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#include <Rainbowduino.h>
|
||||||
|
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user