From 385b3570b26f3f8a09d7951adb4341d6c46fd124 Mon Sep 17 00:00:00 2001 From: pille Date: Fri, 24 Apr 2020 23:35:39 +0200 Subject: [PATCH] cleanup code to use descriptive segment options --- wled00/FX.cpp | 6 +++--- wled00/FX_fcn.cpp | 10 +++++----- wled00/set.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/wled00/FX.cpp b/wled00/FX.cpp index a23a33f6..14fee5cb 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -2943,9 +2943,9 @@ uint16_t WS2812FX::mode_exploding_fireworks(void) fill(BLACK); - bool actuallyReverse = SEGMENT.getOption(1); + bool actuallyReverse = SEGMENT.getOption(SEG_OPTION_REVERSED); //have fireworks start in either direction based on intensity - SEGMENT.setOption(1, SEGENV.step); + SEGMENT.setOption(SEG_OPTION_REVERSED, SEGENV.step); Spark* sparks = reinterpret_cast(SEGENV.data); Spark* flare = sparks; //first spark is flare data @@ -3036,7 +3036,7 @@ uint16_t WS2812FX::mode_exploding_fireworks(void) } } - SEGMENT.setOption(1, actuallyReverse); + SEGMENT.setOption(SEG_OPTION_REVERSED, actuallyReverse); return FRAMETIME; } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index c6d8987b..e25ffb0c 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -495,15 +495,15 @@ void WS2812FX::resetSegments() { _segments[0].speed = DEFAULT_SPEED; _segments[0].stop = _length; _segments[0].grouping = 1; - _segments[0].setOption(0, 1); //select - _segments[0].setOption(2, 1); //on + _segments[0].setOption(SEG_OPTION_SELECTED, 1); + _segments[0].setOption(SEG_OPTION_ON, 1); _segments[0].opacity = 255; for (uint16_t i = 1; i < MAX_NUM_SEGMENTS; i++) { _segments[i].colors[0] = color_wheel(i*51); _segments[i].grouping = 1; - _segments[i].setOption(2, 1); //on + _segments[i].setOption(SEG_OPTION_ON, 1); _segments[i].opacity = 255; _segment_runtimes[i].reset(); } @@ -529,7 +529,7 @@ void WS2812FX::setShowCallback(show_callback cb) void WS2812FX::setTransitionMode(bool t) { _segment_index = getMainSegmentId(); - SEGMENT.setOption(7,t); + SEGMENT.setOption(SEG_OPTION_TRANSITIONAL, t); if (!t) return; unsigned long waitMax = millis() + 20; //refresh after 20 ms if transition enabled if (SEGMENT.mode == FX_MODE_STATIC && SEGENV.next_time > waitMax) SEGENV.next_time = waitMax; @@ -812,7 +812,7 @@ bool WS2812FX::segmentsAreIdentical(Segment* a, Segment* b) if (a->speed != b->speed) return false; if (a->intensity != b->intensity) return false; if (a->palette != b->palette) return false; - //if (a->getOption(1) != b->getOption(1)) return false; //reverse + //if (a->getOption(SEG_OPTION_REVERSED) != b->getOption(SEG_OPTION_REVERSED)) return false; return true; } diff --git a/wled00/set.cpp b/wled00/set.cpp index 18ca71e7..d04c0cb2 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -420,7 +420,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req) WS2812FX::Segment& mainseg = strip.getSegment(main); pos = req.indexOf("SV="); //segment selected - if (pos > 0) mainseg.setOption(0, (req.charAt(pos+3) != '0')); + if (pos > 0) mainseg.setOption(SEG_OPTION_SELECTED, (req.charAt(pos+3) != '0')); uint16_t startI = mainseg.start; uint16_t stopI = mainseg.stop;