diff --git a/wled00/FX.h b/wled00/FX.h index bfe0f6bce..cdab23369 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -841,7 +841,6 @@ class WS2812FX { void handle_palette(void); bool - shouldStartBus = false, _useRgbw = false, _skipFirstMode, _triggered; diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 0fbd05d47..183998699 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -62,7 +62,7 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst) } uint8_t pins[] = {2}; - busses->add(supportWhite? TYPE_SK6812_RGBW : TYPE_WS2812_RGB, pins, countPixels); + busses->add(supportWhite? TYPE_SK6812_RGBW : TYPE_WS2812_RGB, pins, 0, countPixels, COL_ORDER_GRB); _segments[0].start = 0; _segments[0].stop = _length; @@ -418,18 +418,6 @@ void WS2812FX::setBrightness(uint8_t b) { { _segments[i].setOption(SEG_OPTION_FREEZE, false); } - #if LEDPIN == LED_BUILTIN - shouldStartBus = true; - #endif - } else { - #if LEDPIN == LED_BUILTIN - if (shouldStartBus) { - shouldStartBus = false; - const uint8_t ty = _useRgbw ? 2 : 1; - //TODO add re-init method for any bus type that uses GPIO2 on ESP8266 here - //bus->Begin((NeoPixelType)ty, _lengthRaw); - } - #endif } if (SEGENV.next_time > millis() + 22 && millis() - _lastShow > MIN_SHOW_DELAY) show();//apply brightness change immediately if no refresh soon } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 9f333e97c..f61143c93 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -22,7 +22,7 @@ class Bus { virtual void setPixelColor(uint16_t pix, uint32_t c) {}; - virtual void setBrightness(uint8_t b) { _bri = b; }; + virtual void setBrightness(uint8_t b) {}; virtual uint32_t getPixelColor(uint16_t pix) { return 0; }; @@ -96,6 +96,9 @@ class BusDigital : public Bus { } void setBrightness(uint8_t b) { + //Fix for turning off onboard LED breaking bus + if (_bri == 0 && b > 0 && (_pins[0] == LED_BUILTIN || _pins[1] == LED_BUILTIN)) PolyBus::begin(_busPtr, _iType); + _bri = b; PolyBus::setBrightness(_busPtr, _iType, b); } @@ -207,6 +210,10 @@ class BusPwm : public Bus { } } + void setBrightness(uint8_t b) { + _bri = b; + } + void cleanup() { deallocatePins(); } diff --git a/wled00/bus_wrapper.h b/wled00/bus_wrapper.h index 1393dd71b..d9f0244f9 100644 --- a/wled00/bus_wrapper.h +++ b/wled00/bus_wrapper.h @@ -266,7 +266,6 @@ class PolyBus { }; static void* create(uint8_t busType, uint8_t* pins, uint16_t len) { void* busPtr = nullptr; - //delete busPtr; //TODO this needs type handling or destructor isn't called switch (busType) { case I_NONE: break; #ifdef ESP8266 @@ -658,7 +657,7 @@ class PolyBus { } }; static uint32_t getPixelColor(void* busPtr, uint8_t busType, uint16_t pix, uint8_t co) { - RgbwColor col; + RgbwColor col(0,0,0,0); switch (busType) { case I_NONE: break; #ifdef ESP8266 diff --git a/wled00/json.cpp b/wled00/json.cpp index fe79eacb2..ded888956 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -587,7 +587,7 @@ void serveJson(AsyncWebServerRequest* request) bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient) { - AsyncWebSocketClient * wsc; + AsyncWebSocketClient * wsc = nullptr; if (!request) { //not HTTP, use Websockets #ifdef WLED_ENABLE_WEBSOCKETS wsc = ws.client(wsClient); diff --git a/wled00/mqtt.cpp b/wled00/mqtt.cpp index d54f7997f..9aa9bf966 100644 --- a/wled00/mqtt.cpp +++ b/wled00/mqtt.cpp @@ -110,7 +110,7 @@ void publishMqtt() char s[10]; char subuf[38]; - sprintf(s, "%ld", bri); + sprintf(s, "%u", bri); strcpy(subuf, mqttDeviceTopic); strcat(subuf, "/g"); mqtt->publish(subuf, 0, true, s);