From f8eece362fe518aa122b23a14c534255086753b4 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Thu, 10 Feb 2022 16:09:16 +0100 Subject: [PATCH] Compile fix. Adjusted function names. --- wled00/FX.h | 26 +++----------------------- wled00/FX_fcn.cpp | 34 +++++++++++++++++++++++++++++++--- wled00/fcn_declare.h | 2 +- wled00/ir.cpp | 4 ++-- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index 2eee69db..34d28c82 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -334,28 +334,8 @@ class WS2812FX { vLength = (vLength + 1) /2; // divide by 2 if mirror, leave at least a single LED return vLength; } - uint8_t differs(Segment& b) { - uint8_t d = 0; - if (start != b.start) d |= SEG_DIFFERS_BOUNDS; - if (stop != b.stop) d |= SEG_DIFFERS_BOUNDS; - if (offset != b.offset) d |= SEG_DIFFERS_GSO; - if (grouping != b.grouping) d |= SEG_DIFFERS_GSO; - if (spacing != b.spacing) d |= SEG_DIFFERS_GSO; - if (opacity != b.opacity) d |= SEG_DIFFERS_BRI; - if (mode != b.mode) d |= SEG_DIFFERS_FX; - if (speed != b.speed) d |= SEG_DIFFERS_FX; - if (intensity != b.intensity) d |= SEG_DIFFERS_FX; - if (palette != b.palette) d |= SEG_DIFFERS_FX; - - if ((options & 0b00101111) != (b.options & 0b00101111)) d |= SEG_DIFFERS_OPT; - for (uint8_t i = 0; i < NUM_COLORS; i++) - { - if (colors[i] != b.colors[i]) d |= SEG_DIFFERS_COL; - } - - return d; - } - uint8_t capabilities(); + uint8_t differs(Segment& b); + uint8_t getLightCapabilities(); } segment; // segment runtime parameters @@ -652,7 +632,7 @@ class WS2812FX { setSegment(uint8_t n, uint16_t start, uint16_t stop, uint8_t grouping = 0, uint8_t spacing = 0, uint16_t offset = UINT16_MAX), restartRuntime(), resetSegments(), - makeAutoSegments(), + makeAutoSegments(bool forceReset = false), fixInvalidSegments(), setPixelColor(uint16_t n, uint32_t c), setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0), diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 391ad01c..f6b73730 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -565,7 +565,29 @@ uint16_t WS2812FX::getLengthPhysical(void) { return len; } -uint8_t WS2812FX::Segment::capabilities() { +uint8_t WS2812FX::Segment::differs(Segment& b) { + uint8_t d = 0; + if (start != b.start) d |= SEG_DIFFERS_BOUNDS; + if (stop != b.stop) d |= SEG_DIFFERS_BOUNDS; + if (offset != b.offset) d |= SEG_DIFFERS_GSO; + if (grouping != b.grouping) d |= SEG_DIFFERS_GSO; + if (spacing != b.spacing) d |= SEG_DIFFERS_GSO; + if (opacity != b.opacity) d |= SEG_DIFFERS_BRI; + if (mode != b.mode) d |= SEG_DIFFERS_FX; + if (speed != b.speed) d |= SEG_DIFFERS_FX; + if (intensity != b.intensity) d |= SEG_DIFFERS_FX; + if (palette != b.palette) d |= SEG_DIFFERS_FX; + + if ((options & 0b00101111) != (b.options & 0b00101111)) d |= SEG_DIFFERS_OPT; + for (uint8_t i = 0; i < NUM_COLORS; i++) + { + if (colors[i] != b.colors[i]) d |= SEG_DIFFERS_COL; + } + + return d; +} + +uint8_t WS2812FX::Segment::getLightCapabilities() { if (!isActive()) return 0; uint8_t capabilities = 0; uint8_t awm = Bus::getAutoWhiteMode(); @@ -689,7 +711,7 @@ void WS2812FX::resetSegments() { _segment_runtimes[0].markForReset(); } -void WS2812FX::makeAutoSegments() { +void WS2812FX::makeAutoSegments(bool forceReset) { if (autoSegments) { //make one segment per bus uint16_t segStarts[MAX_NUM_SEGMENTS] = {0}; uint16_t segStops [MAX_NUM_SEGMENTS] = {0}; @@ -715,9 +737,15 @@ void WS2812FX::makeAutoSegments() { setSegment(i, segStarts[i], segStops[i]); } } else { - //expand the main seg to the entire length, but only if there are no other segments + //expand the main seg to the entire length, but only if there are no other segments, or reset is forced uint8_t mainSeg = getMainSegmentId(); + if (forceReset) { + for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { + setSegment(i, 0, 0); + } + } + if (getActiveSegmentsNum() < 2) { setSegment(mainSeg, 0, _length); } diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index f79c7459..c6590e2c 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -290,12 +290,12 @@ void clearEEPROM(); //wled_math.cpp #ifndef WLED_USE_REAL_MATH + template T atan_t(T x); float cos_t(float phi); float sin_t(float x); float tan_t(float x); float acos_t(float x); float asin_t(float x); - float atan_t(float x); float floor_t(float x); float fmod_t(float num, float denom); #else diff --git a/wled00/ir.cpp b/wled00/ir.cpp index c8f526c9..d1d3e194 100644 --- a/wled00/ir.cpp +++ b/wled00/ir.cpp @@ -213,7 +213,7 @@ void changeColor(uint32_t c, int16_t cct=-1) for (uint8_t i = 0; i < strip.getMaxSegments(); i++) { WS2812FX::Segment& seg = strip.getSegment(i); if (!seg.isActive() || !seg.isSelected()) continue; - byte capabilities = seg.capabilities(); + byte capabilities = seg.getLightCapabilities(); uint32_t mask = 0; bool isRGB = GET_BIT(capabilities, 0); // when RGBW_MODE_AUTO_ACCURATE this is always true bool hasW = GET_BIT(capabilities, 1); @@ -228,7 +228,7 @@ void changeColor(uint32_t c, int16_t cct=-1) } else { byte i = strip.getMainSegmentId(); WS2812FX::Segment& seg = strip.getSegment(i); - byte capabilities = seg.capabilities(); + byte capabilities = seg.getLightCapabilities(); uint32_t mask = 0; bool isRGB = GET_BIT(capabilities, 0); bool hasW = GET_BIT(capabilities, 1);