From 513835bc354664bfaed5417e4911a74b05dd25d7 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Tue, 8 Oct 2024 23:42:32 +1100 Subject: fix displayoff also add a toggle option --- src/matrixdisplay.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/matrixdisplay.cpp b/src/matrixdisplay.cpp index 24ebb0f..839a7af 100755 --- a/src/matrixdisplay.cpp +++ b/src/matrixdisplay.cpp @@ -73,6 +73,7 @@ struct message }; bool wificonnected; +bool displayon; void saveconfig(); void printLocalTime(); @@ -273,13 +274,21 @@ void handlecmd() if (strcmp(value, "off") == 0) { printf("turning matrix off\n"); + displayon = false; myDisplay.displayShutdown(true); } else if (strcmp(value, "on") == 0) { printf("turning matrix on\n"); + displayon = true; myDisplay.displayShutdown(false); } + else if (strcmp(value, "toggle") == 0) + { + printf("toggling matrix\n"); + displayon = !displayon; + myDisplay.displayShutdown(!displayon); + } } } server.send(200, "application/json", ""); @@ -371,6 +380,7 @@ void printLocalTime() void setup() { wificonnected = false; + displayon = true; esp_log_level_set("*", ESP_LOG_VERBOSE); preferences.begin("matrixdisplay", false); globalconf.pos = 0; @@ -478,6 +488,8 @@ char msgbuff[MSG_SIZE]; char rtemp[15] = {0}; void nextmessage() { + if (!displayon) return; + if (globalconf.pos >= NUM_MESSAGES) { globalconf.pos = 0; @@ -602,7 +614,7 @@ void doom() void loop() { - if (myDisplay.displayAnimate()) + if (displayon && myDisplay.displayAnimate()) { nextmessage(); // doom(); -- cgit v1.2.3