From 1ed817932b91118087c15fdcf1b1d13dd15f22bc Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 30 Jul 2023 21:42:05 +0200 Subject: [PATCH] esp-now remote: reduce number of exported functions too many global variables and functions ... this makes stuff 'static' that can remain at file scope --- wled00/remote.cpp | 20 ++++++++++---------- wled00/wled.cpp | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wled00/remote.cpp b/wled00/remote.cpp index c3ae5ecb..0a833d6e 100644 --- a/wled00/remote.cpp +++ b/wled00/remote.cpp @@ -44,21 +44,21 @@ static int brightnessBeforeNightMode = NIGHT_MODE_DEACTIVATED; static message_structure incoming; // Pulled from the IR Remote logic but reduced to 10 steps with a constant of 3 -const byte brightnessSteps[] = { +static const byte brightnessSteps[] = { 6, 9, 14, 22, 33, 50, 75, 113, 170, 255 }; -const size_t numBrightnessSteps = sizeof(brightnessSteps) / sizeof(uint8_t); +static const size_t numBrightnessSteps = sizeof(brightnessSteps) / sizeof(uint8_t); -bool nightModeActive() { +static bool nightModeActive() { return brightnessBeforeNightMode != NIGHT_MODE_DEACTIVATED; } -void activateNightMode() { +static void activateNightMode() { brightnessBeforeNightMode = bri; bri = NIGHT_MODE_BRIGHTNESS; } -bool resetNightMode() { +static bool resetNightMode() { if (!nightModeActive()) { return false; } @@ -68,7 +68,7 @@ bool resetNightMode() { } // increment `bri` to the next `brightnessSteps` value -void brightnessUp() { +static void brightnessUp() { if (nightModeActive()) { return; } // dumb incremental search is efficient enough for so few items for (uint8_t index = 0; index < numBrightnessSteps; ++index) { @@ -80,7 +80,7 @@ void brightnessUp() { } // decrement `bri` to the next `brightnessSteps` value -void brightnessDown() { +static void brightnessDown() { if (nightModeActive()) { return; } // dumb incremental search is efficient enough for so few items for (int index = numBrightnessSteps - 1; index >= 0; --index) { @@ -91,7 +91,7 @@ void brightnessDown() { } } -void setOn() { +static void setOn() { if (resetNightMode()) { stateUpdated(CALL_MODE_BUTTON); } @@ -100,7 +100,7 @@ void setOn() { } } -void setOff() { +static void setOff() { if (resetNightMode()) { stateUpdated(CALL_MODE_BUTTON); } @@ -109,7 +109,7 @@ void setOff() { } } -void presetWithFallback(uint8_t presetID, uint8_t effectID, uint8_t paletteID) { +static void presetWithFallback(uint8_t presetID, uint8_t effectID, uint8_t paletteID) { applyPresetWithFallback(presetID, CALL_MODE_BUTTON_PRESET, effectID, paletteID); } diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 3a0cf467..1c1ee976 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -54,7 +54,9 @@ void WLED::loop() handleIR(); // 2nd call to function needed for ESP32 to return valid results -- should be good for ESP8266, too #endif handleConnection(); + #ifndef WLED_DISABLE_ESPNOW handleRemote(); + #endif handleSerial(); handleImprovWifiScan(); handleNotifications();