diff --git a/docs/_sidebar.md b/docs/_sidebar.md index bd6b3506..a5ae85b0 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -11,7 +11,6 @@ - Features - [Apps](apps.md) - [Alarm clock](alarm.md) - - [Timer](timer.md) - [Icons](icons.md) - [Sounds](sounds.md) - [Hidden features](dev.md) diff --git a/docs/timer.md b/docs/timer.md index 30272bf2..e69de29b 100644 --- a/docs/timer.md +++ b/docs/timer.md @@ -1,31 +0,0 @@ -# Timer - -With AWTRIX Light, you can set a timer using MQTT. Simply send a JSON object to the topic **[PREFIX]/timer** to start a timer. - -When the timer goes off, the display will show a notification, and you can dismiss the timer by pressing the middle button. - -## JSON Properties - -The JSON object has the following properties: - -| Key | Type | Description | -| --- | ---- | ----------- | -| `hours` | number | The number of hours after midnight when the timer should be triggered. | -| `minutes` | number | The number of minutes after the hour when the timer should be triggered. | -| `seconds` | number | The number of seconds after the minute when the timer should be triggered. | -| `sound` | string | The name of the sound file (without extension) to play when the timer is triggered. | - -Each value is optional, so you can set a timer for just minutes, or any combination of hours, minutes, and seconds. If you only want to start a timer in some minutes, just send the minutes. - -## Example - -Here's an example JSON object to start a timer for 1 hour, 30 minutes, and 10 seconds, with the sound "friends": - -```json -{ - "hours": 1, - "minutes": 30, - "seconds": 10, - "sound": "friends" -} -``` diff --git a/src/MQTTManager.cpp b/src/MQTTManager.cpp index 07483616..4fb2ae06 100644 --- a/src/MQTTManager.cpp +++ b/src/MQTTManager.cpp @@ -7,7 +7,7 @@ #include #include "Dictionary.h" #include "PeripheryManager.h" -#include "Updater.h" +#include "UpdateManager.h" WiFiClient espClient; uint8_t lastBrightness; @@ -67,7 +67,7 @@ void onButtonCommand(HAButton *sender) else if (sender == doUpdate) { if (UPDATE_AVAILABLE) - Updater.updateFirmware(); + UpdateManager.updateFirmware(); } } @@ -194,7 +194,7 @@ void onMqttMessage(const char *topic, const uint8_t *payload, uint16_t length) if (strTopic == MQTT_PREFIX + "/doupdate") { if (UPDATE_AVAILABLE) - Updater.updateFirmware(); + UpdateManager.updateFirmware(); return; } diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index d64d25d2..029c4a2f 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -4,9 +4,9 @@ #include #include #include -#include +//#include #include -#include +#include String menuText; int menuSelection; @@ -378,9 +378,9 @@ void MenuManager_::selectButton() #endif case 13: - if (Updater.checkUpdate(true)) + if (UpdateManager.checkUpdate(true)) { - Updater.updateFirmware(); + UpdateManager.updateFirmware(); } break; default: diff --git a/src/ServerManager.cpp b/src/ServerManager.cpp index 32750513..046a0585 100644 --- a/src/ServerManager.cpp +++ b/src/ServerManager.cpp @@ -9,7 +9,7 @@ #include #include #include "DisplayManager.h" -#include "Updater.h" +#include "UpdateManager.h" WebServer server(80); FSWebServer mws(LittleFS, server); @@ -99,7 +99,7 @@ void ServerManager_::setup() { mws.webserver->sendContent(DisplayManager.getStat()); }); mws.addHandler("/api/doupdate", HTTP_POST, []() { if (UPDATE_AVAILABLE) - Updater.updateFirmware(); mws.webserver->send(200,"OK"); }); + UpdateManager.updateFirmware(); mws.webserver->send(200,"OK"); }); Serial.println("Webserver loaded"); } mws.addHandler("/version", HTTP_GET, versionHandler); diff --git a/src/Updater.cpp b/src/UpdateManager.cpp similarity index 90% rename from src/Updater.cpp rename to src/UpdateManager.cpp index 7c9420e3..b1a8f881 100644 --- a/src/Updater.cpp +++ b/src/UpdateManager.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -14,14 +14,14 @@ Ticker UpdateTicker; // The getter for the instantiated singleton instance -Updater_ &Updater_::getInstance() +UpdateManager_ &UpdateManager_::getInstance() { - static Updater_ instance; + static UpdateManager_ instance; return instance; } // Initialize the global shared instance -Updater_ &Updater = Updater.getInstance(); +UpdateManager_ &UpdateManager = UpdateManager.getInstance(); void update_started() { @@ -43,7 +43,7 @@ void update_error(int err) DisplayManager.show(); } -void Updater_::updateFirmware() +void UpdateManager_::updateFirmware() { WiFiClientSecure client; client.setCACert(rootCACertificate); @@ -70,7 +70,7 @@ void Updater_::updateFirmware() } } -bool Updater_::checkUpdate(bool withScreen) +bool UpdateManager_::checkUpdate(bool withScreen) { if (withScreen) { @@ -143,10 +143,10 @@ bool Updater_::checkUpdate(bool withScreen) void checkUpdateNoReturn() { Serial.println("Check Update"); - Updater.getInstance().checkUpdate(false); + UpdateManager.getInstance().checkUpdate(false); } -void Updater_::setup() +void UpdateManager_::setup() { UpdateTicker.attach(3600, checkUpdateNoReturn); } diff --git a/src/UpdateManager.h b/src/UpdateManager.h new file mode 100644 index 00000000..e4109e80 --- /dev/null +++ b/src/UpdateManager.h @@ -0,0 +1,18 @@ +#ifndef UpdateManager_h +#define UpdateManager_h + +#include + +class UpdateManager_ +{ +private: + UpdateManager_() = default; +public: + static UpdateManager_ &getInstance(); + void setup(); + bool checkUpdate(bool); + void updateFirmware(); +}; + +extern UpdateManager_ &UpdateManager; +#endif diff --git a/src/main.cpp b/src/main.cpp index 0a2fa694..1dd65fb4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -36,7 +36,7 @@ #include "MQTTManager.h" #include "ServerManager.h" #include "Globals.h" -#include "Updater.h" +#include "UpdateManager.h" TaskHandle_t taskHandle; volatile bool StopTask = false; @@ -74,8 +74,8 @@ void setup() { MQTTManager.setup(); DisplayManager.loadNativeApps(); - Updater.setup(); - Updater.checkUpdate(false); + UpdateManager.setup(); + UpdateManager.checkUpdate(false); StopTask = true; float x = 4; while (x >= -85) diff --git a/src/updater.h b/src/updater.h deleted file mode 100644 index 8a06fb21..00000000 --- a/src/updater.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef UPDATER_h -#define UPDATER_h - -#include - -class Updater_ -{ -private: - Updater_() = default; -public: - static Updater_ &getInstance(); - void setup(); - bool checkUpdate(bool); - void updateFirmware(); -}; - -extern Updater_ &Updater; -#endif