cleanup code to use descriptive segment options

pull/870/head
pille 2020-04-24 23:35:39 +02:00
rodzic 77edd12030
commit 385b3570b2
3 zmienionych plików z 9 dodań i 9 usunięć

Wyświetl plik

@ -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<Spark*>(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;
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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;