Fixed canAllShow() and removeAll()
This commit is contained in:
parent
aeb3f2b018
commit
d5025fdbcc
@ -24,6 +24,8 @@
|
|||||||
Modified for WLED
|
Modified for WLED
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "wled.h"
|
||||||
|
|
||||||
#ifndef WS2812FX_h
|
#ifndef WS2812FX_h
|
||||||
#define WS2812FX_h
|
#define WS2812FX_h
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ const uint16_t customMappingSize = sizeof(customMappingTable)/sizeof(uint16_t);
|
|||||||
#define PWM_INDEX 0
|
#define PWM_INDEX 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//do not call this method from system context (network callback)
|
||||||
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
||||||
{
|
{
|
||||||
if (supportWhite == _useRgbw && countPixels == _length && _skipFirstMode == skipFirst) return;
|
if (supportWhite == _useRgbw && countPixels == _length && _skipFirstMode == skipFirst) return;
|
||||||
@ -62,8 +63,11 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t pins[] = {2};
|
uint8_t pins[] = {2};
|
||||||
|
|
||||||
|
while (!busses->canAllShow()) yield();
|
||||||
|
busses->removeAll();
|
||||||
busses->add(supportWhite? TYPE_SK6812_RGBW : TYPE_WS2812_RGB, pins, 0, countPixels, COL_ORDER_GRB);
|
busses->add(supportWhite? TYPE_SK6812_RGBW : TYPE_WS2812_RGB, pins, 0, countPixels, COL_ORDER_GRB);
|
||||||
|
|
||||||
_segments[0].start = 0;
|
_segments[0].start = 0;
|
||||||
_segments[0].stop = _length;
|
_segments[0].stop = _length;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Bus {
|
|||||||
virtual void cleanup() {};
|
virtual void cleanup() {};
|
||||||
|
|
||||||
virtual ~Bus() { //throw the bus under the bus
|
virtual ~Bus() { //throw the bus under the bus
|
||||||
cleanup();
|
//Serial.println("Destructor!");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getStart() {
|
uint16_t getStart() {
|
||||||
@ -85,7 +85,7 @@ class BusDigital : public Bus {
|
|||||||
_busPtr = PolyBus::create(_iType, _pins, _len);
|
_busPtr = PolyBus::create(_iType, _pins, _len);
|
||||||
_valid = (_busPtr != nullptr);
|
_valid = (_busPtr != nullptr);
|
||||||
_colorOrder = colorOrder;
|
_colorOrder = colorOrder;
|
||||||
Serial.printf("Successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n",nr, len, type, pins[0],pins[1],_iType);
|
//Serial.printf("Successfully inited strip %u (len %u) with type %u and pins %u,%u (itype %u)\n",nr, len, type, pins[0],pins[1],_iType);
|
||||||
};
|
};
|
||||||
|
|
||||||
void show() {
|
void show() {
|
||||||
@ -127,6 +127,7 @@ class BusDigital : public Bus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
|
//Serial.println("Digital Cleanup");
|
||||||
PolyBus::cleanup(_busPtr, _iType);
|
PolyBus::cleanup(_busPtr, _iType);
|
||||||
_iType = I_NONE;
|
_iType = I_NONE;
|
||||||
_valid = false;
|
_valid = false;
|
||||||
@ -135,6 +136,10 @@ class BusDigital : public Bus {
|
|||||||
pinManager.deallocatePin(_pins[1]);
|
pinManager.deallocatePin(_pins[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~BusDigital() {
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t _colorOrder = COL_ORDER_GRB;
|
uint8_t _colorOrder = COL_ORDER_GRB;
|
||||||
uint8_t _pins[2] = {255, 255};
|
uint8_t _pins[2] = {255, 255};
|
||||||
@ -263,6 +268,7 @@ class BusManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void removeAll() {
|
void removeAll() {
|
||||||
|
//Serial.println("Removing all.");
|
||||||
for (uint8_t i = 0; i < numBusses; i++) delete busses[i];
|
for (uint8_t i = 0; i < numBusses; i++) delete busses[i];
|
||||||
numBusses = 0;
|
numBusses = 0;
|
||||||
}
|
}
|
||||||
@ -278,7 +284,7 @@ class BusManager {
|
|||||||
for (uint8_t i = 0; i < numBusses; i++) {
|
for (uint8_t i = 0; i < numBusses; i++) {
|
||||||
Bus* b = busses[i];
|
Bus* b = busses[i];
|
||||||
uint16_t bstart = b->getStart();
|
uint16_t bstart = b->getStart();
|
||||||
if (pix < bstart) continue;
|
if (pix < bstart || pix >= bstart + b->getLength()) continue;
|
||||||
busses[i]->setPixelColor(pix - bstart, c);
|
busses[i]->setPixelColor(pix - bstart, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,7 +307,7 @@ class BusManager {
|
|||||||
|
|
||||||
bool canAllShow() {
|
bool canAllShow() {
|
||||||
for (uint8_t i = 0; i < numBusses; i++) {
|
for (uint8_t i = 0; i < numBusses; i++) {
|
||||||
if (busses[i]->canShow()) return false;
|
if (!busses[i]->canShow()) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#define WLED_MAX_BUSSES 2
|
#define WLED_MAX_BUSSES 2
|
||||||
#else
|
#else
|
||||||
#define WLED_MAX_BUSSES 8
|
#define WLED_MAX_BUSSES 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Usermod IDs
|
//Usermod IDs
|
||||||
@ -175,7 +175,11 @@
|
|||||||
|
|
||||||
// maximum number of LEDs - more than 1500 LEDs (or 500 DMA "LEDPIN 3" driven ones) will cause a low memory condition on ESP8266
|
// maximum number of LEDs - more than 1500 LEDs (or 500 DMA "LEDPIN 3" driven ones) will cause a low memory condition on ESP8266
|
||||||
#ifndef MAX_LEDS
|
#ifndef MAX_LEDS
|
||||||
#define MAX_LEDS 1500
|
#ifdef ESP8266
|
||||||
|
#define MAX_LEDS 1536
|
||||||
|
#else
|
||||||
|
#define MAX_LEDS 8192
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_LEDS_DMA 500
|
#define MAX_LEDS_DMA 500
|
||||||
|
@ -331,9 +331,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (subPage != 6 || !doReboot) serializeConfig(); //do not save if factory reset
|
if (subPage != 6 || !doReboot) serializeConfig(); //do not save if factory reset
|
||||||
if (subPage == 2) {
|
if (subPage == 2) doInitStrip = true;
|
||||||
strip.init(useRGBW,ledCount,skipFirstLed);
|
|
||||||
}
|
|
||||||
if (subPage == 4) alexaInit();
|
if (subPage == 4) alexaInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,10 +195,10 @@ void WLED::loop()
|
|||||||
handleHue();
|
handleHue();
|
||||||
handleBlynk();
|
handleBlynk();
|
||||||
|
|
||||||
/*if (presetToApply) {
|
if (doInitStrip) {
|
||||||
applyPreset(presetToApply);
|
strip.init(useRGBW, ledCount, skipFirstLed);
|
||||||
presetToApply = 0;
|
doInitStrip = false;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
yield();
|
yield();
|
||||||
|
|
||||||
@ -267,13 +267,10 @@ void WLED::setup()
|
|||||||
DEBUG_PRINTLN(ESP.getFreeHeap());
|
DEBUG_PRINTLN(ESP.getFreeHeap());
|
||||||
registerUsermods();
|
registerUsermods();
|
||||||
|
|
||||||
//strip.init(EEPROM.read(372), ledCount, EEPROM.read(2204)); // init LEDs quickly
|
|
||||||
//strip.setBrightness(0);
|
|
||||||
|
|
||||||
//DEBUG_PRINT(F("LEDs inited. heap usage ~"));
|
//DEBUG_PRINT(F("LEDs inited. heap usage ~"));
|
||||||
//DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap());
|
//DEBUG_PRINTLN(heapPreAlloc - ESP.getFreeHeap());
|
||||||
|
|
||||||
|
|
||||||
bool fsinit = false;
|
bool fsinit = false;
|
||||||
DEBUGFS_PRINTLN(F("Mount FS"));
|
DEBUGFS_PRINTLN(F("Mount FS"));
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
@ -528,6 +528,7 @@ WLED_GLOBAL bool e131NewData _INIT(false);
|
|||||||
|
|
||||||
// led fx library object
|
// led fx library object
|
||||||
WLED_GLOBAL WS2812FX strip _INIT(WS2812FX());
|
WLED_GLOBAL WS2812FX strip _INIT(WS2812FX());
|
||||||
|
WLED_GLOBAL bool doInitStrip _INIT(false);
|
||||||
|
|
||||||
// Usermod manager
|
// Usermod manager
|
||||||
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
WLED_GLOBAL UsermodManager usermods _INIT(UsermodManager());
|
||||||
|
@ -254,13 +254,14 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (subPage == 2) {
|
if (subPage == 2) {
|
||||||
#ifdef ESP8266
|
oappend(SET_F("d.Sf.LC.max="));
|
||||||
#if LEDPIN == 3
|
#if defined(ESP8266) && LEDPIN == 3
|
||||||
oappend(SET_F("d.Sf.LC.max=500;"));
|
oappendi(MAX_LEDS_DMA);
|
||||||
#else
|
#else
|
||||||
oappend(SET_F("d.Sf.LC.max=1500;"));
|
oappendi(MAX_LEDS);
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
oappend(";");
|
||||||
|
|
||||||
sappend('v',SET_F("LC"),ledCount);
|
sappend('v',SET_F("LC"),ledCount);
|
||||||
sappend('v',SET_F("MA"),strip.ablMilliampsMax);
|
sappend('v',SET_F("MA"),strip.ablMilliampsMax);
|
||||||
sappend('v',SET_F("LA"),strip.milliampsPerLed);
|
sappend('v',SET_F("LA"),strip.milliampsPerLed);
|
||||||
|
Loading…
Reference in New Issue
Block a user