Fix disabled screen skipping

This commit is contained in:
Djuri Baars 2024-09-02 22:44:23 +02:00
parent 478c951ffb
commit a31a42511f
6 changed files with 48 additions and 6 deletions

2
data

@ -1 +1 @@
Subproject commit e21b9895a7c93f62565ffa2cd1d6c085b9b74035 Subproject commit 2c7f7f667ccb10271db072a4b4e6bf8fd4912f2b

View file

@ -15,6 +15,7 @@
#define DEFAULT_USE_BLOCK_COUNTDOWN true #define DEFAULT_USE_BLOCK_COUNTDOWN true
#define DEFAULT_SUFFIX_PRICE false #define DEFAULT_SUFFIX_PRICE false
#define DEFAULT_DISABLE_LEDS false #define DEFAULT_DISABLE_LEDS false
#define DEFAULT_DISABLE_FL false
#define DEFAULT_OWN_DATA_SOURCE true #define DEFAULT_OWN_DATA_SOURCE true
#define DEFAULT_STAGING_SOURCE false #define DEFAULT_STAGING_SOURCE false
#define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD #define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD

View file

@ -13,6 +13,9 @@ bool flInTransition = false;
void frontlightFlash(int flDelayTime) void frontlightFlash(int flDelayTime)
{ {
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
return;
if (frontlightOn) if (frontlightOn)
{ {
frontlightFadeOutAll(flDelayTime, true); frontlightFadeOutAll(flDelayTime, true);
@ -65,6 +68,8 @@ void frontlightFadeInAll(int flDelayTime)
void frontlightFadeInAll(int flDelayTime, bool staggered) void frontlightFadeInAll(int flDelayTime, bool staggered)
{ {
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
return;
if (frontlightIsOn()) if (frontlightIsOn())
return; return;
if (flInTransition) if (flInTransition)
@ -115,6 +120,8 @@ void frontlightFadeOutAll(int flDelayTime)
void frontlightFadeOutAll(int flDelayTime, bool staggered) void frontlightFadeOutAll(int flDelayTime, bool staggered)
{ {
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
return;
if (!frontlightIsOn()) if (!frontlightIsOn())
return; return;
if (flInTransition) if (flInTransition)
@ -179,6 +186,8 @@ bool frontlightIsOn()
void frontlightFadeIn(uint num, int flDelayTime) void frontlightFadeIn(uint num, int flDelayTime)
{ {
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
return;
for (int dutyCycle = 0; dutyCycle <= preferences.getUInt("flMaxBrightness"); dutyCycle += 5) for (int dutyCycle = 0; dutyCycle <= preferences.getUInt("flMaxBrightness"); dutyCycle += 5)
{ {
flArray.setPWM(num, 0, dutyCycle); flArray.setPWM(num, 0, dutyCycle);
@ -188,6 +197,8 @@ void frontlightFadeIn(uint num, int flDelayTime)
void frontlightFadeOut(uint num, int flDelayTime) void frontlightFadeOut(uint num, int flDelayTime)
{ {
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
return;
if (!frontlightIsOn()) if (!frontlightIsOn())
return; return;

View file

@ -282,7 +282,7 @@ void nextScreen() {
newCurrentScreen = screenMappings.front().value; 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)) { while (!preferences.getBool(key.c_str(), true)) {
currentIndex = findScreenIndexByValue(newCurrentScreen); currentIndex = findScreenIndexByValue(newCurrentScreen);
@ -326,8 +326,9 @@ void previousScreen() {
} }
void showSystemStatusScreen() { void showSystemStatusScreen() {
std::array<String, NUM_SCREENS> sysStatusEpdContent = {"", "", "", "", std::array<String, NUM_SCREENS> sysStatusEpdContent;
"", "", ""}; std::fill(sysStatusEpdContent.begin(), sysStatusEpdContent.end(), "");
String ipAddr = WiFi.localIP().toString(); String ipAddr = WiFi.localIP().toString();
String subNet = WiFi.subnetMask().toString(); String subNet = WiFi.subnetMask().toString();

View file

@ -37,6 +37,9 @@ void setupWebserver()
server.on("/api/show/screen", HTTP_GET, onApiShowScreen); server.on("/api/show/screen", HTTP_GET, onApiShowScreen);
server.on("/api/show/text", HTTP_GET, onApiShowText); 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 = AsyncCallbackJsonWebHandler *settingsPatchHandler =
new AsyncCallbackJsonWebHandler("/api/json/settings", onApiSettingsPatch); new AsyncCallbackJsonWebHandler("/api/json/settings", onApiSettingsPatch);
server.addHandler(settingsPatchHandler); server.addHandler(settingsPatchHandler);
@ -373,6 +376,27 @@ void onApiShowScreen(AsyncWebServerRequest *request)
request->send(200); 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) void onApiShowText(AsyncWebServerRequest *request)
{ {
if (request->hasParam("t")) if (request->hasParam("t"))
@ -478,7 +502,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd", String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
"mdnsEnabled", "otaEnabled", "stealFocus", "mdnsEnabled", "otaEnabled", "stealFocus",
"mcapBigChar", "useSatsSymbol", "useBlkCountdown", "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) for (String setting : boolSettings)
{ {
@ -611,6 +635,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
#ifdef HAS_FRONTLIGHT #ifdef HAS_FRONTLIGHT
root["hasFrontlight"] = true; root["hasFrontlight"] = true;
root["flDisable"] = preferences.getBool("flDisable", DEFAULT_DISABLE_FL);
root["flMaxBrightness"] = preferences.getUInt("flMaxBrightness", DEFAULT_FL_MAX_BRIGHTNESS); root["flMaxBrightness"] = preferences.getUInt("flMaxBrightness", DEFAULT_FL_MAX_BRIGHTNESS);
root["flAlwaysOn"] = preferences.getBool("flAlwaysOn", DEFAULT_FL_ALWAYS_ON); root["flAlwaysOn"] = preferences.getBool("flAlwaysOn", DEFAULT_FL_ALWAYS_ON);
root["flEffectDelay"] = preferences.getUInt("flEffectDelay", DEFAULT_FL_EFFECT_DELAY); root["flEffectDelay"] = preferences.getUInt("flEffectDelay", DEFAULT_FL_EFFECT_DELAY);

View file

@ -25,6 +25,10 @@ void onApiStatus(AsyncWebServerRequest *request);
void onApiSystemStatus(AsyncWebServerRequest *request); void onApiSystemStatus(AsyncWebServerRequest *request);
void onApiSetWifiTxPower(AsyncWebServerRequest *request); void onApiSetWifiTxPower(AsyncWebServerRequest *request);
void onApiScreenNext(AsyncWebServerRequest *request);
void onApiScreenPrevious(AsyncWebServerRequest *request);
void onApiShowScreen(AsyncWebServerRequest *request); void onApiShowScreen(AsyncWebServerRequest *request);
void onApiShowText(AsyncWebServerRequest *request); void onApiShowText(AsyncWebServerRequest *request);
void onApiIdentify(AsyncWebServerRequest *request); void onApiIdentify(AsyncWebServerRequest *request);