Skip to content

Commit a31a425

Browse files
committed
Fix disabled screen skipping
1 parent 478c951 commit a31a425

File tree

6 files changed

+48
-6
lines changed

6 files changed

+48
-6
lines changed

data

Submodule data updated from e21b989 to 2c7f7f6

src/lib/defaults.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define DEFAULT_USE_BLOCK_COUNTDOWN true
1616
#define DEFAULT_SUFFIX_PRICE false
1717
#define DEFAULT_DISABLE_LEDS false
18+
#define DEFAULT_DISABLE_FL false
1819
#define DEFAULT_OWN_DATA_SOURCE true
1920
#define DEFAULT_STAGING_SOURCE false
2021
#define DEFAULT_V2_SOURCE_CURRENCY CURRENCY_USD

src/lib/led_handler.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ bool flInTransition = false;
1313

1414
void frontlightFlash(int flDelayTime)
1515
{
16+
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
17+
return;
18+
1619
if (frontlightOn)
1720
{
1821
frontlightFadeOutAll(flDelayTime, true);
@@ -65,6 +68,8 @@ void frontlightFadeInAll(int flDelayTime)
6568

6669
void frontlightFadeInAll(int flDelayTime, bool staggered)
6770
{
71+
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
72+
return;
6873
if (frontlightIsOn())
6974
return;
7075
if (flInTransition)
@@ -115,6 +120,8 @@ void frontlightFadeOutAll(int flDelayTime)
115120

116121
void frontlightFadeOutAll(int flDelayTime, bool staggered)
117122
{
123+
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
124+
return;
118125
if (!frontlightIsOn())
119126
return;
120127
if (flInTransition)
@@ -179,6 +186,8 @@ bool frontlightIsOn()
179186

180187
void frontlightFadeIn(uint num, int flDelayTime)
181188
{
189+
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
190+
return;
182191
for (int dutyCycle = 0; dutyCycle <= preferences.getUInt("flMaxBrightness"); dutyCycle += 5)
183192
{
184193
flArray.setPWM(num, 0, dutyCycle);
@@ -188,6 +197,8 @@ void frontlightFadeIn(uint num, int flDelayTime)
188197

189198
void frontlightFadeOut(uint num, int flDelayTime)
190199
{
200+
if (preferences.getBool("flDisable", DEFAULT_DISABLE_FL))
201+
return;
191202
if (!frontlightIsOn())
192203
return;
193204

src/lib/screen_handler.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void nextScreen() {
282282
newCurrentScreen = screenMappings.front().value;
283283
}
284284

285-
String key = "screen" + String(screenMappings[currentIndex - 1].value) + "Visible";
285+
String key = "screen" + String(newCurrentScreen) + "Visible";
286286

287287
while (!preferences.getBool(key.c_str(), true)) {
288288
currentIndex = findScreenIndexByValue(newCurrentScreen);
@@ -294,7 +294,7 @@ void nextScreen() {
294294

295295
key = "screen" + String(newCurrentScreen) + "Visible";
296296
}
297-
297+
298298
setCurrentScreen(newCurrentScreen);
299299
}
300300

@@ -326,8 +326,9 @@ void previousScreen() {
326326
}
327327

328328
void showSystemStatusScreen() {
329-
std::array<String, NUM_SCREENS> sysStatusEpdContent = {"", "", "", "",
330-
"", "", ""};
329+
std::array<String, NUM_SCREENS> sysStatusEpdContent;
330+
std::fill(sysStatusEpdContent.begin(), sysStatusEpdContent.end(), "");
331+
331332

332333
String ipAddr = WiFi.localIP().toString();
333334
String subNet = WiFi.subnetMask().toString();

src/lib/webserver.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ void setupWebserver()
3737
server.on("/api/show/screen", HTTP_GET, onApiShowScreen);
3838
server.on("/api/show/text", HTTP_GET, onApiShowText);
3939

40+
server.on("/api/screen/next", HTTP_GET, onApiScreenNext);
41+
server.on("/api/screen/previous", HTTP_GET, onApiScreenPrevious);
42+
4043
AsyncCallbackJsonWebHandler *settingsPatchHandler =
4144
new AsyncCallbackJsonWebHandler("/api/json/settings", onApiSettingsPatch);
4245
server.addHandler(settingsPatchHandler);
@@ -373,6 +376,27 @@ void onApiShowScreen(AsyncWebServerRequest *request)
373376
request->send(200);
374377
}
375378

379+
/**
380+
* @Api
381+
* @Path("/api/screen/next")
382+
*/
383+
void onApiScreenNext(AsyncWebServerRequest *request)
384+
{
385+
nextScreen();
386+
request->send(200);
387+
}
388+
389+
/**
390+
* @Api
391+
* @Path("/api/screen/previous")
392+
*/
393+
void onApiScreenPrevious(AsyncWebServerRequest *request)
394+
{
395+
previousScreen();
396+
397+
request->send(200);
398+
}
399+
376400
void onApiShowText(AsyncWebServerRequest *request)
377401
{
378402
if (request->hasParam("t"))
@@ -478,7 +502,7 @@ void onApiSettingsPatch(AsyncWebServerRequest *request, JsonVariant &json)
478502
String boolSettings[] = {"fetchEurPrice", "ledTestOnPower", "ledFlashOnUpd",
479503
"mdnsEnabled", "otaEnabled", "stealFocus",
480504
"mcapBigChar", "useSatsSymbol", "useBlkCountdown",
481-
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource"};
505+
"suffixPrice", "disableLeds", "ownDataSource", "flAlwaysOn", "flDisable", "flFlashOnUpd", "mempoolSecure", "useNostr", "bitaxeEnabled", "nostrZapNotify", "stagingSource"};
482506

483507
for (String setting : boolSettings)
484508
{
@@ -611,6 +635,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
611635

612636
#ifdef HAS_FRONTLIGHT
613637
root["hasFrontlight"] = true;
638+
root["flDisable"] = preferences.getBool("flDisable", DEFAULT_DISABLE_FL);
614639
root["flMaxBrightness"] = preferences.getUInt("flMaxBrightness", DEFAULT_FL_MAX_BRIGHTNESS);
615640
root["flAlwaysOn"] = preferences.getBool("flAlwaysOn", DEFAULT_FL_ALWAYS_ON);
616641
root["flEffectDelay"] = preferences.getUInt("flEffectDelay", DEFAULT_FL_EFFECT_DELAY);

src/lib/webserver.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ void onApiStatus(AsyncWebServerRequest *request);
2525
void onApiSystemStatus(AsyncWebServerRequest *request);
2626
void onApiSetWifiTxPower(AsyncWebServerRequest *request);
2727

28+
29+
void onApiScreenNext(AsyncWebServerRequest *request);
30+
void onApiScreenPrevious(AsyncWebServerRequest *request);
31+
2832
void onApiShowScreen(AsyncWebServerRequest *request);
2933
void onApiShowText(AsyncWebServerRequest *request);
3034
void onApiIdentify(AsyncWebServerRequest *request);

0 commit comments

Comments
 (0)