From c98529b685171a4142d043c06f2eed0c4e8078fc Mon Sep 17 00:00:00 2001 From: RLF Date: Thu, 28 Dec 2023 19:41:46 -0500 Subject: [PATCH] Update uno-stats-monitor/monitor_uno.ino cleanup --- uno-stats-monitor/monitor_uno.ino | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/uno-stats-monitor/monitor_uno.ino b/uno-stats-monitor/monitor_uno.ino index 36f7348..035c7ab 100644 --- a/uno-stats-monitor/monitor_uno.ino +++ b/uno-stats-monitor/monitor_uno.ino @@ -252,7 +252,7 @@ void LedShowLoad(const char *load) else if(myload <= 60 && myload > 50) segments = 5; else if(myload <= 70 && myload > 60) segments = 6; else if(myload <= 85 && myload > 70) segments = 7; - else if(myload > 84) segments = 8; + else if(myload >= 86) segments = 8; // segments as rows for(int row=0;row<8;row++) { @@ -305,7 +305,7 @@ void IRtranslate() delay(500); } -// serial/IR receive +// serial receive void SERrecv() { static boolean recvInProgress = false; @@ -333,15 +333,20 @@ void SERrecv() SERnewData = true; } } - else if(rc == startMarker) { recvInProgress = true; } } } -// display stats on LCD and load average on LED -void showNewData() +// process new data +// data schema: +// 1st character denotes function: +// 1 - print on 1st line as is +// 2 - print on 2nd line as is +// 3 - display load on LCD matrix +// 4 - set a setting +void procNewData() { if(SERnewData == true) { if(DEBUG) { @@ -349,19 +354,23 @@ void showNewData() Serial.println(SERrecvChars); } - // Print on line 1 or 2 - // dev: fucking c and its fixed arrays - // we have to define 1st character (line number) as BS and when printing, search for that BS character to skip printing that 1 character, grrr + // Chooser + // dev: we have to define 1st character (line number) as BS and when printing, search for that BS character to skip printing that 1 character + // print on line 1 if(SERrecvChars[0] == '1') { LcdL1(true); SERrecvChars[0] = '\b'; LcdWrite(SERrecvChars); } + + // print on line 2 else if(SERrecvChars[0] == '2') { LcdL2(true); SERrecvChars[0] = '\b'; LcdWrite(SERrecvChars); } + + // show load on led matrix else if(SERrecvChars[0] == '3') { SERrecvChars[0] = ' '; LedShowLoad(SERrecvChars); @@ -389,7 +398,7 @@ void setup (void) // main() void loop (void) { - //process IR signal + // process IR signal if(Irrecv.decode(&IRresults)) { IRtranslate(); Irrecv.resume(); // receive the next value @@ -398,6 +407,6 @@ void loop (void) // process serial input SERrecv(); - // display new data - showNewData(); + // process new data + procNewData(); }