mirror of
https://github.com/wled/WLED.git
synced 2025-04-23 22:37:18 +00:00
Cherry pick fixes
This commit is contained in:
parent
8654c2e4da
commit
22eee967c2
@ -543,7 +543,7 @@ typedef struct Segment {
|
||||
static void handleRandomPalette();
|
||||
inline static const CRGBPalette16 &getCurrentPalette() { return Segment::_currentPalette; }
|
||||
|
||||
void setGeometry(uint16_t i1, uint16_t i2, uint8_t grp=1, uint8_t spc=0, uint16_t ofs=UINT16_MAX, uint16_t i1Y=0, uint16_t i2Y=1);
|
||||
void setGeometry(uint16_t i1, uint16_t i2, uint8_t grp=1, uint8_t spc=0, uint16_t ofs=UINT16_MAX, uint16_t i1Y=0, uint16_t i2Y=1, uint8_t m12 = 0);
|
||||
Segment &setColor(uint8_t slot, uint32_t c);
|
||||
Segment &setCCT(uint16_t k);
|
||||
Segment &setOpacity(uint8_t o);
|
||||
@ -596,7 +596,6 @@ typedef struct Segment {
|
||||
[[gnu::hot]] uint32_t getPixelColor(int i) const;
|
||||
// 1D support functions (some implement 2D as well)
|
||||
void blur(uint8_t, bool smear = false);
|
||||
void clear();
|
||||
void fill(uint32_t c);
|
||||
void fade_out(uint8_t r);
|
||||
void fadeToBlackBy(uint8_t fadeBy);
|
||||
|
@ -280,7 +280,7 @@ void Segment::startTransition(uint16_t dur) {
|
||||
_t->_cctT = cct;
|
||||
#ifndef WLED_DISABLE_MODE_BLEND
|
||||
if (modeBlending) {
|
||||
swapSegenv(_t->_segT); // copy runtime data to temporary
|
||||
swapSegenv(_t->_segT);
|
||||
_t->_modeT = mode;
|
||||
_t->_segT._dataLenT = 0;
|
||||
_t->_segT._dataT = nullptr;
|
||||
@ -291,19 +291,13 @@ void Segment::startTransition(uint16_t dur) {
|
||||
memcpy(_t->_segT._dataT, data, _dataLen);
|
||||
_t->_segT._dataLenT = _dataLen;
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<NUM_COLORS; i++) _t->_segT._colorT[i] = colors[i];
|
||||
}
|
||||
DEBUG_PRINTF_P(PSTR("-- pal: %d, bri: %d, C:[%08X,%08X,%08X], m: %d\n"),
|
||||
(int)_t->_palTid,
|
||||
(int)_t->_briT,
|
||||
_t->_segT._colorT[0],
|
||||
_t->_segT._colorT[1],
|
||||
_t->_segT._colorT[2],
|
||||
(int)_t->_modeT);
|
||||
} else
|
||||
# endif
|
||||
} else {
|
||||
for (size_t i=0; i<NUM_COLORS; i++) _t->_segT._colorT[i] = colors[i];
|
||||
}
|
||||
#else
|
||||
for (size_t i=0; i<NUM_COLORS; i++) _t->_colorT[i] = colors[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
void Segment::stopTransition() {
|
||||
@ -462,14 +456,15 @@ void Segment::handleRandomPalette() {
|
||||
}
|
||||
|
||||
// segId is given when called from network callback, changes are queued if that segment is currently in its effect function
|
||||
void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t ofs, uint16_t i1Y, uint16_t i2Y) {
|
||||
void Segment::setGeometry(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t ofs, uint16_t i1Y, uint16_t i2Y, uint8_t m12) {
|
||||
// return if neither bounds nor grouping have changed
|
||||
bool boundsUnchanged = (start == i1 && stop == i2);
|
||||
#ifndef WLED_DISABLE_2D
|
||||
if (Segment::maxHeight>1) boundsUnchanged &= (startY == i1Y && stopY == i2Y); // 2D
|
||||
#endif
|
||||
|
||||
if (stop && (spc > 0 || m12 != map1D2D)) clear();
|
||||
m12 = constrain(m12, 0, 7);
|
||||
if (stop && (spc > 0 || m12 != map1D2D)) fill(BLACK);
|
||||
/*
|
||||
if (boundsUnchanged
|
||||
&& (!grp || (grouping == grp && spacing == spc))
|
||||
@ -1046,26 +1041,6 @@ void Segment::refreshLightCapabilities() {
|
||||
_capabilities = capabilities;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fills segment with black
|
||||
*/
|
||||
void Segment::clear() {
|
||||
if (!isActive()) return; // not active
|
||||
unsigned oldVW = _vWidth;
|
||||
unsigned oldVH = _vHeight;
|
||||
unsigned oldVL = _vLength;
|
||||
unsigned oldSB = _segBri;
|
||||
_vWidth = virtualWidth();
|
||||
_vHeight = virtualHeight();
|
||||
_vLength = virtualLength();
|
||||
_segBri = currentBri();
|
||||
fill(BLACK);
|
||||
_vWidth = oldVW;
|
||||
_vHeight = oldVH;
|
||||
_vLength = oldVL;
|
||||
_segBri = oldSB;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fills segment with color
|
||||
*/
|
||||
|
@ -121,7 +121,7 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
|
||||
if (stop > start && of > len -1) of = len -1;
|
||||
|
||||
// update segment (delete if necessary)
|
||||
seg.setGeometry(start, stop, grp, spc, of, startY, stopY); // strip needs to be suspended for this to work without issues
|
||||
seg.setGeometry(start, stop, grp, spc, of, startY, stopY, map1D2D); // strip needs to be suspended for this to work without issues
|
||||
|
||||
if (newSeg) seg.refreshLightCapabilities(); // fix for #3403
|
||||
|
||||
@ -396,10 +396,10 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
||||
if (!segVar.isNull()) {
|
||||
// we may be called during strip.service() so we must not modify segments while effects are executing
|
||||
strip.suspend();
|
||||
const unsigned long start = millis();
|
||||
while (strip.isServicing() && millis() - start < strip.getFrameTime()) yield(); // wait until frame is over
|
||||
const unsigned long waitUntil = millis() + strip.getFrameTime();
|
||||
while (strip.isServicing() && millis() < waitUntil) delay(1); // wait until frame is over
|
||||
#ifdef WLED_DEBUG
|
||||
if (millis() - start > 0) DEBUG_PRINTLN(F("JSON: Waited for strip to finish servicing."));
|
||||
if (millis() >= waitUntil) DEBUG_PRINTLN(F("JSON: Waited for strip to finish servicing."));
|
||||
#endif
|
||||
if (segVar.is<JsonObject>()) {
|
||||
int id = segVar["id"] | -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user