Dynamic bus config
- provide LED types from BusManager for settings Credit: @netmindz for the idea.
This commit is contained in:
		| @@ -48,38 +48,25 @@ uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, byte | |||||||
| #define W(c) (byte((c) >> 24)) | #define W(c) (byte((c) >> 24)) | ||||||
|  |  | ||||||
|  |  | ||||||
| void ColorOrderMap::add(uint16_t start, uint16_t len, uint8_t colorOrder) { | bool ColorOrderMap::add(uint16_t start, uint16_t len, uint8_t colorOrder) { | ||||||
|   if (_count >= WLED_MAX_COLOR_ORDER_MAPPINGS) { |   if (count() >= WLED_MAX_COLOR_ORDER_MAPPINGS || len == 0 || (colorOrder & 0x0F) > COL_ORDER_MAX) return false; // upper nibble contains W swap information | ||||||
|     return; |   _mappings.push_back({start,len,colorOrder}); | ||||||
|   } |   return true; | ||||||
|   if (len == 0) { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   // upper nibble contains W swap information |  | ||||||
|   if ((colorOrder & 0x0F) > COL_ORDER_MAX) { |  | ||||||
|     return; |  | ||||||
|   } |  | ||||||
|   _mappings[_count].start = start; |  | ||||||
|   _mappings[_count].len = len; |  | ||||||
|   _mappings[_count].colorOrder = colorOrder; |  | ||||||
|   _count++; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaultColorOrder) const { | uint8_t IRAM_ATTR ColorOrderMap::getPixelColorOrder(uint16_t pix, uint8_t defaultColorOrder) const { | ||||||
|   if (_count > 0) { |   // upper nibble contains W swap information | ||||||
|     // upper nibble contains W swap information |   // when ColorOrderMap's upper nibble contains value >0 then swap information is used from it, otherwise global swap is used | ||||||
|     // when ColorOrderMap's upper nibble contains value >0 then swap information is used from it, otherwise global swap is used |   for (unsigned i = 0; i < count(); i++) { | ||||||
|     for (unsigned i = 0; i < _count; i++) { |     if (pix >= _mappings[i].start && pix < (_mappings[i].start + _mappings[i].len)) { | ||||||
|       if (pix >= _mappings[i].start && pix < (_mappings[i].start + _mappings[i].len)) { |       return _mappings[i].colorOrder | ((_mappings[i].colorOrder >> 4) ? 0 : (defaultColorOrder & 0xF0)); | ||||||
|         return _mappings[i].colorOrder | ((_mappings[i].colorOrder >> 4) ? 0 : (defaultColorOrder & 0xF0)); |  | ||||||
|       } |  | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   return defaultColorOrder; |   return defaultColorOrder; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| uint32_t Bus::autoWhiteCalc(uint32_t c) { | uint32_t Bus::autoWhiteCalc(uint32_t c) const { | ||||||
|   unsigned aWM = _autoWhiteMode; |   unsigned aWM = _autoWhiteMode; | ||||||
|   if (_gAWM < AW_GLOBAL_DISABLED) aWM = _gAWM; |   if (_gAWM < AW_GLOBAL_DISABLED) aWM = _gAWM; | ||||||
|   if (aWM == RGBW_MODE_MANUAL_ONLY) return c; |   if (aWM == RGBW_MODE_MANUAL_ONLY) return c; | ||||||
| @@ -95,7 +82,7 @@ uint32_t Bus::autoWhiteCalc(uint32_t c) { | |||||||
|   return RGBW32(r, g, b, w); |   return RGBW32(r, g, b, w); | ||||||
| } | } | ||||||
|  |  | ||||||
| uint8_t *Bus::allocData(size_t size) { | uint8_t *Bus::allocateData(size_t size) { | ||||||
|   if (_data) free(_data); // should not happen, but for safety |   if (_data) free(_data); // should not happen, but for safety | ||||||
|   return _data = (uint8_t *)(size>0 ? calloc(size, sizeof(uint8_t)) : nullptr); |   return _data = (uint8_t *)(size>0 ? calloc(size, sizeof(uint8_t)) : nullptr); | ||||||
| } | } | ||||||
| @@ -123,7 +110,7 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com) | |||||||
|   } |   } | ||||||
|   _iType = PolyBus::getI(bc.type, _pins, nr); |   _iType = PolyBus::getI(bc.type, _pins, nr); | ||||||
|   if (_iType == I_NONE) return; |   if (_iType == I_NONE) return; | ||||||
|   if (bc.doubleBuffer && !allocData(bc.count * Bus::getNumberOfChannels(bc.type))) return; |   if (bc.doubleBuffer && !allocateData(bc.count * Bus::getNumberOfChannels(bc.type))) return; | ||||||
|   //_buffering = bc.doubleBuffer; |   //_buffering = bc.doubleBuffer; | ||||||
|   uint16_t lenToCreate = bc.count; |   uint16_t lenToCreate = bc.count; | ||||||
|   if (bc.type == TYPE_WS2812_1CH_X3) lenToCreate = NUM_ICS_WS2812_1CH_3X(bc.count); // only needs a third of "RGB" LEDs for NeoPixelBus |   if (bc.type == TYPE_WS2812_1CH_X3) lenToCreate = NUM_ICS_WS2812_1CH_3X(bc.count); // only needs a third of "RGB" LEDs for NeoPixelBus | ||||||
| @@ -150,7 +137,7 @@ BusDigital::BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com) | |||||||
| //I am NOT to be held liable for burned down garages or houses! | //I am NOT to be held liable for burned down garages or houses! | ||||||
|  |  | ||||||
| // To disable brightness limiter we either set output max current to 0 or single LED current to 0 | // To disable brightness limiter we either set output max current to 0 or single LED current to 0 | ||||||
| uint8_t BusDigital::estimateCurrentAndLimitBri() { | uint8_t BusDigital::estimateCurrentAndLimitBri(void) { | ||||||
|   bool useWackyWS2815PowerModel = false; |   bool useWackyWS2815PowerModel = false; | ||||||
|   byte actualMilliampsPerLed = _milliAmpsPerLed; |   byte actualMilliampsPerLed = _milliAmpsPerLed; | ||||||
|  |  | ||||||
| @@ -202,7 +189,7 @@ uint8_t BusDigital::estimateCurrentAndLimitBri() { | |||||||
|   return newBri; |   return newBri; | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusDigital::show() { | void BusDigital::show(void) { | ||||||
|   _milliAmpsTotal = 0; |   _milliAmpsTotal = 0; | ||||||
|   if (!_valid) return; |   if (!_valid) return; | ||||||
|  |  | ||||||
| @@ -263,7 +250,7 @@ void BusDigital::show() { | |||||||
|   if (newBri < _bri) PolyBus::setBrightness(_busPtr, _iType, _bri); |   if (newBri < _bri) PolyBus::setBrightness(_busPtr, _iType, _bri); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool BusDigital::canShow() { | bool BusDigital::canShow(void) const { | ||||||
|   if (!_valid) return true; |   if (!_valid) return true; | ||||||
|   return PolyBus::canShow(_busPtr, _iType); |   return PolyBus::canShow(_busPtr, _iType); | ||||||
| } | } | ||||||
| @@ -319,7 +306,7 @@ void IRAM_ATTR BusDigital::setPixelColor(uint16_t pix, uint32_t c) { | |||||||
| } | } | ||||||
|  |  | ||||||
| // returns original color if global buffering is enabled, else returns lossly restored color from bus | // returns original color if global buffering is enabled, else returns lossly restored color from bus | ||||||
| uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) { | uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) const { | ||||||
|   if (!_valid) return 0; |   if (!_valid) return 0; | ||||||
|   if (_data) { |   if (_data) { | ||||||
|     size_t offset = pix * getNumberOfChannels(); |     size_t offset = pix * getNumberOfChannels(); | ||||||
| @@ -349,9 +336,9 @@ uint32_t IRAM_ATTR BusDigital::getPixelColor(uint16_t pix) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| uint8_t BusDigital::getPins(uint8_t* pinArray) { | uint8_t BusDigital::getPins(uint8_t* pinArray) const { | ||||||
|   unsigned numPins = IS_2PIN(_type) ? 2 : 1; |   unsigned numPins = IS_2PIN(_type) ? 2 : 1; | ||||||
|   for (unsigned i = 0; i < numPins; i++) pinArray[i] = _pins[i]; |   if (pinArray) for (unsigned i = 0; i < numPins; i++) pinArray[i] = _pins[i]; | ||||||
|   return numPins; |   return numPins; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -361,12 +348,12 @@ void BusDigital::setColorOrder(uint8_t colorOrder) { | |||||||
|   _colorOrder = colorOrder; |   _colorOrder = colorOrder; | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusDigital::reinit() { | void BusDigital::reinit(void) { | ||||||
|   if (!_valid) return; |   if (!_valid) return; | ||||||
|   PolyBus::begin(_busPtr, _iType, _pins); |   PolyBus::begin(_busPtr, _iType, _pins); | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusDigital::cleanup() { | void BusDigital::cleanup(void) { | ||||||
|   DEBUG_PRINTLN(F("Digital Cleanup.")); |   DEBUG_PRINTLN(F("Digital Cleanup.")); | ||||||
|   PolyBus::cleanup(_busPtr, _iType); |   PolyBus::cleanup(_busPtr, _iType); | ||||||
|   _iType = I_NONE; |   _iType = I_NONE; | ||||||
| @@ -477,7 +464,7 @@ void BusPwm::setPixelColor(uint16_t pix, uint32_t c) { | |||||||
| } | } | ||||||
|  |  | ||||||
| //does no index check | //does no index check | ||||||
| uint32_t BusPwm::getPixelColor(uint16_t pix) { | uint32_t BusPwm::getPixelColor(uint16_t pix) const { | ||||||
|   if (!_valid) return 0; |   if (!_valid) return 0; | ||||||
|   // TODO getting the reverse from CCT is involved (a quick approximation when CCT blending is ste to 0 implemented) |   // TODO getting the reverse from CCT is involved (a quick approximation when CCT blending is ste to 0 implemented) | ||||||
|   switch (_type) { |   switch (_type) { | ||||||
| @@ -528,7 +515,7 @@ static const uint16_t cieLUT[256] = { | |||||||
| }; | }; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| void BusPwm::show() { | void BusPwm::show(void) { | ||||||
|   if (!_valid) return; |   if (!_valid) return; | ||||||
|   unsigned numPins = NUM_PWM_PINS(_type); |   unsigned numPins = NUM_PWM_PINS(_type); | ||||||
|   unsigned maxBri = (1<<_depth) - 1; |   unsigned maxBri = (1<<_depth) - 1; | ||||||
| @@ -548,16 +535,14 @@ void BusPwm::show() { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| uint8_t BusPwm::getPins(uint8_t* pinArray) { | uint8_t BusPwm::getPins(uint8_t* pinArray) const { | ||||||
|   if (!_valid) return 0; |   if (!_valid) return 0; | ||||||
|   unsigned numPins = NUM_PWM_PINS(_type); |   unsigned numPins = NUM_PWM_PINS(_type); | ||||||
|   for (unsigned i = 0; i < numPins; i++) { |   if (pinArray) for (unsigned i = 0; i < numPins; i++) pinArray[i] = _pins[i]; | ||||||
|     pinArray[i] = _pins[i]; |  | ||||||
|   } |  | ||||||
|   return numPins; |   return numPins; | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusPwm::deallocatePins() { | void BusPwm::deallocatePins(void) { | ||||||
|   unsigned numPins = NUM_PWM_PINS(_type); |   unsigned numPins = NUM_PWM_PINS(_type); | ||||||
|   for (unsigned i = 0; i < numPins; i++) { |   for (unsigned i = 0; i < numPins; i++) { | ||||||
|     pinManager.deallocatePin(_pins[i], PinOwner::BusPwm); |     pinManager.deallocatePin(_pins[i], PinOwner::BusPwm); | ||||||
| @@ -601,19 +586,19 @@ void BusOnOff::setPixelColor(uint16_t pix, uint32_t c) { | |||||||
|   _data[0] = bool(r|g|b|w) && bool(_bri) ? 0xFF : 0; |   _data[0] = bool(r|g|b|w) && bool(_bri) ? 0xFF : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| uint32_t BusOnOff::getPixelColor(uint16_t pix) { | uint32_t BusOnOff::getPixelColor(uint16_t pix) const { | ||||||
|   if (!_valid) return 0; |   if (!_valid) return 0; | ||||||
|   return RGBW32(_data[0], _data[0], _data[0], _data[0]); |   return RGBW32(_data[0], _data[0], _data[0], _data[0]); | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusOnOff::show() { | void BusOnOff::show(void) { | ||||||
|   if (!_valid) return; |   if (!_valid) return; | ||||||
|   digitalWrite(_pin, _reversed ? !(bool)_data[0] : (bool)_data[0]); |   digitalWrite(_pin, _reversed ? !(bool)_data[0] : (bool)_data[0]); | ||||||
| } | } | ||||||
|  |  | ||||||
| uint8_t BusOnOff::getPins(uint8_t* pinArray) { | uint8_t BusOnOff::getPins(uint8_t* pinArray) const { | ||||||
|   if (!_valid) return 0; |   if (!_valid) return 0; | ||||||
|   pinArray[0] = _pin; |   if (pinArray) pinArray[0] = _pin; | ||||||
|   return 1; |   return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -642,7 +627,7 @@ BusNetwork::BusNetwork(BusConfig &bc) | |||||||
|   } |   } | ||||||
|   _UDPchannels = _rgbw ? 4 : 3; |   _UDPchannels = _rgbw ? 4 : 3; | ||||||
|   _client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]); |   _client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]); | ||||||
|   _valid = (allocData(_len * _UDPchannels) != nullptr); |   _valid = (allocateData(_len * _UDPchannels) != nullptr); | ||||||
|   DEBUG_PRINTF_P(PSTR("%successfully inited virtual strip with type %u and IP %u.%u.%u.%u\n"), _valid?"S":"Uns", bc.type, bc.pins[0], bc.pins[1], bc.pins[2], bc.pins[3]); |   DEBUG_PRINTF_P(PSTR("%successfully inited virtual strip with type %u and IP %u.%u.%u.%u\n"), _valid?"S":"Uns", bc.type, bc.pins[0], bc.pins[1], bc.pins[2], bc.pins[3]); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -657,27 +642,25 @@ void BusNetwork::setPixelColor(uint16_t pix, uint32_t c) { | |||||||
|   if (_rgbw) _data[offset+3] = W(c); |   if (_rgbw) _data[offset+3] = W(c); | ||||||
| } | } | ||||||
|  |  | ||||||
| uint32_t BusNetwork::getPixelColor(uint16_t pix) { | uint32_t BusNetwork::getPixelColor(uint16_t pix) const { | ||||||
|   if (!_valid || pix >= _len) return 0; |   if (!_valid || pix >= _len) return 0; | ||||||
|   unsigned offset = pix * _UDPchannels; |   unsigned offset = pix * _UDPchannels; | ||||||
|   return RGBW32(_data[offset], _data[offset+1], _data[offset+2], (_rgbw ? _data[offset+3] : 0)); |   return RGBW32(_data[offset], _data[offset+1], _data[offset+2], (_rgbw ? _data[offset+3] : 0)); | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusNetwork::show() { | void BusNetwork::show(void) { | ||||||
|   if (!_valid || !canShow()) return; |   if (!_valid || !canShow()) return; | ||||||
|   _broadcastLock = true; |   _broadcastLock = true; | ||||||
|   realtimeBroadcast(_UDPtype, _client, _len, _data, _bri, _rgbw); |   realtimeBroadcast(_UDPtype, _client, _len, _data, _bri, _rgbw); | ||||||
|   _broadcastLock = false; |   _broadcastLock = false; | ||||||
| } | } | ||||||
|  |  | ||||||
| uint8_t BusNetwork::getPins(uint8_t* pinArray) { | uint8_t BusNetwork::getPins(uint8_t* pinArray) const { | ||||||
|   for (unsigned i = 0; i < 4; i++) { |   if (pinArray) for (unsigned i = 0; i < 4; i++) pinArray[i] = _client[i]; | ||||||
|     pinArray[i] = _client[i]; |  | ||||||
|   } |  | ||||||
|   return 4; |   return 4; | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusNetwork::cleanup() { | void BusNetwork::cleanup(void) { | ||||||
|   _type = I_NONE; |   _type = I_NONE; | ||||||
|   _valid = false; |   _valid = false; | ||||||
|   freeData(); |   freeData(); | ||||||
| @@ -724,13 +707,67 @@ int BusManager::add(BusConfig &bc) { | |||||||
|   return numBusses++; |   return numBusses++; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // idea by @netmindz https://github.com/Aircoookie/WLED/pull/4056 | ||||||
|  | String BusManager::getLEDTypesJSONString(void) { | ||||||
|  |   struct LEDType { | ||||||
|  |     uint8_t id; | ||||||
|  |     const char *type; | ||||||
|  |     const char *name; | ||||||
|  |   } types[] = { | ||||||
|  |     {TYPE_WS2812_RGB,      "D",      PSTR("WS281x")}, | ||||||
|  |     {TYPE_SK6812_RGBW,     "D",      PSTR("SK6812/WS2814 RGBW")}, | ||||||
|  |     {TYPE_TM1814,          "D",      PSTR("TM1814")}, | ||||||
|  |     {TYPE_WS2811_400KHZ,   "D",      PSTR("400kHz")}, | ||||||
|  |     {TYPE_TM1829,          "D",      PSTR("TM1829")}, | ||||||
|  |     {TYPE_UCS8903,         "D",      PSTR("UCS8903")}, | ||||||
|  |     {TYPE_APA106,          "D",      PSTR("APA106/PL9823")}, | ||||||
|  |     {TYPE_TM1914,          "D",      PSTR("TM1914")}, | ||||||
|  |     {TYPE_FW1906,          "D",      PSTR("FW1906 GRBCW")}, | ||||||
|  |     {TYPE_UCS8904,         "D",      PSTR("UCS8904 RGBW")}, | ||||||
|  |     {TYPE_WS2805,          "D",      PSTR("WS2805 RGBCW")}, | ||||||
|  |     {TYPE_SM16825,         "D",      PSTR("SM16825 RGBCW")}, | ||||||
|  |     {TYPE_WS2812_1CH_X3,   "D",      PSTR("WS2811 White")}, | ||||||
|  |     //{TYPE_WS2812_2CH_X3,   "D",      PSTR("WS2811 CCT")}, | ||||||
|  |     //{TYPE_WS2812_WWA,      "D",      PSTR("WS2811 WWA")}, | ||||||
|  |     {TYPE_WS2801,          "2P",     PSTR("WS2801")}, | ||||||
|  |     {TYPE_APA102,          "2P",     PSTR("APA102")}, | ||||||
|  |     {TYPE_LPD8806,         "2P",     PSTR("LPD8806")}, | ||||||
|  |     {TYPE_LPD6803,         "2P",     PSTR("LPD6803")}, | ||||||
|  |     {TYPE_P9813,           "2P",     PSTR("PP9813")}, | ||||||
|  |     {TYPE_ONOFF,           "",       PSTR("On/Off")}, | ||||||
|  |     {TYPE_ANALOG_1CH,      "A",      PSTR("PWM White")}, | ||||||
|  |     {TYPE_ANALOG_2CH,      "AA",     PSTR("PWM CCT")}, | ||||||
|  |     {TYPE_ANALOG_3CH,      "AAA",    PSTR("PWM RGB")}, | ||||||
|  |     {TYPE_ANALOG_4CH,      "AAAA",   PSTR("PWM RGBW")}, | ||||||
|  |     {TYPE_ANALOG_5CH,      "AAAAA",  PSTR("PWM RGB+CCT")}, | ||||||
|  |     //{TYPE_ANALOG_6CH,      "AAAAAA", PSTR("PWM RGB+DCCT")}, | ||||||
|  |     {TYPE_NET_DDP_RGB,     "V",      PSTR("DDP RGB (network)")}, | ||||||
|  |     {TYPE_NET_ARTNET_RGB,  "V",      PSTR("Art-Net RGB (network)")}, | ||||||
|  |     {TYPE_NET_DDP_RGBW,    "V",      PSTR("DDP RGBW (network)")}, | ||||||
|  |     {TYPE_NET_ARTNET_RGBW, "V",      PSTR("Art-Net RGBW (network)")} | ||||||
|  |   }; | ||||||
|  |   String json = "["; | ||||||
|  |   for (const auto &type : types) { | ||||||
|  |     String id = String(type.id); | ||||||
|  |     json += "{i:" + id | ||||||
|  |       + F(",w:") + String((int)Bus::hasWhite(type.id)) | ||||||
|  |       + F(",c:") + String((int)Bus::hasCCT(type.id)) | ||||||
|  |       + F(",s:") + String((int)Bus::is16bit(type.id)) | ||||||
|  |       + F(",t:\"") + FPSTR(type.type) | ||||||
|  |       + F("\",n:\"") + FPSTR(type.name) + F("\"},"); | ||||||
|  |   } | ||||||
|  |   json.setCharAt(json.length()-1, ']'); // replace last comma with bracket | ||||||
|  |   return json; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void BusManager::useParallelOutput(void) { | void BusManager::useParallelOutput(void) { | ||||||
|   _parallelOutputs = 8; // hardcoded since we use NPB I2S x8 methods |   _parallelOutputs = 8; // hardcoded since we use NPB I2S x8 methods | ||||||
|   PolyBus::setParallelI2S1Output(); |   PolyBus::setParallelI2S1Output(); | ||||||
| } | } | ||||||
|  |  | ||||||
| //do not call this method from system context (network callback) | //do not call this method from system context (network callback) | ||||||
| void BusManager::removeAll() { | void BusManager::removeAll(void) { | ||||||
|   DEBUG_PRINTLN(F("Removing all.")); |   DEBUG_PRINTLN(F("Removing all.")); | ||||||
|   //prevents crashes due to deleting busses while in use. |   //prevents crashes due to deleting busses while in use. | ||||||
|   while (!canAllShow()) yield(); |   while (!canAllShow()) yield(); | ||||||
| @@ -744,7 +781,7 @@ void BusManager::removeAll() { | |||||||
| // #2478 | // #2478 | ||||||
| // If enabled, RMT idle level is set to HIGH when off | // If enabled, RMT idle level is set to HIGH when off | ||||||
| // to prevent leakage current when using an N-channel MOSFET to toggle LED power | // to prevent leakage current when using an N-channel MOSFET to toggle LED power | ||||||
| void BusManager::esp32RMTInvertIdle() { | void BusManager::esp32RMTInvertIdle(void) { | ||||||
|   bool idle_out; |   bool idle_out; | ||||||
|   unsigned rmt = 0; |   unsigned rmt = 0; | ||||||
|   for (unsigned u = 0; u < numBusses(); u++) { |   for (unsigned u = 0; u < numBusses(); u++) { | ||||||
| @@ -775,7 +812,7 @@ void BusManager::esp32RMTInvertIdle() { | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| void BusManager::on() { | void BusManager::on(void) { | ||||||
|   #ifdef ESP8266 |   #ifdef ESP8266 | ||||||
|   //Fix for turning off onboard LED breaking bus |   //Fix for turning off onboard LED breaking bus | ||||||
|   if (pinManager.getPinOwner(LED_BUILTIN) == PinOwner::BusDigital) { |   if (pinManager.getPinOwner(LED_BUILTIN) == PinOwner::BusDigital) { | ||||||
| @@ -796,7 +833,7 @@ void BusManager::on() { | |||||||
|   #endif |   #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusManager::off() { | void BusManager::off(void) { | ||||||
|   #ifdef ESP8266 |   #ifdef ESP8266 | ||||||
|   // turn off built-in LED if strip is turned off |   // turn off built-in LED if strip is turned off | ||||||
|   // this will break digital bus so will need to be re-initialised on On |   // this will break digital bus so will need to be re-initialised on On | ||||||
| @@ -811,7 +848,7 @@ void BusManager::off() { | |||||||
|   #endif |   #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| void BusManager::show() { | void BusManager::show(void) { | ||||||
|   _milliAmpsUsed = 0; |   _milliAmpsUsed = 0; | ||||||
|   for (unsigned i = 0; i < numBusses; i++) { |   for (unsigned i = 0; i < numBusses; i++) { | ||||||
|     busses[i]->show(); |     busses[i]->show(); | ||||||
| @@ -852,13 +889,13 @@ void BusManager::setSegmentCCT(int16_t cct, bool allowWBCorrection) { | |||||||
| uint32_t BusManager::getPixelColor(uint16_t pix) { | uint32_t BusManager::getPixelColor(uint16_t pix) { | ||||||
|   for (unsigned i = 0; i < numBusses; i++) { |   for (unsigned i = 0; i < numBusses; i++) { | ||||||
|     unsigned bstart = busses[i]->getStart(); |     unsigned bstart = busses[i]->getStart(); | ||||||
|     if (pix < bstart || pix >= bstart + busses[i]->getLength()) continue; |     if (!busses[i]->containsPixel(pix)) continue; | ||||||
|     return busses[i]->getPixelColor(pix - bstart); |     return busses[i]->getPixelColor(pix - bstart); | ||||||
|   } |   } | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool BusManager::canAllShow() { | bool BusManager::canAllShow(void) { | ||||||
|   for (unsigned i = 0; i < numBusses; i++) { |   for (unsigned i = 0; i < numBusses; i++) { | ||||||
|     if (!busses[i]->canShow()) return false; |     if (!busses[i]->canShow()) return false; | ||||||
|   } |   } | ||||||
| @@ -871,7 +908,7 @@ Bus* BusManager::getBus(uint8_t busNr) { | |||||||
| } | } | ||||||
|  |  | ||||||
| //semi-duplicate of strip.getLengthTotal() (though that just returns strip._length, calculated in finalizeInit()) | //semi-duplicate of strip.getLengthTotal() (though that just returns strip._length, calculated in finalizeInit()) | ||||||
| uint16_t BusManager::getTotalLength() { | uint16_t BusManager::getTotalLength(void) { | ||||||
|   unsigned len = 0; |   unsigned len = 0; | ||||||
|   for (unsigned i=0; i<numBusses; i++) len += busses[i]->getLength(); |   for (unsigned i=0; i<numBusses; i++) len += busses[i]->getLength(); | ||||||
|   return len; |   return len; | ||||||
|   | |||||||
| @@ -6,6 +6,8 @@ | |||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "const.h" | #include "const.h" | ||||||
|  | #include <array> | ||||||
|  | #include <vector> | ||||||
|  |  | ||||||
| //colors.cpp | //colors.cpp | ||||||
| uint16_t approximateKelvinFromRGB(uint32_t rgb); | uint16_t approximateKelvinFromRGB(uint32_t rgb); | ||||||
| @@ -73,34 +75,31 @@ struct BusConfig { | |||||||
|  |  | ||||||
|  |  | ||||||
| // Defines an LED Strip and its color ordering. | // Defines an LED Strip and its color ordering. | ||||||
| struct ColorOrderMapEntry { | typedef struct { | ||||||
|   uint16_t start; |   uint16_t start; | ||||||
|   uint16_t len; |   uint16_t len; | ||||||
|   uint8_t colorOrder; |   uint8_t colorOrder; | ||||||
| }; | } ColorOrderMapEntry; | ||||||
|  |  | ||||||
| struct ColorOrderMap { | struct ColorOrderMap { | ||||||
|     void add(uint16_t start, uint16_t len, uint8_t colorOrder); |     bool add(uint16_t start, uint16_t len, uint8_t colorOrder); | ||||||
|  |  | ||||||
|     uint8_t count() const { return _count; } |     inline uint8_t count() const { return _mappings.size(); } | ||||||
|  |  | ||||||
|     void reset() { |     void reset() { | ||||||
|       _count = 0; |       _mappings.clear(); | ||||||
|       memset(_mappings, 0, sizeof(_mappings)); |       _mappings.shrink_to_fit(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const ColorOrderMapEntry* get(uint8_t n) const { |     const ColorOrderMapEntry* get(uint8_t n) const { | ||||||
|       if (n > _count) { |       if (n >= count()) return nullptr; | ||||||
|         return nullptr; |  | ||||||
|       } |  | ||||||
|       return &(_mappings[n]); |       return &(_mappings[n]); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     uint8_t getPixelColorOrder(uint16_t pix, uint8_t defaultColorOrder) const; |     uint8_t getPixelColorOrder(uint16_t pix, uint8_t defaultColorOrder) const; | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
|     uint8_t _count; |     std::vector<ColorOrderMapEntry> _mappings; | ||||||
|     ColorOrderMapEntry _mappings[WLED_MAX_COLOR_ORDER_MAPPINGS]; |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -122,59 +121,61 @@ class Bus { | |||||||
|  |  | ||||||
|     virtual ~Bus() {} //throw the bus under the bus |     virtual ~Bus() {} //throw the bus under the bus | ||||||
|  |  | ||||||
|     virtual void     show() = 0; |     virtual void     show(void) = 0; | ||||||
|     virtual bool     canShow()                   { return true; } |     virtual bool     canShow(void) const                          { return true; } | ||||||
|     virtual void     setStatusPixel(uint32_t c)  {} |     virtual void     setStatusPixel(uint32_t c)                   {} | ||||||
|     virtual void     setPixelColor(uint16_t pix, uint32_t c) = 0; |     virtual void     setPixelColor(uint16_t pix, uint32_t c) = 0; | ||||||
|     virtual uint32_t getPixelColor(uint16_t pix) { return 0; } |     virtual void     setBrightness(uint8_t b)                     { _bri = b; }; | ||||||
|     virtual void     setBrightness(uint8_t b)    { _bri = b; }; |     inline  void     setStart(uint16_t start)                     { _start = start; } | ||||||
|     virtual uint8_t  getPins(uint8_t* pinArray)  { return 0; } |     virtual void     setColorOrder(uint8_t co)                    {} | ||||||
|     virtual uint16_t getLength()                 { return isOk() ? _len : 0; } |     virtual bool     hasRGB(void) const                           { return Bus::hasRGB(_type); } | ||||||
|     virtual void     setColorOrder(uint8_t co)   {} |     virtual bool     hasWhite(void) const                         { return Bus::hasWhite(_type); } | ||||||
|     virtual uint8_t  getColorOrder()             { return COL_ORDER_RGB; } |     virtual bool     hasCCT(void) const                           { return Bus::hasCCT(_type); } | ||||||
|     virtual uint8_t  skippedLeds()               { return 0; } |     virtual bool     is16bit(void) const                          { return Bus::is16bit(_type); } | ||||||
|     virtual uint16_t getFrequency()              { return 0U; } |     virtual uint32_t getPixelColor(uint16_t pix) const            { return 0; } | ||||||
|     virtual uint16_t getLEDCurrent()             { return 0; } |     virtual uint8_t  getPins(uint8_t* pinArray = nullptr) const   { return 0; } | ||||||
|     virtual uint16_t getUsedCurrent()            { return 0; } |     virtual uint16_t getLength(void) const                        { return isOk() ? _len : 0; } | ||||||
|     virtual uint16_t getMaxCurrent()             { return 0; } |     virtual uint8_t  getColorOrder(void) const                    { return COL_ORDER_RGB; } | ||||||
|     virtual uint8_t  getNumberOfChannels()       { return hasWhite(_type) + 3*hasRGB(_type) + hasCCT(_type); } |     virtual uint8_t  skippedLeds(void) const                      { return 0; } | ||||||
|     static inline uint8_t getNumberOfChannels(uint8_t type) { return hasWhite(type) + 3*hasRGB(type) + hasCCT(type); } |     virtual uint16_t getFrequency(void) const                     { return 0U; } | ||||||
|     inline  void     setReversed(bool reversed)  { _reversed = reversed; } |     virtual uint16_t getLEDCurrent(void) const                    { return 0; } | ||||||
|     inline  uint16_t getStart()                  { return _start; } |     virtual uint16_t getUsedCurrent(void) const                   { return 0; } | ||||||
|     inline  void     setStart(uint16_t start)    { _start = start; } |     virtual uint16_t getMaxCurrent(void) const                    { return 0; } | ||||||
|     inline  uint8_t  getType()                   { return _type; } |     virtual uint8_t  getNumberOfChannels(void) const              { return hasWhite(_type) + 3*hasRGB(_type) + hasCCT(_type); } | ||||||
|     inline  bool     isOk()                      { return _valid; } |  | ||||||
|     inline  bool     isReversed()                { return _reversed; } |  | ||||||
|     inline  bool     isOffRefreshRequired()      { return _needsRefresh; } |  | ||||||
|             bool     containsPixel(uint16_t pix) { return pix >= _start && pix < _start+_len; } |  | ||||||
|  |  | ||||||
|     virtual bool hasRGB(void) { return Bus::hasRGB(_type); } |     inline  void     setReversed(bool reversed)                   { _reversed = reversed; } | ||||||
|     static  bool hasRGB(uint8_t type) { |     inline  void     setAutoWhiteMode(uint8_t m)                  { if (m < 5) _autoWhiteMode = m; } | ||||||
|       if ((type >= TYPE_WS2812_1CH && type <= TYPE_WS2812_WWA) || type == TYPE_ANALOG_1CH || type == TYPE_ANALOG_2CH || type == TYPE_ONOFF) return false; |     inline  uint8_t  getAutoWhiteMode(void) const                 { return _autoWhiteMode; } | ||||||
|       return true; |     inline  uint16_t getStart(void) const                         { return _start; } | ||||||
|  |     inline  uint8_t  getType(void) const                          { return _type; } | ||||||
|  |     inline  bool     isOk(void) const                             { return _valid; } | ||||||
|  |     inline  bool     isReversed(void) const                       { return _reversed; } | ||||||
|  |     inline  bool     isOffRefreshRequired(void) const             { return _needsRefresh; } | ||||||
|  |     inline  bool     containsPixel(uint16_t pix) const            { return pix >= _start && pix < _start + _len; } | ||||||
|  |  | ||||||
|  |     static inline uint8_t getNumberOfChannels(uint8_t type)       { return hasWhite(type) + 3*hasRGB(type) + hasCCT(type); } | ||||||
|  |     static constexpr bool hasRGB(uint8_t type) { | ||||||
|  |       return !((type >= TYPE_WS2812_1CH && type <= TYPE_WS2812_WWA) || type == TYPE_ANALOG_1CH || type == TYPE_ANALOG_2CH || type == TYPE_ONOFF); | ||||||
|     } |     } | ||||||
|     virtual bool hasWhite(void) { return Bus::hasWhite(_type); } |     static constexpr bool hasWhite(uint8_t type) { | ||||||
|     static  bool hasWhite(uint8_t type) { |       return  (type >= TYPE_WS2812_1CH && type <= TYPE_WS2812_WWA) || | ||||||
|       if ((type >= TYPE_WS2812_1CH && type <= TYPE_WS2812_WWA) || |               type == TYPE_SK6812_RGBW || type == TYPE_TM1814 || type == TYPE_UCS8904 || | ||||||
|           type == TYPE_SK6812_RGBW || type == TYPE_TM1814 || type == TYPE_UCS8904 || |               type == TYPE_FW1906 || type == TYPE_WS2805 || type == TYPE_SM16825 ||        // digital types with white channel | ||||||
|           type == TYPE_FW1906 || type == TYPE_WS2805 || type == TYPE_SM16825) return true; // digital types with white channel |               (type > TYPE_ONOFF && type <= TYPE_ANALOG_5CH && type != TYPE_ANALOG_3CH) || // analog types with white channel | ||||||
|       if (type > TYPE_ONOFF && type <= TYPE_ANALOG_5CH && type != TYPE_ANALOG_3CH) return true; // analog types with white channel |               type == TYPE_NET_DDP_RGBW || type == TYPE_NET_ARTNET_RGBW;                   // network types with white channel | ||||||
|       if (type == TYPE_NET_DDP_RGBW || type == TYPE_NET_ARTNET_RGBW) return true; // network types with white channel |  | ||||||
|       return false; |  | ||||||
|     } |     } | ||||||
|     virtual bool hasCCT(void) { return Bus::hasCCT(_type); } |     static constexpr bool hasCCT(uint8_t type) { | ||||||
|     static  bool hasCCT(uint8_t type) { |       return  type == TYPE_WS2812_2CH_X3 || type == TYPE_WS2812_WWA || | ||||||
|       if (type == TYPE_WS2812_2CH_X3 || type == TYPE_WS2812_WWA || |               type == TYPE_ANALOG_2CH    || type == TYPE_ANALOG_5CH || | ||||||
|           type == TYPE_ANALOG_2CH    || type == TYPE_ANALOG_5CH || |               type == TYPE_FW1906        || type == TYPE_WS2805     || | ||||||
|           type == TYPE_FW1906        || type == TYPE_WS2805     || |               type == TYPE_SM16825; | ||||||
|           type == TYPE_SM16825) return true; |  | ||||||
|       return false; |  | ||||||
|     } |     } | ||||||
|     static inline int16_t getCCT() { return _cct; } |     static constexpr bool is16bit(uint8_t type)      { return type == TYPE_UCS8903 || type == TYPE_UCS8904 || type == TYPE_SM16825; } | ||||||
|     static void setCCT(int16_t cct) { |     static inline int16_t getCCT(void)               { return _cct; } | ||||||
|       _cct = cct; |     static inline void    setGlobalAWMode(uint8_t m) { if (m < 5) _gAWM = m; else _gAWM = AW_GLOBAL_DISABLED; } | ||||||
|     } |     static inline uint8_t getGlobalAWMode(void)      { return _gAWM; } | ||||||
|     static inline uint8_t getCCTBlend() { return _cctBlend; } |     static void setCCT(int16_t cct)                  { _cct = cct; } | ||||||
|  |     static inline uint8_t getCCTBlend(void)          { return _cctBlend; } | ||||||
|     static void setCCTBlend(uint8_t b) { |     static void setCCTBlend(uint8_t b) { | ||||||
|       if (b > 100) b = 100; |       if (b > 100) b = 100; | ||||||
|       _cctBlend = (b * 127) / 100; |       _cctBlend = (b * 127) / 100; | ||||||
| @@ -203,10 +204,6 @@ class Bus { | |||||||
|       ww = (w * ww) / 255; //brightness scaling |       ww = (w * ww) / 255; //brightness scaling | ||||||
|       cw = (w * cw) / 255; |       cw = (w * cw) / 255; | ||||||
|     } |     } | ||||||
|     inline        void    setAutoWhiteMode(uint8_t m) { if (m < 5) _autoWhiteMode = m; } |  | ||||||
|     inline        uint8_t getAutoWhiteMode()          { return _autoWhiteMode; } |  | ||||||
|     inline static void    setGlobalAWMode(uint8_t m)  { if (m < 5) _gAWM = m; else _gAWM = AW_GLOBAL_DISABLED; } |  | ||||||
|     inline static uint8_t getGlobalAWMode()           { return _gAWM; } |  | ||||||
|  |  | ||||||
|   protected: |   protected: | ||||||
|     uint8_t  _type; |     uint8_t  _type; | ||||||
| @@ -231,8 +228,8 @@ class Bus { | |||||||
|     //  127 - additive CCT blending (CCT 127 => 100% warm, 100% cold) |     //  127 - additive CCT blending (CCT 127 => 100% warm, 100% cold) | ||||||
|     static uint8_t _cctBlend; |     static uint8_t _cctBlend; | ||||||
|  |  | ||||||
|     uint32_t autoWhiteCalc(uint32_t c); |     uint32_t autoWhiteCalc(uint32_t c) const; | ||||||
|     uint8_t *allocData(size_t size = 1); |     uint8_t *allocateData(size_t size = 1); | ||||||
|     void     freeData() { if (_data != nullptr) free(_data); _data = nullptr; } |     void     freeData() { if (_data != nullptr) free(_data); _data = nullptr; } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -242,23 +239,22 @@ class BusDigital : public Bus { | |||||||
|     BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com); |     BusDigital(BusConfig &bc, uint8_t nr, const ColorOrderMap &com); | ||||||
|     ~BusDigital() { cleanup(); } |     ~BusDigital() { cleanup(); } | ||||||
|  |  | ||||||
|     void show() override; |     void show(void) override; | ||||||
|     bool canShow() override; |     bool canShow(void) const override; | ||||||
|     void setBrightness(uint8_t b) override; |     void setBrightness(uint8_t b) override; | ||||||
|     void setStatusPixel(uint32_t c) override; |     void setStatusPixel(uint32_t c) override; | ||||||
|     void setPixelColor(uint16_t pix, uint32_t c) override; |     void setPixelColor(uint16_t pix, uint32_t c) override; | ||||||
|     void setColorOrder(uint8_t colorOrder) override; |     void setColorOrder(uint8_t colorOrder) override; | ||||||
|     uint32_t getPixelColor(uint16_t pix) override; |     uint32_t getPixelColor(uint16_t pix) const override; | ||||||
|     uint8_t  getColorOrder() override  { return _colorOrder; } |     uint8_t  getColorOrder(void) const override  { return _colorOrder; } | ||||||
|     uint8_t  getPins(uint8_t* pinArray) override; |     uint8_t  getPins(uint8_t* pinArray) const override; | ||||||
|     uint8_t  skippedLeds() override    { return _skip; } |     uint8_t  skippedLeds(void) const override    { return _skip; } | ||||||
|     uint16_t getFrequency() override   { return _frequencykHz; } |     uint16_t getFrequency(void) const override   { return _frequencykHz; } | ||||||
|     uint8_t  estimateCurrentAndLimitBri(); |     uint16_t getLEDCurrent(void) const override  { return _milliAmpsPerLed; } | ||||||
|     uint16_t getLEDCurrent() override  { return _milliAmpsPerLed; } |     uint16_t getUsedCurrent(void) const override { return _milliAmpsTotal; } | ||||||
|     uint16_t getUsedCurrent() override { return _milliAmpsTotal; } |     uint16_t getMaxCurrent(void) const override  { return _milliAmpsMax; } | ||||||
|     uint16_t getMaxCurrent() override  { return _milliAmpsMax; } |     void reinit(void); | ||||||
|     void reinit(); |     void cleanup(void); | ||||||
|     void cleanup(); |  | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
|     uint8_t _skip; |     uint8_t _skip; | ||||||
| @@ -273,7 +269,7 @@ class BusDigital : public Bus { | |||||||
|  |  | ||||||
|     static uint16_t _milliAmpsTotal; // is overwitten/recalculated on each show() |     static uint16_t _milliAmpsTotal; // is overwitten/recalculated on each show() | ||||||
|  |  | ||||||
|     inline uint32_t restoreColorLossy(uint32_t c, uint8_t restoreBri) { |     inline uint32_t restoreColorLossy(uint32_t c, uint8_t restoreBri) const { | ||||||
|       if (restoreBri < 255) { |       if (restoreBri < 255) { | ||||||
|         uint8_t* chan = (uint8_t*) &c; |         uint8_t* chan = (uint8_t*) &c; | ||||||
|         for (uint_fast8_t i=0; i<4; i++) { |         for (uint_fast8_t i=0; i<4; i++) { | ||||||
| @@ -283,6 +279,8 @@ class BusDigital : public Bus { | |||||||
|       } |       } | ||||||
|       return c; |       return c; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     uint8_t  estimateCurrentAndLimitBri(void); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -292,11 +290,11 @@ class BusPwm : public Bus { | |||||||
|     ~BusPwm() { cleanup(); } |     ~BusPwm() { cleanup(); } | ||||||
|  |  | ||||||
|     void setPixelColor(uint16_t pix, uint32_t c) override; |     void setPixelColor(uint16_t pix, uint32_t c) override; | ||||||
|     uint32_t getPixelColor(uint16_t pix) override; //does no index check |     uint32_t getPixelColor(uint16_t pix) const override; //does no index check | ||||||
|     uint8_t  getPins(uint8_t* pinArray) override; |     uint8_t  getPins(uint8_t* pinArray) const override; | ||||||
|     uint16_t getFrequency() override { return _frequency; } |     uint16_t getFrequency(void) const override { return _frequency; } | ||||||
|     void show() override; |     void show(void) override; | ||||||
|     void cleanup() { deallocatePins(); } |     void cleanup(void) { deallocatePins(); } | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
|     uint8_t _pins[5]; |     uint8_t _pins[5]; | ||||||
| @@ -307,7 +305,7 @@ class BusPwm : public Bus { | |||||||
|     uint8_t _depth; |     uint8_t _depth; | ||||||
|     uint16_t _frequency; |     uint16_t _frequency; | ||||||
|  |  | ||||||
|     void deallocatePins(); |     void deallocatePins(void); | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -317,10 +315,10 @@ class BusOnOff : public Bus { | |||||||
|     ~BusOnOff() { cleanup(); } |     ~BusOnOff() { cleanup(); } | ||||||
|  |  | ||||||
|     void setPixelColor(uint16_t pix, uint32_t c) override; |     void setPixelColor(uint16_t pix, uint32_t c) override; | ||||||
|     uint32_t getPixelColor(uint16_t pix) override; |     uint32_t getPixelColor(uint16_t pix) const override; | ||||||
|     uint8_t  getPins(uint8_t* pinArray) override; |     uint8_t  getPins(uint8_t* pinArray) const override; | ||||||
|     void show() override; |     void show(void) override; | ||||||
|     void cleanup() { pinManager.deallocatePin(_pin, PinOwner::BusOnOff); } |     void cleanup(void) { pinManager.deallocatePin(_pin, PinOwner::BusOnOff); } | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
|     uint8_t _pin; |     uint8_t _pin; | ||||||
| @@ -333,14 +331,14 @@ class BusNetwork : public Bus { | |||||||
|     BusNetwork(BusConfig &bc); |     BusNetwork(BusConfig &bc); | ||||||
|     ~BusNetwork() { cleanup(); } |     ~BusNetwork() { cleanup(); } | ||||||
|  |  | ||||||
|     bool hasRGB() override   { return true; } |     bool hasRGB(void) const override   { return true; } | ||||||
|     bool hasWhite() override { return _rgbw; } |     bool hasWhite(void) const override { return _rgbw; } | ||||||
|     bool canShow() override  { return !_broadcastLock; } // this should be a return value from UDP routine if it is still sending data out |     bool canShow(void) const override  { return !_broadcastLock; } // this should be a return value from UDP routine if it is still sending data out | ||||||
|     void setPixelColor(uint16_t pix, uint32_t c) override; |     void setPixelColor(uint16_t pix, uint32_t c) override; | ||||||
|     uint32_t getPixelColor(uint16_t pix) override; |     uint32_t getPixelColor(uint16_t pix) const override; | ||||||
|     uint8_t  getPins(uint8_t* pinArray) override; |     uint8_t  getPins(uint8_t* pinArray) const override; | ||||||
|     void show() override; |     void show(void) override; | ||||||
|     void cleanup(); |     void cleanup(void); | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
|     IPAddress _client; |     IPAddress _client; | ||||||
| @@ -365,31 +363,31 @@ class BusManager { | |||||||
|     static void useParallelOutput(void); // workaround for inaccessible PolyBus |     static void useParallelOutput(void); // workaround for inaccessible PolyBus | ||||||
|  |  | ||||||
|     //do not call this method from system context (network callback) |     //do not call this method from system context (network callback) | ||||||
|     static void removeAll(); |     static void removeAll(void); | ||||||
|  |  | ||||||
|     static void on(void); |     static void on(void); | ||||||
|     static void off(void); |     static void off(void); | ||||||
|  |  | ||||||
|     static void show(); |     static void show(void); | ||||||
|     static bool canAllShow(); |     static bool canAllShow(void); | ||||||
|     static void setStatusPixel(uint32_t c); |     static void setStatusPixel(uint32_t c); | ||||||
|     static void setPixelColor(uint16_t pix, uint32_t c); |     static void setPixelColor(uint16_t pix, uint32_t c); | ||||||
|     static void setBrightness(uint8_t b); |     static void setBrightness(uint8_t b); | ||||||
|     // for setSegmentCCT(), cct can only be in [-1,255] range; allowWBCorrection will convert it to K |     // for setSegmentCCT(), cct can only be in [-1,255] range; allowWBCorrection will convert it to K | ||||||
|     // WARNING: setSegmentCCT() is a misleading name!!! much better would be setGlobalCCT() or just setCCT() |     // WARNING: setSegmentCCT() is a misleading name!!! much better would be setGlobalCCT() or just setCCT() | ||||||
|     static void setSegmentCCT(int16_t cct, bool allowWBCorrection = false); |     static void setSegmentCCT(int16_t cct, bool allowWBCorrection = false); | ||||||
|     static void setMilliampsMax(uint16_t max) { _milliAmpsMax = max;} |     static inline void setMilliampsMax(uint16_t max) { _milliAmpsMax = max;} | ||||||
|     static uint32_t getPixelColor(uint16_t pix); |     static uint32_t getPixelColor(uint16_t pix); | ||||||
|     static inline int16_t getSegmentCCT() { return Bus::getCCT(); } |     static inline int16_t getSegmentCCT(void) { return Bus::getCCT(); } | ||||||
|  |  | ||||||
|     static Bus* getBus(uint8_t busNr); |     static Bus* getBus(uint8_t busNr); | ||||||
|  |  | ||||||
|     //semi-duplicate of strip.getLengthTotal() (though that just returns strip._length, calculated in finalizeInit()) |     //semi-duplicate of strip.getLengthTotal() (though that just returns strip._length, calculated in finalizeInit()) | ||||||
|     static uint16_t getTotalLength(); |     static uint16_t getTotalLength(void); | ||||||
|     static uint8_t getNumBusses() { return numBusses; } |     static inline uint8_t getNumBusses(void) { return numBusses; } | ||||||
|  |     static String getLEDTypesJSONString(void); | ||||||
|  |  | ||||||
|     static void                 updateColorOrderMap(const ColorOrderMap &com) { memcpy(&colorOrderMap, &com, sizeof(ColorOrderMap)); } |     static inline ColorOrderMap& getColorOrderMap(void) { return colorOrderMap; } | ||||||
|     static const ColorOrderMap& getColorOrderMap() { return colorOrderMap; } |  | ||||||
|  |  | ||||||
|   private: |   private: | ||||||
|     static uint8_t numBusses; |     static uint8_t numBusses; | ||||||
| @@ -400,9 +398,9 @@ class BusManager { | |||||||
|     static uint8_t _parallelOutputs; |     static uint8_t _parallelOutputs; | ||||||
|  |  | ||||||
|     #ifdef ESP32_DATA_IDLE_HIGH |     #ifdef ESP32_DATA_IDLE_HIGH | ||||||
|     static void    esp32RMTInvertIdle(); |     static void    esp32RMTInvertIdle(void); | ||||||
|     #endif |     #endif | ||||||
|     static uint8_t getNumVirtualBusses() { |     static uint8_t getNumVirtualBusses(void) { | ||||||
|       int j = 0; |       int j = 0; | ||||||
|       for (int i=0; i<numBusses; i++) if (busses[i]->getType() >= TYPE_NET_DDP_RGB && busses[i]->getType() < 96) j++; |       for (int i=0; i<numBusses; i++) if (busses[i]->getType() >= TYPE_NET_DDP_RGB && busses[i]->getType() < 96) j++; | ||||||
|       return j; |       return j; | ||||||
|   | |||||||
| @@ -244,17 +244,12 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { | |||||||
|   // read color order map configuration |   // read color order map configuration | ||||||
|   JsonArray hw_com = hw[F("com")]; |   JsonArray hw_com = hw[F("com")]; | ||||||
|   if (!hw_com.isNull()) { |   if (!hw_com.isNull()) { | ||||||
|     ColorOrderMap com = {}; |  | ||||||
|     unsigned s = 0; |  | ||||||
|     for (JsonObject entry : hw_com) { |     for (JsonObject entry : hw_com) { | ||||||
|       if (s > WLED_MAX_COLOR_ORDER_MAPPINGS) break; |  | ||||||
|       uint16_t start = entry["start"] | 0; |       uint16_t start = entry["start"] | 0; | ||||||
|       uint16_t len = entry["len"] | 0; |       uint16_t len = entry["len"] | 0; | ||||||
|       uint8_t colorOrder = (int)entry[F("order")]; |       uint8_t colorOrder = (int)entry[F("order")]; | ||||||
|       com.add(start, len, colorOrder); |       if (!BusManager::getColorOrderMap().add(start, len, colorOrder)) break; | ||||||
|       s++; |  | ||||||
|     } |     } | ||||||
|     BusManager::updateColorOrderMap(com); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // read multiple button configuration |   // read multiple button configuration | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ | |||||||
| 	<script> | 	<script> | ||||||
| 		var d=document,laprev=55,maxB=1,maxD=1,maxA=1,maxV=0,maxM=4000,maxPB=4096,maxL=1333,maxCO=10,maxLbquot=0; //maximum bytes for LED allocation: 4kB for 8266, 32kB for 32 | 		var d=document,laprev=55,maxB=1,maxD=1,maxA=1,maxV=0,maxM=4000,maxPB=4096,maxL=1333,maxCO=10,maxLbquot=0; //maximum bytes for LED allocation: 4kB for 8266, 32kB for 32 | ||||||
| 		var oMaxB=1; | 		var oMaxB=1; | ||||||
|  | 		d.ledTypes = []; // filled from GetV() | ||||||
| 		d.um_p = []; | 		d.um_p = []; | ||||||
| 		d.rsvd = []; | 		d.rsvd = []; | ||||||
| 		d.ro_gpio = []; | 		d.ro_gpio = []; | ||||||
| @@ -18,14 +19,15 @@ | |||||||
| 		function gId(n){return d.getElementById(n);} | 		function gId(n){return d.getElementById(n);} | ||||||
| 		function off(n){d.getElementsByName(n)[0].value = -1;} | 		function off(n){d.getElementsByName(n)[0].value = -1;} | ||||||
| 		// these functions correspond to C macros found in const.h | 		// these functions correspond to C macros found in const.h | ||||||
| 		function isPWM(t) { return t > 40 && t < 46; }                      // is PWM type | 		function gT(t)     { for (let type of d.ledTypes) if (t == type.i) return type; } // getType from available ledTypes | ||||||
| 		function isAna(t) { return t == 40 || isPWM(t); }                   // is analog type | 		function isPWM(t)  { return gT(t).t.charAt(0) === "A"; }    // is PWM type | ||||||
| 		function isDig(t) { return (t > 15 && t < 40) || isD2P(t); }        // is digital type | 		function isAna(t)  { return gT(t).t === "" || isPWM(t); }   // is analog type | ||||||
| 		function isD2P(t) { return t > 47 && t < 64; }                      // is digital 2 pin type | 		function isDig(t)  { return gT(t).t === "D" || isD2P(t); }  // is digital type | ||||||
| 		function is16b(t) { return t == 26 || t == 29 || t == 34; }         // is digital 16 bit type | 		function isD2P(t)  { return gT(t).t === "2P"; }             // is digital 2 pin type | ||||||
| 		function isVir(t) { return t >= 80 && t < 96; }                     // is virtual type | 		function isVir(t)  { return gT(t).t === "V"; }              // is virtual type | ||||||
| 		function hasW(t)  { return (t >= 18 && t <= 21) || (t >= 28 && t <= 32) || t == 34 || (t >= 44 && t <= 45) || (t >= 88 && t <= 89); } | 		function hasW(t)   { return gT(t).w == 1; }                 // has white channel | ||||||
| 		function hasCCT(t) { return t == 20 || t == 21 || t == 42 || t == 45 || t == 28 || t == 32 || t == 34; } | 		function hasCCT(t) { return gT(t).c == 1; }                 // is white CCT enabled | ||||||
|  | 		function is16b(t)  { return gT(t).s == 1; }                 // is digital 16 bit type | ||||||
| 		// https://www.educative.io/edpresso/how-to-dynamically-load-a-js-file-in-javascript | 		// https://www.educative.io/edpresso/how-to-dynamically-load-a-js-file-in-javascript | ||||||
| 		function loadJS(FILE_URL, async = true) { | 		function loadJS(FILE_URL, async = true) { | ||||||
| 			let scE = d.createElement("script"); | 			let scE = d.createElement("script"); | ||||||
| @@ -224,6 +226,35 @@ | |||||||
| 			let sLC = 0, sPC = 0, sDI = 0, maxLC = 0; | 			let sLC = 0, sPC = 0, sDI = 0, maxLC = 0; | ||||||
| 			const ablEN = d.Sf.ABL.checked; | 			const ablEN = d.Sf.ABL.checked; | ||||||
| 			maxB = oMaxB; // TODO make sure we start with all possible buses | 			maxB = oMaxB; // TODO make sure we start with all possible buses | ||||||
|  | 			let setPinConfig = (n,t) => { | ||||||
|  | 				let p0d = "GPIO:"; | ||||||
|  | 				let p1d = ""; | ||||||
|  | 				switch (gT(t).t.charAt(0)) { | ||||||
|  | 					case '2': | ||||||
|  | 						p1d = "Clk "+p0d; | ||||||
|  | 					case 'D': | ||||||
|  | 						p0d = "Data "+p0d; | ||||||
|  | 						break; | ||||||
|  | 					case 'A': | ||||||
|  | 						if (gT(t).t.length > 1) p0d = "GPIOs:"; | ||||||
|  | 						break; | ||||||
|  | 					case 'V': | ||||||
|  | 						p0d = "IP address:"; | ||||||
|  | 						break; | ||||||
|  | 				} | ||||||
|  | 				gId("p0d"+n).innerHTML = p0d; | ||||||
|  | 				gId("p1d"+n).innerHTML = p1d; | ||||||
|  | 				// secondary pins show/hide (type string length is equivalent to number of pins used; except for virtual and on/off) | ||||||
|  | 				let pins = gT(t).t.length + 3*isVir(t); // fixes virtual pins to 4 | ||||||
|  | 				if (pins == 0) pins = 1;                  // fixes on/off pin | ||||||
|  | 				for (let p=1; p<5; p++) { | ||||||
|  | 					var LK = d.Sf["L"+p+n]; | ||||||
|  | 					if (!LK) continue; | ||||||
|  | 					LK.style.display = (p < pins) ? "inline" : "none"; | ||||||
|  | 					LK.required = (p < pins); | ||||||
|  | 					if (p >= pins) LK.value=""; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			// enable/disable LED fields | 			// enable/disable LED fields | ||||||
| 			let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]"); | 			let LTs = d.Sf.querySelectorAll("#mLC select[name^=LT]"); | ||||||
| @@ -232,49 +263,29 @@ | |||||||
| 				// is the field a LED type? | 				// is the field a LED type? | ||||||
| 				var n = s.name.substring(2); | 				var n = s.name.substring(2); | ||||||
| 				var t = parseInt(s.value); | 				var t = parseInt(s.value); | ||||||
| 				gId("p0d"+n).innerHTML = isVir(t) ? "IP address:" : isD2P(t) ? "Data GPIO:" : (t > 41) ? "GPIOs:" : "GPIO:"; |  | ||||||
| 				gId("p1d"+n).innerHTML = isD2P(t) ? "Clk GPIO:" : ""; |  | ||||||
| 				gId("abl"+n).style.display = (!ablEN || isVir(t) || isAna(t)) ? "none" : "inline"; |  | ||||||
| 				//var LK = d.getElementsByName("L1"+n)[0]; // clock pin |  | ||||||
|  |  | ||||||
| 				memu += getMem(t, n); // calc memory | 				memu += getMem(t, n); // calc memory | ||||||
|  | 				setPinConfig(n,t); | ||||||
| 				// enumerate pins | 				gId("abl"+n).style.display = (!ablEN || isVir(t) || isAna(t)) ? "none" : "inline"; | ||||||
| 				for (p=1; p<5; p++) { |  | ||||||
| 					var LK = d.Sf["L"+p+n]; // secondary pins |  | ||||||
| 					if (!LK) continue; |  | ||||||
| 					if ((isVir(t) && p<4) || (isD2P(t) && p==1) || (isPWM(t) && (p+40 < t))) // TYPE_xxxx values from const.h |  | ||||||
| 					{ |  | ||||||
| 						// display pin field |  | ||||||
| 						LK.style.display = "inline"; |  | ||||||
| 						LK.required = true; |  | ||||||
| 					} else { |  | ||||||
| 						// hide pin field |  | ||||||
| 						LK.style.display = "none"; |  | ||||||
| 						LK.required = false; |  | ||||||
| 						LK.value=""; |  | ||||||
| 					} |  | ||||||
| 				} |  | ||||||
| 				if (change) { | 				if (change) { | ||||||
| 					gId("rf"+n).checked = (gId("rf"+n).checked || t == 31); // LEDs require data in off state | 					gId("rf"+n).checked = (gId("rf"+n).checked || t == 31); // LEDs require data in off state (mandatory for TM1814) | ||||||
| 					if (isAna(t)) d.Sf["LC"+n].value = 1; // for sanity change analog count just to 1 LED | 					if (isAna(t)) d.Sf["LC"+n].value = 1;                   // for sanity change analog count just to 1 LED | ||||||
| 					d.Sf["LA"+n].min = (isVir(t) || isAna(t)) ? 0 : 1; | 					d.Sf["LA"+n].min = (isVir(t) || isAna(t)) ? 0 : 1; | ||||||
| 					d.Sf["MA"+n].min = (isVir(t) || isAna(t)) ? 0 : 250; | 					d.Sf["MA"+n].min = (isVir(t) || isAna(t)) ? 0 : 250; | ||||||
| 				} | 				} | ||||||
| 				gId("rf"+n).onclick = (t == 31) ? (()=>{return false}) : (()=>{});  // prevent change for TM1814 | 				gId("rf"+n).onclick = (t == 31) ? (()=>{return false}) : (()=>{});          // prevent change for TM1814 | ||||||
| 				gRGBW |= hasW(t); // RGBW checkbox, TYPE_xxxx values from const.h | 				gRGBW |= hasW(t);                                                           // RGBW checkbox | ||||||
| 				gId("co"+n).style.display = (isVir(t) || isAna(t)) ? "none":"inline";  // hide color order for PWM | 				gId("co"+n).style.display = (isVir(t) || isAna(t)) ? "none":"inline";       // hide color order for PWM | ||||||
| 				gId("dig"+n+"w").style.display = (isDig(t) && hasW(t)) ? "inline":"none"; // show swap channels dropdown | 				gId("dig"+n+"w").style.display = (isDig(t) && hasW(t)) ? "inline":"none";   // show swap channels dropdown | ||||||
| 				gId("dig"+n+"w").querySelector("[data-opt=CCT]").disabled = !hasCCT(t);   // disable WW/CW swapping	 | 				gId("dig"+n+"w").querySelector("[data-opt=CCT]").disabled = !hasCCT(t);     // disable WW/CW swapping	 | ||||||
| 				if (!(isDig(t) && hasW(t))) d.Sf["WO"+n].value = 0; // reset swapping | 				if (!(isDig(t) && hasW(t))) d.Sf["WO"+n].value = 0;                         // reset swapping | ||||||
| 				gId("dig"+n+"c").style.display = (isAna(t)) ? "none":"inline";  // hide count for analog | 				gId("dig"+n+"c").style.display = (isAna(t)) ? "none":"inline";              // hide count for analog | ||||||
| 				gId("dig"+n+"r").style.display = (isVir(t)) ? "none":"inline";  // hide reversed for virtual | 				gId("dig"+n+"r").style.display = (isVir(t)) ? "none":"inline";              // hide reversed for virtual | ||||||
| 				gId("dig"+n+"s").style.display = (isVir(t) || isAna(t)) ? "none":"inline";  // hide skip 1st for virtual & analog | 				gId("dig"+n+"s").style.display = (isVir(t) || isAna(t)) ? "none":"inline";  // hide skip 1st for virtual & analog | ||||||
| 				gId("dig"+n+"f").style.display = (isDig(t)) ? "inline":"none";  // hide refresh | 				gId("dig"+n+"f").style.display = (isDig(t)) ? "inline":"none";              // hide refresh | ||||||
| 				gId("dig"+n+"a").style.display = (hasW(t)) ? "inline":"none";   // auto calculate white | 				gId("dig"+n+"a").style.display = (hasW(t)) ? "inline":"none";               // auto calculate white | ||||||
| 				gId("dig"+n+"l").style.display = (isD2P(t) || isPWM(t)) ? "inline":"none";  // bus clock speed / PWM speed (relative) (not On/Off) | 				gId("dig"+n+"l").style.display = (isD2P(t) || isPWM(t)) ? "inline":"none";  // bus clock speed / PWM speed (relative) (not On/Off) | ||||||
| 				gId("rev"+n).innerHTML = isAna(t) ? "Inverted output":"Reversed (rotated 180°)";  // change reverse text for analog | 				gId("rev"+n).innerHTML = isAna(t) ? "Inverted output":"Reversed";           // change reverse text for analog else (rotated 180°) | ||||||
| 				//gId("psd"+n).innerHTML = isAna(t) ? "Index:":"Start:";    // change analog start description | 				//gId("psd"+n).innerHTML = isAna(t) ? "Index:":"Start:";                      // change analog start description | ||||||
| 			}); | 			}); | ||||||
| 			// display global white channel overrides | 			// display global white channel overrides | ||||||
| 			gId("wc").style.display = (gRGBW) ? 'inline':'none'; | 			gId("wc").style.display = (gRGBW) ? 'inline':'none'; | ||||||
| @@ -408,38 +419,7 @@ | |||||||
| 				var cn = `<div class="iST"> | 				var cn = `<div class="iST"> | ||||||
| <hr class="sml"> | <hr class="sml"> | ||||||
| ${i+1}: | ${i+1}: | ||||||
| <select name="LT${s}" onchange="UI(true)">${i>=maxB && false ? '' : | <select name="LT${s}" onchange="UI(true)"></select><br> | ||||||
| '<option value="22" data-type="D">WS281x</option>\ |  | ||||||
| <option value="30" data-type="D">SK6812/WS2814 RGBW</option>\ |  | ||||||
| <option value="31" data-type="D">TM1814</option>\ |  | ||||||
| <option value="24" data-type="D">400kHz</option>\ |  | ||||||
| <option value="25" data-type="D">TM1829</option>\ |  | ||||||
| <option value="26" data-type="D">UCS8903</option>\ |  | ||||||
| <option value="27" data-type="D">APA106/PL9823</option>\ |  | ||||||
| <option value="33" data-type="D">TM1914</option>\ |  | ||||||
| <option value="28" data-type="D">FW1906 GRBCW</option>\ |  | ||||||
| <option value="29" data-type="D">UCS8904 RGBW</option>\ |  | ||||||
| <option value="32" data-type="D">WS2805 RGBCW</option>\ |  | ||||||
| <option value="34" data-type="D">SM16825 RGBCW</option>\ |  | ||||||
| <option value="50" data-type="2P">WS2801</option>\ |  | ||||||
| <option value="51" data-type="2P">APA102</option>\ |  | ||||||
| <option value="52" data-type="2P">LPD8806</option>\ |  | ||||||
| <option value="54" data-type="2P">LPD6803</option>\ |  | ||||||
| <option value="53" data-type="2P">P9813</option>\ |  | ||||||
| <option value="19" data-type="D">WS2811 White</option>\ |  | ||||||
| <option value="40">On/Off</option>\ |  | ||||||
| <option value="41" data-type="A">PWM White</option>\ |  | ||||||
| <option value="42" data-type="AA">PWM CCT</option>\ |  | ||||||
| <option value="43" data-type="AAA">PWM RGB</option>\ |  | ||||||
| <option value="44" data-type="AAAA">PWM RGBW</option>\ |  | ||||||
| <option value="45" data-type="AAAAA">PWM RGB+CCT</option>\ |  | ||||||
| <!--option value="46" data-type="AAAAAA">PWM RGB+DCCT</option-->'} |  | ||||||
| <option value="80" data-type="V">DDP RGB (network)</option> |  | ||||||
| <!--option value="81" data-type="V">E1.31 RGB (network)</option--> |  | ||||||
| <option value="82" data-type="V">Art-Net RGB (network)</option> |  | ||||||
| <option value="88" data-type="V">DDP RGBW (network)</option> |  | ||||||
| <option value="89" data-type="V">Art-Net RGBW (network)</option> |  | ||||||
| </select><br> |  | ||||||
| <div id="abl${s}"> | <div id="abl${s}"> | ||||||
| mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();"> | mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();"> | ||||||
| <option value="55" selected>55mA (typ. 5V WS281x)</option> | <option value="55" selected>55mA (typ. 5V WS281x)</option> | ||||||
| @@ -478,6 +458,21 @@ mA/LED: <select name="LAsel${s}" onchange="enLA(this,'${s}');UI();"> | |||||||
| <div id="dig${s}a" style="display:inline"><br>Auto-calculate white channel from RGB:<br><select name="AW${s}"><option value=0>None</option><option value=1>Brighter</option><option value=2>Accurate</option><option value=3>Dual</option><option value=4>Max</option></select> </div> | <div id="dig${s}a" style="display:inline"><br>Auto-calculate white channel from RGB:<br><select name="AW${s}"><option value=0>None</option><option value=1>Brighter</option><option value=2>Accurate</option><option value=3>Dual</option><option value=4>Max</option></select> </div> | ||||||
| </div>`; | </div>`; | ||||||
| 				f.insertAdjacentHTML("beforeend", cn); | 				f.insertAdjacentHTML("beforeend", cn); | ||||||
|  | 				// fill led types (credit @netmindz) | ||||||
|  | 				d.Sf.querySelectorAll("#mLC select[name^=LT]").forEach((sel,n)=>{ | ||||||
|  | 					if (sel.length == 0) { // ignore already updated | ||||||
|  | 						for (let type of d.ledTypes) { | ||||||
|  | 							let opt = d.createElement("option"); | ||||||
|  | 							opt.value = type.i; | ||||||
|  | 							opt.text = type.n; | ||||||
|  | 							if (type.t != undefined && type.t != "") { | ||||||
|  | 								opt.setAttribute('data-type', type.t); | ||||||
|  | 							} | ||||||
|  | 							sel.appendChild(opt);			 | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 				}); | ||||||
|  | 				// disable inappropriate LED types | ||||||
| 				let sel = d.getElementsByName("LT"+s)[0] | 				let sel = d.getElementsByName("LT"+s)[0] | ||||||
| 				if (i >= maxB || digitalB >= maxD) disable(sel,'option[data-type="D"]'); | 				if (i >= maxB || digitalB >= maxD) disable(sel,'option[data-type="D"]'); | ||||||
| 				if (i >= maxB || twopinB >= 1)     disable(sel,'option[data-type="2P"]'); | 				if (i >= maxB || twopinB >= 1)     disable(sel,'option[data-type="2P"]'); | ||||||
| @@ -810,7 +805,7 @@ Swap: <select id="xw${s}" name="XW${s}"> | |||||||
| 			Use per-output limiter: <input type="checkbox" name="PPL" onchange="UI()"><br> | 			Use per-output limiter: <input type="checkbox" name="PPL" onchange="UI()"><br> | ||||||
| 			<div id="ppldis" style="display:none;"> | 			<div id="ppldis" style="display:none;"> | ||||||
| 				<i>Make sure you enter correct values in each LED output.<br> | 				<i>Make sure you enter correct values in each LED output.<br> | ||||||
| 				If using multiple outputs with only one PSU, distribute its power proportionally amongst ouputs.</i><br> | 				If using multiple outputs with only one PSU, distribute its power proportionally amongst outputs.</i><br> | ||||||
| 			</div> | 			</div> | ||||||
| 			<div id="ampwarning" class="warn" style="display: none;"> | 			<div id="ampwarning" class="warn" style="display: none;"> | ||||||
| 				⚠ Your power supply provides high current.<br> | 				⚠ Your power supply provides high current.<br> | ||||||
|   | |||||||
| @@ -215,7 +215,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) | |||||||
|     } |     } | ||||||
|     //doInitBusses = busesChanged; // we will do that below to ensure all input data is processed |     //doInitBusses = busesChanged; // we will do that below to ensure all input data is processed | ||||||
|  |  | ||||||
|     ColorOrderMap com = {}; |  | ||||||
|     for (int s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) { |     for (int s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) { | ||||||
|       int offset = s < 10 ? 48 : 55; |       int offset = s < 10 ? 48 : 55; | ||||||
|       char xs[4] = "XS"; xs[2] = offset+s; xs[3] = 0; //start LED |       char xs[4] = "XS"; xs[2] = offset+s; xs[3] = 0; //start LED | ||||||
| @@ -227,10 +226,9 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) | |||||||
|         length = request->arg(xc).toInt(); |         length = request->arg(xc).toInt(); | ||||||
|         colorOrder = request->arg(xo).toInt() & 0x0F; |         colorOrder = request->arg(xo).toInt() & 0x0F; | ||||||
|         colorOrder |= (request->arg(xw).toInt() & 0x0F) << 4; // add W swap information |         colorOrder |= (request->arg(xw).toInt() & 0x0F) << 4; // add W swap information | ||||||
|         com.add(start, length, colorOrder); |         if (!BusManager::getColorOrderMap().add(start, length, colorOrder)) break; | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|     BusManager::updateColorOrderMap(com); |  | ||||||
|  |  | ||||||
|     // update other pins |     // update other pins | ||||||
|     #ifndef WLED_DISABLE_INFRARED |     #ifndef WLED_DISABLE_INFRARED | ||||||
|   | |||||||
| @@ -349,6 +349,8 @@ void getSettingsJS(byte subPage, char* dest) | |||||||
|  |  | ||||||
|     appendGPIOinfo(); |     appendGPIOinfo(); | ||||||
|  |  | ||||||
|  |     oappend(SET_F("d.ledTypes=")); oappend(BusManager::getLEDTypesJSONString().c_str()); oappend(";"); | ||||||
|  |  | ||||||
|     // set limits |     // set limits | ||||||
|     oappend(SET_F("bLimits(")); |     oappend(SET_F("bLimits(")); | ||||||
|     oappend(itoa(WLED_MAX_BUSSES,nS,10));  oappend(","); |     oappend(itoa(WLED_MAX_BUSSES,nS,10));  oappend(","); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Blaz Kristan
					Blaz Kristan