minor code clean up
This commit is contained in:
parent
ef9bb53274
commit
d8c52eb62b
36
M2/M2.ino
36
M2/M2.ino
|
@ -60,7 +60,7 @@ void drawGui(screenMode COLOR_MODE) {
|
||||||
|
|
||||||
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
||||||
|
|
||||||
// BOTTOM
|
// BUTTONS
|
||||||
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
||||||
screenModeButton.draw();
|
screenModeButton.draw();
|
||||||
if (COLOR_MODE == DARK) {
|
if (COLOR_MODE == DARK) {
|
||||||
|
@ -86,6 +86,7 @@ void drawGui(screenMode COLOR_MODE) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// BUTTON HANDLERS
|
||||||
void screenModeHandler(Event& e) {
|
void screenModeHandler(Event& e) {
|
||||||
M5.Axp.SetLDOEnable(3, true);
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
delay(125);
|
delay(125);
|
||||||
|
@ -189,23 +190,23 @@ void rawHandler(Event& e) {
|
||||||
drawGui(COLOR_MODE);
|
drawGui(COLOR_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// WRITING DATA ON SCREEN
|
||||||
void writeScreenData(dataMode DATA_MODE, screenMode COLOR_MODE, int data[4]){
|
void writeScreenData(dataMode DATA_MODE, screenMode COLOR_MODE, int data[4]){
|
||||||
|
|
||||||
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
||||||
|
|
||||||
if(DATA_MODE == ATTENTION){
|
if(DATA_MODE == ATTENTION){
|
||||||
//Serial2.print((1));
|
|
||||||
M5.Lcd.drawString("ATTENTION", 90, 80, 4);
|
M5.Lcd.drawString("ATTENTION", 90, 80, 4);
|
||||||
}else if(DATA_MODE ==MEDITATION){
|
}else if(DATA_MODE ==MEDITATION){
|
||||||
//Serial2.print(String(2));
|
|
||||||
M5.Lcd.drawString("MEDITATION", 84, 80, 4);
|
M5.Lcd.drawString("MEDITATION", 84, 80, 4);
|
||||||
}else if(DATA_MODE == QUALITY){
|
}else if(DATA_MODE == QUALITY){
|
||||||
//Serial2.print(String(3));
|
|
||||||
M5.Lcd.drawString("SIGNAL QUALITY", 60, 80, 4);
|
M5.Lcd.drawString("SIGNAL QUALITY", 60, 80, 4);
|
||||||
}else if(DATA_MODE == RAW){
|
}else if(DATA_MODE == RAW){
|
||||||
M5.Lcd.drawString("RAW", 132, 80, 4);
|
M5.Lcd.drawString("RAW", 132, 80, 4);
|
||||||
}else{
|
}else{
|
||||||
//Serial2.print(String(0));
|
|
||||||
M5.Lcd.drawString("...", 148, 100, 4);
|
M5.Lcd.drawString("...", 148, 100, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(DATA_MODE != STOP){
|
if(DATA_MODE != STOP){
|
||||||
if(COLOR_MODE == DARK) {
|
if(COLOR_MODE == DARK) {
|
||||||
M5.Lcd.fillRect(132,116,64,64,COLORS[LIGHT]);
|
M5.Lcd.fillRect(132,116,64,64,COLORS[LIGHT]);
|
||||||
|
@ -228,28 +229,37 @@ int countDigit(int n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String stringReceived = "";
|
String stringReceived = "";
|
||||||
int valuesReceived[4]/* = {0,0,0,0}*/;
|
int valuesReceived[4];
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
M5.update();
|
M5.update();
|
||||||
|
|
||||||
|
//WAITS FOR DATA IN UART
|
||||||
while(Serial2.available())
|
while(Serial2.available())
|
||||||
{
|
{
|
||||||
char c = Serial2.read();
|
char c = Serial2.read();
|
||||||
//Serial.print(c);
|
|
||||||
stringReceived += c;
|
stringReceived += c;
|
||||||
|
|
||||||
|
//ONCE LONG ENOUGH DATA HAS BEEN RECIEVED PROCEEDS
|
||||||
if (stringReceived.length() == 17) {
|
if (stringReceived.length() == 17) {
|
||||||
//Serial.println(" s:"+stringReceived);
|
|
||||||
|
// POPULATES ARRAY OF VALUES
|
||||||
valuesReceived[RAW] = stringReceived.substring(9).toInt();
|
valuesReceived[RAW] = stringReceived.substring(9).toInt();
|
||||||
valuesReceived[QUALITY] = stringReceived.substring(6,9).toInt();
|
valuesReceived[QUALITY] = stringReceived.substring(6,9).toInt();
|
||||||
valuesReceived[MEDITATION] = stringReceived.substring(3,6).toInt();
|
valuesReceived[MEDITATION] = stringReceived.substring(3,6).toInt();
|
||||||
valuesReceived[ATTENTION] = stringReceived.substring(0,3).toInt();
|
valuesReceived[ATTENTION] = stringReceived.substring(0,3).toInt();
|
||||||
Serial.print("A:" + String(valuesReceived[ATTENTION]));
|
|
||||||
Serial.print(" M:" + String(valuesReceived[MEDITATION]));
|
// PRINTS VALUES INTO USB SERIAL CONSOLE
|
||||||
Serial.print(" Q:" + String(valuesReceived[QUALITY]));
|
Serial.print("AT:" + String(valuesReceived[ATTENTION]));
|
||||||
Serial.print(" R:" + String(valuesReceived[RAW]) + "\n");
|
Serial.print(" MD:" + String(valuesReceived[MEDITATION]));
|
||||||
|
Serial.print(" SQ:" + String(valuesReceived[QUALITY]));
|
||||||
|
Serial.print(" RW:" + String(valuesReceived[RAW]) + "\n");
|
||||||
|
|
||||||
|
//RESETS STRING
|
||||||
stringReceived = "";
|
stringReceived = "";
|
||||||
|
|
||||||
|
//WRITES LATEST DATA ON SCREEN
|
||||||
writeScreenData(DATA_MODE, COLOR_MODE, valuesReceived);
|
writeScreenData(DATA_MODE, COLOR_MODE, valuesReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue