Update uno-stats-monitor/monitor_uno.ino

cleanup
This commit is contained in:
RLF
2023-12-28 19:41:46 -05:00
parent 71ffd58cfe
commit c98529b685

View File

@@ -252,7 +252,7 @@ void LedShowLoad(const char *load)
else if(myload <= 60 && myload > 50) segments = 5; else if(myload <= 60 && myload > 50) segments = 5;
else if(myload <= 70 && myload > 60) segments = 6; else if(myload <= 70 && myload > 60) segments = 6;
else if(myload <= 85 && myload > 70) segments = 7; else if(myload <= 85 && myload > 70) segments = 7;
else if(myload > 84) segments = 8; else if(myload >= 86) segments = 8;
// segments as rows // segments as rows
for(int row=0;row<8;row++) { for(int row=0;row<8;row++) {
@@ -305,7 +305,7 @@ void IRtranslate()
delay(500); delay(500);
} }
// serial/IR receive // serial receive
void SERrecv() void SERrecv()
{ {
static boolean recvInProgress = false; static boolean recvInProgress = false;
@@ -333,15 +333,20 @@ void SERrecv()
SERnewData = true; SERnewData = true;
} }
} }
else if(rc == startMarker) { else if(rc == startMarker) {
recvInProgress = true; recvInProgress = true;
} }
} }
} }
// display stats on LCD and load average on LED // process new data
void showNewData() // 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(SERnewData == true) {
if(DEBUG) { if(DEBUG) {
@@ -349,19 +354,23 @@ void showNewData()
Serial.println(SERrecvChars); Serial.println(SERrecvChars);
} }
// Print on line 1 or 2 // Chooser
// dev: fucking c and its fixed arrays // 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
// 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 // print on line 1
if(SERrecvChars[0] == '1') { if(SERrecvChars[0] == '1') {
LcdL1(true); LcdL1(true);
SERrecvChars[0] = '\b'; SERrecvChars[0] = '\b';
LcdWrite(SERrecvChars); LcdWrite(SERrecvChars);
} }
// print on line 2
else if(SERrecvChars[0] == '2') { else if(SERrecvChars[0] == '2') {
LcdL2(true); LcdL2(true);
SERrecvChars[0] = '\b'; SERrecvChars[0] = '\b';
LcdWrite(SERrecvChars); LcdWrite(SERrecvChars);
} }
// show load on led matrix
else if(SERrecvChars[0] == '3') { else if(SERrecvChars[0] == '3') {
SERrecvChars[0] = ' '; SERrecvChars[0] = ' ';
LedShowLoad(SERrecvChars); LedShowLoad(SERrecvChars);
@@ -389,7 +398,7 @@ void setup (void)
// main() // main()
void loop (void) void loop (void)
{ {
//process IR signal // process IR signal
if(Irrecv.decode(&IRresults)) { if(Irrecv.decode(&IRresults)) {
IRtranslate(); IRtranslate();
Irrecv.resume(); // receive the next value Irrecv.resume(); // receive the next value
@@ -398,6 +407,6 @@ void loop (void)
// process serial input // process serial input
SERrecv(); SERrecv();
// display new data // process new data
showNewData(); procNewData();
} }