Skip to content

Commit

Permalink
Minor optimisation
Browse files Browse the repository at this point in the history
- disable JSON live
- WS error string
- button irelevant check
  • Loading branch information
blazoncek committed Aug 22, 2024
1 parent d11ca2e commit 0bbd6b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion wled00/button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void handleButton()
buttonLongPressed[b] = true;
}

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

// released after rising-edge short press action
Expand Down
4 changes: 2 additions & 2 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
#endif
//#define WLED_ENABLE_DMX // uses 3.5kb (use LEDPIN other than 2)
#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
//#define WLED_ENABLE_JSONLIVE // peek LED output via /json/live (WS binary peek is always enabled)
#ifndef WLED_DISABLE_LOXONE
#define WLED_ENABLE_LOXONE // uses 1.2kb
#endif
Expand Down Expand Up @@ -331,7 +331,7 @@ typedef class WiFiOptions {
struct {
uint8_t selectedWiFi : 4; // max 16 SSIDs
uint8_t apChannel : 4;
bool apHide : 1;
uint8_t apHide : 3;
uint8_t apBehavior : 3;
bool noWifiSleep : 1;
bool force802_3g : 1;
Expand Down
8 changes: 6 additions & 2 deletions wled00/ws.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void wsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventTyp
//pong message was received (in response to a ping request maybe)
DEBUG_PRINTLN(F("WS pong."));

} else {
DEBUG_PRINTLN(F("WS unknown event."));
}
}

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

if (!requestJSONBufferLock(12)) {
const char* error = PSTR("{\"error\":3}");
if (client) {
client->text(F("{\"error\":3}")); // ERR_NOBUF
client->text(FPSTR(error)); // ERR_NOBUF
} else {
ws.textAll(F("{\"error\":3}")); // ERR_NOBUF
ws.textAll(FPSTR(error)); // ERR_NOBUF
}
return;
}
Expand All @@ -120,6 +123,7 @@ void sendDataWs(AsyncWebSocketClient * client)
size_t len = measureJson(*pDoc);
DEBUG_PRINTF_P(PSTR("JSON buffer size: %u for WS request (%u).\n"), pDoc->memoryUsage(), len);

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

0 comments on commit 0bbd6b7

Please sign in to comment.