From 2a116d97ed88333296949c6b84529bbb303827f3 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Tue, 10 Dec 2024 15:13:17 +0100 Subject: [PATCH] Add frontlight off when dark setting --- data | 2 +- src/lib/defaults.hpp | 2 ++ src/lib/webserver.cpp | 4 +++- src/main.cpp | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/data b/data index f0fa58b..25e91b2 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit f0fa58b5ea60f695aeaae9ddd7138cbb3686e96a +Subproject commit 25e91b2086936e7c6ef09e917c6efd371293fd7e diff --git a/src/lib/defaults.hpp b/src/lib/defaults.hpp index 8af3b5b..ada5531 100644 --- a/src/lib/defaults.hpp +++ b/src/lib/defaults.hpp @@ -45,6 +45,8 @@ #define DEFAULT_FL_EFFECT_DELAY 15 #define DEFAULT_LUX_LIGHT_TOGGLE 128 +#define DEFAULT_FL_OFF_WHEN_DARK true + #define DEFAULT_FL_ALWAYS_ON false #define DEFAULT_FL_FLASH_ON_UPDATE false diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index 777fe0b..b901379 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -546,7 +546,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json) "mdnsEnabled", "otaEnabled", "stealFocus", "mcapBigChar", "useSatsSymbol", "useBlkCountdown", "suffixPrice", "disableLeds", "ownDataSource", - "mowMode", "suffixShareDot", + "mowMode", "suffixShareDot", "flOffWhenDark", "flAlwaysOn", "flDisable", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource", "httpAuthEnabled"}; @@ -726,6 +726,8 @@ void onApiSettingsGet(AsyncWebServerRequest *request) root["hasLightLevel"] = hasLightLevel(); root["luxLightToggle"] = preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE); + root["flOffWhenDark"] = preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK); + #else root["hasFrontlight"] = false; root["hasLightLevel"] = false; diff --git a/src/main.cpp b/src/main.cpp index 908f155..b9d2ae7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -51,7 +51,7 @@ extern "C" void app_main() if (hasLightLevel()) { if (preferences.getUInt("luxLightToggle", DEFAULT_LUX_LIGHT_TOGGLE) != 0) { - if (hasLightLevel() && getLightLevel() <= 2) + if (hasLightLevel() && getLightLevel() <= 1 && preferences.getBool("flOffWhenDark", DEFAULT_FL_OFF_WHEN_DARK)) { if (frontlightIsOn()) { frontlightFadeOutAll();