From b4aa8376deae9d0b66ae9268ba85665de07d43f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Kristan?= Date: Tue, 17 Dec 2024 18:59:53 +0100 Subject: [PATCH] Idle current bugfix (#4402) --- wled00/bus_manager.cpp | 11 ----------- wled00/bus_manager.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/wled00/bus_manager.cpp b/wled00/bus_manager.cpp index 5b031bebb..fa78b4805 100644 --- a/wled00/bus_manager.cpp +++ b/wled00/bus_manager.cpp @@ -155,16 +155,6 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com) DEBUG_PRINTF_P(PSTR("%successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u). mA=%d/%d\n"), _valid?"S":"Uns", nr, bc.count, bc.type, _pins[0], is2Pin(bc.type)?_pins[1]:255, _iType, _milliAmpsPerLed, _milliAmpsMax); } -//fine tune power estimation constants for your setup -//you can set it to 0 if the ESP is powered by USB and the LEDs by external -#ifndef MA_FOR_ESP - #ifdef ESP8266 - #define MA_FOR_ESP 80 //how much mA does the ESP use (Wemos D1 about 80mA) - #else - #define MA_FOR_ESP 120 //how much mA does the ESP use (ESP32 about 120mA) - #endif -#endif - //DISCLAIMER //The following function attemps to calculate the current LED power usage, //and will limit the brightness to stay below a set amperage threshold. @@ -943,7 +933,6 @@ void BusManager::show() { busses[i]->show(); _milliAmpsUsed += busses[i]->getUsedCurrent(); } - if (_milliAmpsUsed) _milliAmpsUsed += MA_FOR_ESP; } void BusManager::setStatusPixel(uint32_t c) { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index ecebc120e..89307af2b 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -363,6 +363,16 @@ struct BusConfig { }; +//fine tune power estimation constants for your setup +//you can set it to 0 if the ESP is powered by USB and the LEDs by external +#ifndef MA_FOR_ESP + #ifdef ESP8266 + #define MA_FOR_ESP 80 //how much mA does the ESP use (Wemos D1 about 80mA) + #else + #define MA_FOR_ESP 120 //how much mA does the ESP use (ESP32 about 120mA) + #endif +#endif + class BusManager { public: BusManager() {}; @@ -370,7 +380,7 @@ class BusManager { //utility to get the approx. memory usage of a given BusConfig static uint32_t memUsage(BusConfig &bc); static uint32_t memUsage(unsigned channels, unsigned count, unsigned buses = 1); - static uint16_t currentMilliamps() { return _milliAmpsUsed; } + static uint16_t currentMilliamps() { return _milliAmpsUsed + MA_FOR_ESP; } static uint16_t ablMilliampsMax() { return _milliAmpsMax; } static int add(BusConfig &bc);