summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Jones <daniel@danieljon.es>2024-10-08 23:42:32 +1100
committerDaniel Jones <daniel@danieljon.es>2024-10-08 23:42:32 +1100
commit513835bc354664bfaed5417e4911a74b05dd25d7 (patch)
tree9c5a2da1a7840190e8aa29c7826280ea50a191d7 /src
parent732704a6f6f14d6107bd3db864d8fc4605579942 (diff)
fix displayoff
also add a toggle option
Diffstat (limited to 'src')
-rwxr-xr-xsrc/matrixdisplay.cpp14
1 files changed, 13 insertions, 1 deletions
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();