diff --git a/wled00/FX.h b/wled00/FX.h index cfae0d6ee..1d32471d1 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -647,7 +647,7 @@ class WS2812FX { setTransitionMode(bool t), calcGammaTable(float), trigger(void), - setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0), + setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0, uint16_t offset = UINT16_MAX), resetSegments(), makeAutoSegments(), fixInvalidSegments(), diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 27a5c3bb6..62abc7870 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -49,7 +49,7 @@ //#define DEFAULT_LED_TYPE TYPE_WS2812_RGB #ifndef PIXEL_COUNTS - #define PIXEL_COUNTS 30 + #define PIXEL_COUNTS DEFAULT_LED_COUNT #endif #ifndef DATA_PINS @@ -213,14 +213,14 @@ void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w) if (indexMir >= SEGMENT.stop) indexMir -= len; if (indexMir < customMappingSize) indexMir = customMappingTable[indexMir]; - busses.setPixelColor(indexMir, col, cct); + busses.setPixelColor(indexMir, col); } /* offset/phase */ indexSet += SEGMENT.offset; if (indexSet >= SEGMENT.stop) indexSet -= len; if (indexSet < customMappingSize) indexSet = customMappingTable[indexSet]; - busses.setPixelColor(indexSet, col, cct); + busses.setPixelColor(indexSet, col); } } } else { //live data, etc. @@ -517,7 +517,6 @@ uint32_t WS2812FX::getPixelColor(uint16_t i) if (i < customMappingSize) i = customMappingTable[i]; if (i >= _length) return 0; - // TODO: may need to add IS_REVERSE and IS_MIRROR logic return busses.getPixelColor(i); } @@ -566,12 +565,14 @@ bool WS2812FX::hasCCTBus(void) { return false; } -void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, uint8_t spacing) { +void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, uint8_t spacing, uint16_t offset) { if (n >= MAX_NUM_SEGMENTS) return; Segment& seg = _segments[n]; //return if neither bounds nor grouping have changed - if (seg.start == i1 && seg.stop == i2 && (!grouping || (seg.grouping == grouping && seg.spacing == spacing))) return; + if (seg.start == i1 && seg.stop == i2 + && (!grouping || (seg.grouping == grouping && seg.spacing == spacing)) + && (offset == UINT16_MAX || offset == seg.offset)) return; if (seg.stop) setRange(seg.start, seg.stop -1, 0); //turn old segment range off if (i2 <= i1) //disable segment @@ -601,6 +602,7 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping, seg.grouping = grouping; seg.spacing = spacing; } + if (offset < UINT16_MAX) seg.offset = offset; _segment_runtimes[n].reset(); } diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index a9cb5d139..dd36d724a 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -49,11 +49,10 @@ struct BusConfig { uint8_t skipAmount; bool refreshReq; uint8_t pins[5] = {LEDPIN, 255, 255, 255, 255}; - uint8_t autoWhite; - BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0, uint8_t aw = 0) { + BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0) { refreshReq = (bool) GET_BIT(busType,7); type = busType & 0x7F; // bit 7 may be/is hacked to include refresh info (1=refresh in off state, 0=no refresh) - count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip; autoWhite = aw; + count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip; uint8_t nPins = 1; if (type >= TYPE_NET_DDP_RGB && type < 96) nPins = 4; //virtual network bus. 4 "pins" store IP address else if (type > 47) nPins = 2; @@ -153,7 +152,7 @@ class Bus { class BusDigital : public Bus { public: - BusDigital(BusConfig &bc, uint8_t nr) : Bus(bc.type, bc.start, bc.autoWhite) { + BusDigital(BusConfig &bc, uint8_t nr) : Bus(bc.type, bc.start) { if (!IS_DIGITAL(bc.type) || !bc.count) return; if (!pinManager.allocatePin(bc.pins[0], true, PinOwner::BusDigital)) return; _pins[0] = bc.pins[0]; @@ -211,11 +210,6 @@ class BusDigital : public Bus { PolyBus::setPixelColor(_busPtr, _iType, pix, c, _colorOrder); } - void setPixelColor(uint16_t pix, uint32_t c, uint8_t cct) { - c = colorBalanceFromKelvin(2000+(cct<<5), c); // color correction from CCT - setPixelColor(pix, c); - } - uint32_t getPixelColor(uint16_t pix) { if (reversed) pix = _len - pix -1; else pix += _skip; @@ -274,7 +268,7 @@ class BusDigital : public Bus { class BusPwm : public Bus { public: - BusPwm(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { + BusPwm(BusConfig &bc) : Bus(bc.type, bc.start) { _valid = false; if (!IS_PWM(bc.type)) return; uint8_t numPins = NUM_PWM_PINS(bc.type); @@ -306,37 +300,6 @@ class BusPwm : public Bus { _valid = true; }; - void setPixelColor(uint16_t pix, uint32_t c, uint8_t cct) { - if (pix != 0 || !_valid) return; //only react to first pixel - if (getAutoWhiteMode() != RGBW_MODE_MANUAL_ONLY) c = autoWhiteCalc(c); - c = colorBalanceFromKelvin(2000+(cct<<5), c); // color correction from CCT (w remains unchanged) - uint8_t r = R(c); - uint8_t g = G(c); - uint8_t b = B(c); - uint8_t w = W(c); - - switch (_type) { - case TYPE_ANALOG_1CH: //one channel (white), relies on auto white calculation - _data[0] = w; //max(r, max(g, max(b, w))); - break; - case TYPE_ANALOG_2CH: //warm white + cold white - // perhaps a non-linear adjustment would be in order. need to test - //w = max(r, max(g, max(b, w))); - _data[1] = (w * cct) / 255; - _data[0] = (w * (255-cct)) / 255; - break; - case TYPE_ANALOG_5CH: //RGB + warm white + cold white - // perhaps a non-linear adjustment would be in order. need to test - _data[4] = (w * cct) / 255; - w = (w * (255-cct)) / 255; - case TYPE_ANALOG_4CH: //RGBW - _data[3] = w; - case TYPE_ANALOG_3CH: //standard dumb RGB - _data[0] = r; _data[1] = g; _data[2] = b; - break; - } - } - void setPixelColor(uint16_t pix, uint32_t c) { if (pix != 0 || !_valid) return; //only react to first pixel if (_type != TYPE_ANALOG_3CH) c = autoWhiteCalc(c); @@ -453,7 +416,7 @@ class BusPwm : public Bus { class BusNetwork : public Bus { public: - BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { + BusNetwork(BusConfig &bc) : Bus(bc.type, bc.start) { _valid = false; // switch (bc.type) { // case TYPE_NET_ARTNET_RGB: @@ -619,8 +582,7 @@ class BusManager { Bus* b = busses[i]; uint16_t bstart = b->getStart(); if (pix < bstart || pix >= bstart + b->getLength()) continue; - if (cct<0) busses[i]->setPixelColor(pix - bstart, c); // no white balance - else busses[i]->setPixelColor(pix - bstart, c, cct); // do white balance + busses[i]->setPixelColor(pix - bstart, c); } } diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 033d2429d..bcf592086 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -113,12 +113,11 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { uint16_t start = elm["start"] | 0; if (length==0 || start + length > MAX_LEDS) continue; // zero length or we reached max. number of LEDs, just stop uint8_t ledType = elm["type"] | TYPE_WS2812_RGB; - uint8_t awMode = elm[F("rgbwm")] | rgbwMode; bool reversed = elm["rev"]; bool refresh = elm["ref"] | false; ledType |= refresh << 7; // hack bit 7 to indicate strip requires off refresh s++; - BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst, awMode); + BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst); mem += BusManager::memUsage(bc); if (mem <= MAX_LED_MEMORY && busses.getNumBusses() <= WLED_MAX_BUSSES) busses.add(bc); // finalization will be done in WLED::beginStrip() } diff --git a/wled00/set.cpp b/wled00/set.cpp index df545c484..42fac1168 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -67,7 +67,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) } } - uint8_t colorOrder, type, skip, awMode; + uint8_t colorOrder, type, skip; uint16_t length, start; uint8_t pins[5] = {255, 255, 255, 255, 255}; @@ -109,7 +109,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) // actual finalization is done in WLED::loop() (removing old busses and adding new) if (busConfigs[s] != nullptr) delete busConfigs[s]; - busConfigs[s] = new BusConfig(type, pins, start, length, colorOrder, request->hasArg(cv), skip, awMode); + busConfigs[s] = new BusConfig(type, pins, start, length, colorOrder, request->hasArg(cv), skip); doInitBusses = true; }