diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 1f29159..bd6b350 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -14,6 +14,7 @@ - [Timer](timer.md) - [Icons](icons.md) - [Sounds](sounds.md) + - [Hidden features](dev.md) - API - [MQTT/HTTP](api.md) diff --git a/docs/custom.md b/docs/custom.md index 64eecf7..d2d5345 100644 --- a/docs/custom.md +++ b/docs/custom.md @@ -45,4 +45,4 @@ Here's an example JSON object to display the text "Hello, AWTRIX Light!" with th ## Delete a custom app To delete a custom app simply send a empty payload/body to the same topic/url. -You can also use [this API](api?id=addremove-and-rearange-apps) +You can also use [this API](api?id=addremove-and-rearange-apps) \ No newline at end of file diff --git a/docs/dev.md b/docs/dev.md new file mode 100644 index 0000000..84e92f2 --- /dev/null +++ b/docs/dev.md @@ -0,0 +1,15 @@ +# Hidden Features + +Ok, now they are no longer hidden :). +This section contains small setting options that the majority of users do not change or change very rarely and therefore saved the effort of creating an elaborate settings interface. + +Create a `dev.json` in your filemanager. + +## JSON Properties + +The JSON object has the following properties: + +| Key | Type | Description | Default | +| --- | ---- | ----------- | ------- | +| `bootsound` | string | Uses a custom melodie from the MELODIES folder | standart | +| `uppercase` | boolean | Print every character in uppercase | true | diff --git a/docs/onscreen.md b/docs/onscreen.md index caa5f0f..57549bd 100644 --- a/docs/onscreen.md +++ b/docs/onscreen.md @@ -18,5 +18,6 @@ Hold down the middle button for 2s to exit the current menu and to save your set | `WEEKDAY` | Allows selection of start of week. | | `TEMP` | Allows selection of temperature system (°C or °F). | | `APPS` | Allows to enable or disable internal apps | +| `SOUND` | Allows to enable or disable sound output | | `UPDATE` | Check and download new firmware if available. | diff --git a/src/Globals.cpp b/src/Globals.cpp index 46fc48d..985bb2b 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -51,6 +51,11 @@ void loadDevSettings() BOOT_SOUND = doc["bootsound"].as(); } + if (doc.containsKey("bootsound")) + { + UPPERCASE_LETTERS = doc["uppercase"].as(); + } + file.close(); } diff --git a/src/ServerManager.cpp b/src/ServerManager.cpp index bd322d4..f34edab 100644 --- a/src/ServerManager.cpp +++ b/src/ServerManager.cpp @@ -37,83 +37,6 @@ void saveHandler() webRequest->send(200); } -void handleAPIRequest() -{ - WebServerClass *webRequest = mws.getRequest(); - String url = webRequest->uri(); - url.replace("/api", ""); - if (webRequest->method() == HTTP_POST) - { - String body = webRequest->arg("plain"); - const char *bodyPtr = body.c_str(); - webRequest->send(200); - if (url == "/notify") - { - if (body[0] != '{' || body[strlen(bodyPtr) - 1] != '}') - { - webRequest->send(400, "text/plain", "Invalid payload format"); - return; - } - DisplayManager.generateNotification(bodyPtr); - } - - else if (url == "/timer") - { - DisplayManager.gererateTimer(bodyPtr); - } - - else if (url == "/notify/dismiss") - { - DisplayManager.dismissNotify(); - } - - else if (url == "/apps") - { - DisplayManager.updateAppVector(bodyPtr); - } - - else if (url == "/switch") - { - DisplayManager.switchToApp(bodyPtr); - } - - else if (url == "/settings") - { - DisplayManager.setNewSettings(bodyPtr); - } - - else if (url == "/nextapp") - { - DisplayManager.nextApp(); - } - - else if (url == "/previousapp") - { - DisplayManager.previousApp(); - } - - else if (url.startsWith("/custom")) - { - String topic_str = url.substring(MQTT_PREFIX.length() + 7); - DisplayManager.generateCustomPage(topic_str, bodyPtr); - } - else - { - webRequest->send(400); - } - } - else if (webRequest->method() == HTTP_GET) - { - if (url == "/stats") - { - webRequest->sendContent(DisplayManager.getStat()); - } - else - { - webRequest->send(400); - } - } -} void ServerManager_::setup() { @@ -153,8 +76,6 @@ void ServerManager_::setup() mws.addHTML(custom_html, "icon_html"); mws.addCSS(custom_css); mws.addJavascript(custom_script); - mws.addOptionBox("General"); - mws.addOption("Uppercase letters", UPPERCASE_LETTERS); mws.addHandler("/save", HTTP_POST, saveHandler); mws.addHandler("/api/notify", HTTP_POST, []() {DisplayManager.generateNotification(mws.webserver->arg("plain").c_str()); mws.webserver->send(200,"OK"); }); @@ -266,7 +187,6 @@ void ServerManager_::loadSettings() NET_SN = doc["Subnet"].as(); NET_PDNS = doc["Primary DNS"].as(); NET_SDNS = doc["Secondary DNS"].as(); - UPPERCASE_LETTERS = doc["Uppercase letters"]; file.close(); DisplayManager.applyAllSettings(); Serial.println(F("Configuration loaded"));