From 3fec10030921c6963a2f6cdbe362788a044fe2c0 Mon Sep 17 00:00:00 2001 From: Will Tatam Date: Sat, 8 Aug 2026 10:10:59 +0100 Subject: [PATCH] Encapsulate button.cpp's own runtime state as static, not global lastOnTime was referenced only in button.cpp. Converted it to file-local `static`. No behavior change - purely a storage-class change. Verified: esp32dev builds and links cleanly via `pio run -e esp32dev`, no warnings from either changed file. Co-Authored-By: Claude Sonnet 5 --- wled00/button.cpp | 4 ++++ wled00/wled.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wled00/button.cpp b/wled00/button.cpp index 4e0d982038..ef56cea7c6 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -13,6 +13,10 @@ #define WLED_LONG_BRI_STEPS 16 // how much to increase/decrease the brightness with each long press repetition static const char _mqtt_topic_button[] PROGMEM = "%s/button/%d"; // optimize flash usage + +// Runtime state private to this file - previously WLED_GLOBAL, a leftover from +// when all state lived in one big extern block regardless of who used it. +static unsigned long lastOnTime = 0; static bool buttonBriDirection = false; // true: increase brightness, false: decrease brightness void shortPressAction(uint8_t b) diff --git a/wled00/wled.h b/wled00/wled.h index 9bafb49196..777f461b3d 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -611,7 +611,7 @@ WLED_GLOBAL byte briNlT _INIT(0); // current nightlight brig WLED_GLOBAL byte colNlT[] _INIT_N(({ 0, 0, 0, 0 })); // current nightlight color // brightness -WLED_GLOBAL unsigned long lastOnTime _INIT(0); +// lastOnTime is private to button.cpp - see there. WLED_GLOBAL bool offMode _INIT(!turnOnAtBoot); WLED_GLOBAL byte briS _INIT(128); // default brightness WLED_GLOBAL byte bri _INIT(briS); // global brightness (set)