From 1769ebabbbc6acd5187ac85925c1489ce7d594e4 Mon Sep 17 00:00:00 2001 From: RLF Date: Wed, 27 Dec 2023 00:32:10 -0500 Subject: [PATCH] cleanup --- uno-stats-monitor/monitor_uno.ino | 78 ++++++++++++++++++------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/uno-stats-monitor/monitor_uno.ino b/uno-stats-monitor/monitor_uno.ino index c077735..0dc7366 100644 --- a/uno-stats-monitor/monitor_uno.ino +++ b/uno-stats-monitor/monitor_uno.ino @@ -1,5 +1,5 @@ /* - * UNO Monitor Receiver (4bit LCD Version) + * UNO Monitor Receiver (4-bit LCD Version) * kidacro@archamedis.net * * Waits for input over serial connection and displays on LCD @@ -47,7 +47,38 @@ boolean newData = false; // Debugging (serial console must be connected) bool DEBUG = 1; - + +void LcdL1(boolean wipe = false) { + delay(10); + LCD.setCursor(0, 0); // Define the cursor position as the 1st position of the 1st line + + if(wipe) { + LcdWrite(" "); // 16 spaces for a blank line + LCD.setCursor(0, 0); + } + + delay(10); +} + +void LcdL2(boolean wipe = false) { + delay(10); + LCD.setCursor(0, 1); // Define the cursor position as the 1st position of the 2nd line + + if(wipe) { + LcdWrite(" "); // 16 spaces for a blank line + LCD.setCursor(0, 1); + } + + delay(10); +} + +void LcdCls(void) { + delay(10); + LCD.clear(); // The screen is empty + LcdL1(); // the cursor position is zeroed + delay(10); +} + void LcdSetup(void) { // set up the LCD's number of columns and rows: LCD.begin(LCDLength, 2); @@ -59,31 +90,12 @@ void LcdSetup(void) { LCD.print("Waiting for data"); } -void LcdCls(void) { - delay(10); - LCD.clear(); // The screen is empty - LcdL1(); // the cursor position is zeroed - delay(10); -} - -void LcdL1() { - delay(10); - LCD.setCursor(0, 0); // Define the cursor position as the 1st position of the 1st line - delay(10); -} - -void LcdL2() { - delay(10); - LCD.setCursor(0, 1); // Define the cursor position as the 1st position of the 2nd line - delay(10); -} - -// returns starting position of text +/* returns starting position of text void LcdCenter(int mylen) { int mypos = 0; return mypos; -} +}*/ void LcdWrite(String mymessage) { int i = 0; @@ -121,9 +133,15 @@ void LcdWriteExample() { LcdL1(); LcdWrite("Archamedis Stats"); - LcdL2(); + delay(20); + + LcdL1(true); LcdWrite("4.3ghz 89% 68C"); - + + delay(20); + + LcdL2(); + LcdWrite("Ryzen 9 5950x"); } void recvWithStartEndMarkers() { @@ -169,16 +187,12 @@ void showNewData() { // 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 if(receivedChars[0] == '1') { - LcdL1(); - LcdWrite(" "); // 16 spaces for a blank line - LcdL1(); + LcdL1(true); receivedChars[0] = '\b'; LcdWrite(receivedChars); } else if(receivedChars[0] == '2') { - LcdL2(); - LcdWrite(" "); // 16 spaces for a blank line - LcdL2(); + LcdL2(true); receivedChars[0] = '\b'; LcdWrite(receivedChars); } @@ -211,4 +225,4 @@ void loop (void) { // process input recvWithStartEndMarkers(); showNewData(); -} +} \ No newline at end of file