diff --git a/data b/data index e21b989..2c7f7f6 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit e21b9895a7c93f62565ffa2cd1d6c085b9b74035 +Subproject commit 2c7f7f667ccb10271db072a4b4e6bf8fd4912f2b diff --git a/src/lib/defaults.hpp b/src/lib/defaults.hpp index 2659df0..8e16eb8 100644 --- a/src/lib/defaults.hpp +++ b/src/lib/defaults.hpp @@ -15,6 +15,7 @@ #define DEFAULT_USE_BLOCK_COUNTDOWN true #define DEFAULT_SUFFIX_PRICE false #define DEFAULT_DISABLE_LEDS false +#define DEFAULT_DISABLE_FL false #define DEFAULT_OWN_DATA_SOURCE true #define DEFAULT_STAGING_SOURCE false #define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD diff --git a/src/lib/led_handler.cpp b/src/lib/led_handler.cpp index e124ea1..0d780a6 100644 --- a/src/lib/led_handler.cpp +++ b/src/lib/led_handler.cpp @@ -13,6 +13,9 @@ bool flInTransition = false; void frontlightFlash(int flDelayTime) { + if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + return; + if (frontlightOn) { frontlightFadeOutAll(flDelayTime, true); @@ -65,6 +68,8 @@ void frontlightFadeInAll(int flDelayTime) void frontlightFadeInAll(int flDelayTime, bool staggered) { + if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + return; if (frontlightIsOn()) return; if (flInTransition) @@ -115,6 +120,8 @@ void frontlightFadeOutAll(int flDelayTime) void frontlightFadeOutAll(int flDelayTime, bool staggered) { + if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + return; if (!frontlightIsOn()) return; if (flInTransition) @@ -179,6 +186,8 @@ bool frontlightIsOn() void frontlightFadeIn(uint num, int flDelayTime) { + if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + return; for (int dutyCycle = 0; dutyCycle <= preferences.getUInt("flMaxBrightness"); dutyCycle += 5) { flArray.setPWM(num, 0, dutyCycle); @@ -188,6 +197,8 @@ void frontlightFadeIn(uint num, int flDelayTime) void frontlightFadeOut(uint num, int flDelayTime) { + if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL)) + return; if (!frontlightIsOn()) return; diff --git a/src/lib/screen_handler.cpp b/src/lib/screen_handler.cpp index 269d2a7..9335020 100644 --- a/src/lib/screen_handler.cpp +++ b/src/lib/screen_handler.cpp @@ -282,7 +282,7 @@ void nextScreen() { newCurrentScreen = screenMappings.front().value; } - String key = "screen" + String(screenMappings[currentIndex - 1].value) + "Visible"; + String key = "screen" + String(newCurrentScreen) + "Visible"; while (!preferences.getBool(key.c_str(), true)) { currentIndex = findScreenIndexByValue(newCurrentScreen); @@ -294,7 +294,7 @@ void nextScreen() { key = "screen" + String(newCurrentScreen) + "Visible"; } - + setCurrentScreen(newCurrentScreen); } @@ -326,8 +326,9 @@ void previousScreen() { } void showSystemStatusScreen() { - std::array sysStatusEpdContent = {"", "", "", "", - "", "", ""}; + std::array sysStatusEpdContent; + std::fill(sysStatusEpdContent.begin(), sysStatusEpdContent.end(), ""); + String ipAddr = WiFi.localIP().toString(); String subNet = WiFi.subnetMask().toString(); diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index 0d516f1..352983d 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -37,6 +37,9 @@ void setupWebserver() server.on("/api/show/screen", HTTP_GET, onApiShowScreen); server.on("/api/show/text", HTTP_GET, onApiShowText); + server.on("/api/screen/next", HTTP_GET, onApiScreenNext); + server.on("/api/screen/previous", HTTP_GET, onApiScreenPrevious); + AsyncCallbackJsonWebHandler *settingsPatchHandler = new AsyncCallbackJsonWebHandler("/api/json/settings", onApiSettingsPatch); server.addHandler(settingsPatchHandler); @@ -373,6 +376,27 @@ void onApiShowScreen(AsyncWebServerRequest *request) request->send(200); } +/** + * @Api + * @Path("/api/screen/next") + */ +void onApiScreenNext(AsyncWebServerRequest *request) +{ + nextScreen(); + request->send(200); +} + +/** + * @Api + * @Path("/api/screen/previous") + */ +void onApiScreenPrevious(AsyncWebServerRequest *request) +{ + previousScreen(); + + request->send(200); +} + void onApiShowText(AsyncWebServerRequest *request) { if (request->hasParam("t")) @@ -478,7 +502,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json) String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd", "mdnsEnabled", "otaEnabled", "stealFocus", "mcapBigChar", "useSatsSymbol", "useBlkCountdown", - "suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource"}; + "suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flDisable", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource"}; for (String setting : boolSettings) { @@ -611,6 +635,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request) #ifdef HAS_FRONTLIGHT root["hasFrontlight"] = true; + root["flDisable"] = preferences.getBool("flDisable", DEFAULT_DISABLE_FL); root["flMaxBrightness"] = preferences.getUInt("flMaxBrightness", DEFAULT_FL_MAX_BRIGHTNESS); root["flAlwaysOn"] = preferences.getBool("flAlwaysOn", DEFAULT_FL_ALWAYS_ON); root["flEffectDelay"] = preferences.getUInt("flEffectDelay", DEFAULT_FL_EFFECT_DELAY); diff --git a/src/lib/webserver.hpp b/src/lib/webserver.hpp index 3d16b35..b47d115 100644 --- a/src/lib/webserver.hpp +++ b/src/lib/webserver.hpp @@ -25,6 +25,10 @@ void onApiStatus(AsyncWebServerRequest *request); void onApiSystemStatus(AsyncWebServerRequest *request); void onApiSetWifiTxPower(AsyncWebServerRequest *request); + +void onApiScreenNext(AsyncWebServerRequest *request); +void onApiScreenPrevious(AsyncWebServerRequest *request); + void onApiShowScreen(AsyncWebServerRequest *request); void onApiShowText(AsyncWebServerRequest *request); void onApiIdentify(AsyncWebServerRequest *request);