Skip to content

Commit 0bbd6b7

Browse files
committed
Minor optimisation
- disable JSON live - WS error string - button irelevant check
1 parent d11ca2e commit 0bbd6b7

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

wled00/button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void handleButton()
308308
buttonLongPressed[b] = true;
309309
}
310310

311-
} else if (!isButtonPressed(b) && buttonPressedBefore[b]) { //released
311+
} else if (buttonPressedBefore[b]) { //released
312312
long dur = now - buttonPressedTime[b];
313313

314314
// released after rising-edge short press action

wled00/wled.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
3737
#endif
3838
//#define WLED_ENABLE_DMX // uses 3.5kb (use LEDPIN other than 2)
39-
#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
39+
//#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
4040
#ifndef WLED_DISABLE_LOXONE
4141
#define WLED_ENABLE_LOXONE // uses 1.2kb
4242
#endif
@@ -331,7 +331,7 @@ typedef class WiFiOptions {
331331
struct {
332332
uint8_t selectedWiFi : 4; // max 16 SSIDs
333333
uint8_t apChannel : 4;
334-
bool apHide : 1;
334+
uint8_t apHide : 3;
335335
uint8_t apBehavior : 3;
336336
bool noWifiSleep : 1;
337337
bool force802_3g : 1;

wled00/ws.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
9696
//pong message was received (in response to a ping request maybe)
9797
DEBUG_PRINTLN(F("WS pong."));
9898

99+
} else {
100+
DEBUG_PRINTLN(F("WS unknown event."));
99101
}
100102
}
101103

@@ -104,10 +106,11 @@ void sendDataWs(AsyncWebSocketClient * client)
104106
if (!ws.count()) return;
105107

106108
if (!requestJSONBufferLock(12)) {
109+
const char* error = PSTR("{\"error\":3}");
107110
if (client) {
108-
client->text(F("{\"error\":3}")); // ERR_NOBUF
111+
client->text(FPSTR(error)); // ERR_NOBUF
109112
} else {
110-
ws.textAll(F("{\"error\":3}")); // ERR_NOBUF
113+
ws.textAll(FPSTR(error)); // ERR_NOBUF
111114
}
112115
return;
113116
}
@@ -120,6 +123,7 @@ void sendDataWs(AsyncWebSocketClient * client)
120123
size_t len = measureJson(*pDoc);
121124
DEBUG_PRINTF_P(PSTR("JSON buffer size: %u for WS request (%u).\n"), pDoc->memoryUsage(), len);
122125

126+
// the following may no longer be necessary as heap management has been fixed by @willmmiles in AWS
123127
size_t heap1 = ESP.getFreeHeap();
124128
DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());
125129
#ifdef ESP8266

0 commit comments

Comments
 (0)