Replace setOption/getOption
This commit is contained in:
parent
f7652bd2ef
commit
44a4b11d36
@ -75,7 +75,7 @@ int8_t tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec) {
|
|||||||
*/
|
*/
|
||||||
uint16_t mode_static(void) {
|
uint16_t mode_static(void) {
|
||||||
SEGMENT.fill(SEGCOLOR(0));
|
SEGMENT.fill(SEGCOLOR(0));
|
||||||
return /*(SEGMENT.getOption(SEG_OPTION_TRANSITIONAL)) ? FRAMETIME :*/ 350; //update faster if in transition
|
return 350;
|
||||||
}
|
}
|
||||||
static const char _data_FX_MODE_STATIC[] PROGMEM = "Solid";
|
static const char _data_FX_MODE_STATIC[] PROGMEM = "Solid";
|
||||||
|
|
||||||
@ -3986,7 +3986,7 @@ uint16_t mode_flow(void)
|
|||||||
{
|
{
|
||||||
uint8_t colorIndex = (i * 255 / zoneLen) - counter;
|
uint8_t colorIndex = (i * 255 / zoneLen) - counter;
|
||||||
uint16_t led = (z & 0x01) ? i : (zoneLen -1) -i;
|
uint16_t led = (z & 0x01) ? i : (zoneLen -1) -i;
|
||||||
if (SEGMENT.getOption(SEG_OPTION_REVERSED)) led = (zoneLen -1) -led;
|
if (SEGMENT.reverse) led = (zoneLen -1) -led;
|
||||||
SEGMENT.setPixelColor(pos + led, SEGMENT.color_from_palette(colorIndex, false, true, 255));
|
SEGMENT.setPixelColor(pos + led, SEGMENT.color_from_palette(colorIndex, false, true, 255));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4927,7 +4927,7 @@ uint16_t mode_2Dgameoflife(void) { // Written by Ewoud Wijma, inspired by https:
|
|||||||
SEGENV.aux1 = SEGENV.aux0;
|
SEGENV.aux1 = SEGENV.aux0;
|
||||||
SEGENV.aux0 = crc;
|
SEGENV.aux0 = crc;
|
||||||
|
|
||||||
return (SEGMENT.getOption(SEG_OPTION_TRANSITIONAL)) ? FRAMETIME : FRAMETIME_FIXED * (128-(SEGMENT.speed>>1)); // update only when appropriate time passes (in 42 FPS slots)
|
return FRAMETIME_FIXED * (128-(SEGMENT.speed>>1)); // update only when appropriate time passes (in 42 FPS slots)
|
||||||
} // mode_2Dgameoflife()
|
} // mode_2Dgameoflife()
|
||||||
static const char _data_FX_MODE_2DGAMEOFLIFE[] PROGMEM = "Game Of Life@!,;!,!;!;2d";
|
static const char _data_FX_MODE_2DGAMEOFLIFE[] PROGMEM = "Game Of Life@!,;!,!;!;2d";
|
||||||
|
|
||||||
|
50
wled00/FX.h
50
wled00/FX.h
@ -344,7 +344,7 @@ typedef enum mapping1D2D {
|
|||||||
M12_Block = 3
|
M12_Block = 3
|
||||||
} mapping1D2D_t;
|
} mapping1D2D_t;
|
||||||
|
|
||||||
// segment, 68 (92 in memory) bytes
|
// segment, 72 bytes
|
||||||
typedef struct Segment {
|
typedef struct Segment {
|
||||||
public:
|
public:
|
||||||
uint16_t start; // start index / start X coordinate 2D (left)
|
uint16_t start; // start index / start X coordinate 2D (left)
|
||||||
@ -357,34 +357,38 @@ typedef struct Segment {
|
|||||||
union {
|
union {
|
||||||
uint16_t options; //bit pattern: msb first: [transposed mirrorY reverseY] transitional (tbd) paused needspixelstate mirrored on reverse selected
|
uint16_t options; //bit pattern: msb first: [transposed mirrorY reverseY] transitional (tbd) paused needspixelstate mirrored on reverse selected
|
||||||
struct {
|
struct {
|
||||||
bool selected : 1; // 0 : selected
|
bool selected : 1; // 0 : selected
|
||||||
bool reverse : 1; // 1 : reversed
|
bool reverse : 1; // 1 : reversed
|
||||||
bool on : 1; // 2 : is On
|
bool on : 1; // 2 : is On
|
||||||
bool mirror : 1; // 3 : mirrored
|
bool mirror : 1; // 3 : mirrored
|
||||||
bool pxs : 1; // 4 : indicates that the effect does not use FRAMETIME or needs getPixelColor (?)
|
bool pxs : 1; // 4 : indicates that the effect does not use FRAMETIME or needs getPixelColor (?)
|
||||||
bool freeze : 1; // 5 : paused/frozen
|
bool freeze : 1; // 5 : paused/frozen
|
||||||
bool reset : 1; // 6 : indicates that Segment runtime requires reset
|
bool reset : 1; // 6 : indicates that Segment runtime requires reset
|
||||||
bool transitional: 1; // 7 : transitional (there is transition occuring)
|
bool transitional: 1; // 7 : transitional (there is transition occuring)
|
||||||
bool reverse_y : 1; // 8 : reversed Y (2D)
|
bool reverse_y : 1; // 8 : reversed Y (2D)
|
||||||
bool mirror_y : 1; // 9 : mirrored Y (2D)
|
bool mirror_y : 1; // 9 : mirrored Y (2D)
|
||||||
bool transpose : 1; // 10 : transposed (2D, swapped X & Y)
|
bool transpose : 1; // 10 : transposed (2D, swapped X & Y)
|
||||||
uint8_t map1D2D : 2; // 11-12 : mapping for 1D effect on 2D (0-strip, 1-expand vertically, 2-circular, 3-rectangular)
|
uint8_t map1D2D : 3; // 11-13 : mapping for 1D effect on 2D (0-use as strip, 1-expand vertically, 2-circular/arc, 3-rectangular/corner, ...)
|
||||||
uint8_t soundSim : 3; // 13-15 : 0-7 sound simulation types
|
uint8_t soundSim : 2; // 14-15 : 0-3 sound simulation types
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
uint8_t grouping, spacing;
|
uint8_t grouping, spacing;
|
||||||
|
//struct {
|
||||||
|
// uint8_t grouping : 4; // maximum 15 pixels in a group
|
||||||
|
// uint8_t spacing : 4; // maximum 15 pixels per gap
|
||||||
|
//};
|
||||||
uint8_t opacity;
|
uint8_t opacity;
|
||||||
uint32_t colors[NUM_COLORS];
|
uint32_t colors[NUM_COLORS];
|
||||||
uint8_t cct; //0==1900K, 255==10091K
|
uint8_t cct; //0==1900K, 255==10091K
|
||||||
uint8_t custom1, custom2; // custom FX parameters/sliders
|
uint8_t custom1, custom2; // custom FX parameters/sliders
|
||||||
struct {
|
struct {
|
||||||
uint8_t custom3 : 5; // reduced range slider (0-31)
|
uint8_t custom3 : 5; // reduced range slider (0-31)
|
||||||
bool check1 : 1; // checkmark 1
|
bool check1 : 1; // checkmark 1
|
||||||
bool check2 : 1; // checkmark 2
|
bool check2 : 1; // checkmark 2
|
||||||
bool check3 : 1; // checkmark 3
|
bool check3 : 1; // checkmark 3
|
||||||
};
|
};
|
||||||
uint16_t startY; // start Y coodrinate 2D (top)
|
uint8_t startY; // start Y coodrinate 2D (top); there should be no more than 255 rows
|
||||||
uint16_t stopY; // stop Y coordinate 2D (bottom)
|
uint8_t stopY; // stop Y coordinate 2D (bottom); there should be no more than 255 rows
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
// runtime data
|
// runtime data
|
||||||
@ -627,7 +631,7 @@ typedef struct Segment {
|
|||||||
void wu_pixel(uint32_t x, uint32_t y, CRGB c) {}
|
void wu_pixel(uint32_t x, uint32_t y, CRGB c) {}
|
||||||
#endif
|
#endif
|
||||||
} segment;
|
} segment;
|
||||||
//static int i = sizeof(Segment);
|
//static int segSize = sizeof(Segment);
|
||||||
|
|
||||||
// main "strip" class
|
// main "strip" class
|
||||||
class WS2812FX { // 96 bytes
|
class WS2812FX { // 96 bytes
|
||||||
|
@ -1106,7 +1106,7 @@ void WS2812FX::setBrightness(uint8_t b, bool direct) {
|
|||||||
_brightness = b;
|
_brightness = b;
|
||||||
if (_brightness == 0) { //unfreeze all segments on power off
|
if (_brightness == 0) { //unfreeze all segments on power off
|
||||||
for (segment &seg : _segments) {
|
for (segment &seg : _segments) {
|
||||||
seg.setOption(SEG_OPTION_FREEZE, false);
|
seg.freeze = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (direct) {
|
if (direct) {
|
||||||
@ -1319,7 +1319,7 @@ void WS2812FX::makeAutoSegments(bool forceReset) {
|
|||||||
_segments.clear();
|
_segments.clear();
|
||||||
for (size_t i = 0; i < s; i++) {
|
for (size_t i = 0; i < s; i++) {
|
||||||
Segment seg = Segment(segStarts[i], segStops[i]);
|
Segment seg = Segment(segStarts[i], segStops[i]);
|
||||||
seg.setOption(SEG_OPTION_SELECTED, true);
|
seg.selected = true;
|
||||||
_segments.push_back(seg);
|
_segments.push_back(seg);
|
||||||
}
|
}
|
||||||
_mainSegment = 0;
|
_mainSegment = 0;
|
||||||
|
@ -197,10 +197,10 @@ void handleAnalog(uint8_t b)
|
|||||||
// otherwise use "double press" for segment selection
|
// otherwise use "double press" for segment selection
|
||||||
Segment& seg = strip.getSegment(macroDoublePress[b]);
|
Segment& seg = strip.getSegment(macroDoublePress[b]);
|
||||||
if (aRead == 0) {
|
if (aRead == 0) {
|
||||||
seg.setOption(SEG_OPTION_ON, 0); // off
|
seg.on = false; // off
|
||||||
} else {
|
} else {
|
||||||
seg.setOpacity(aRead);
|
seg.setOpacity(aRead);
|
||||||
seg.setOption(SEG_OPTION_ON, 1);
|
seg.on = true;
|
||||||
}
|
}
|
||||||
// this will notify clients of update (websockets,mqtt,etc)
|
// this will notify clients of update (websockets,mqtt,etc)
|
||||||
updateInterfaces(CALL_MODE_BUTTON);
|
updateInterfaces(CALL_MODE_BUTTON);
|
||||||
|
@ -84,8 +84,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
|
|
||||||
if ((spc>0 && spc!=seg.spacing) || seg.map1D2D!=map1D2D) seg.fill(BLACK); // clear spacing gaps
|
if ((spc>0 && spc!=seg.spacing) || seg.map1D2D!=map1D2D) seg.fill(BLACK); // clear spacing gaps
|
||||||
|
|
||||||
seg.map1D2D = map1D2D & 0x03;
|
seg.map1D2D = map1D2D & 0x07;
|
||||||
seg.soundSim = soundSim & 0x07;
|
seg.soundSim = soundSim & 0x03;
|
||||||
|
|
||||||
uint16_t len = 1;
|
uint16_t len = 1;
|
||||||
if (stop > start) len = stop - start;
|
if (stop > start) len = stop - start;
|
||||||
@ -102,15 +102,15 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
byte segbri = seg.opacity;
|
byte segbri = seg.opacity;
|
||||||
if (getVal(elem["bri"], &segbri)) {
|
if (getVal(elem["bri"], &segbri)) {
|
||||||
if (segbri > 0) seg.setOpacity(segbri);
|
if (segbri > 0) seg.setOpacity(segbri);
|
||||||
seg.setOption(SEG_OPTION_ON, segbri);
|
seg.on = segbri;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool on = elem["on"] | seg.getOption(SEG_OPTION_ON);
|
bool on = elem["on"] | seg.on;
|
||||||
if (elem["on"].is<const char*>() && elem["on"].as<const char*>()[0] == 't') on = !on;
|
if (elem["on"].is<const char*>() && elem["on"].as<const char*>()[0] == 't') on = !on;
|
||||||
seg.setOption(SEG_OPTION_ON, on);
|
seg.on = on;
|
||||||
bool frz = elem["frz"] | seg.getOption(SEG_OPTION_FREEZE);
|
bool frz = elem["frz"] | seg.freeze;
|
||||||
if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.getOption(SEG_OPTION_FREEZE);
|
if (elem["frz"].is<const char*>() && elem["frz"].as<const char*>()[0] == 't') frz = !seg.freeze;
|
||||||
seg.setOption(SEG_OPTION_FREEZE, frz);
|
seg.freeze = frz;
|
||||||
|
|
||||||
seg.setCCT(elem["cct"] | seg.cct);
|
seg.setCCT(elem["cct"] | seg.cct);
|
||||||
|
|
||||||
@ -162,13 +162,13 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
seg.setOption(SEG_OPTION_SELECTED, elem["sel"] | seg.getOption(SEG_OPTION_SELECTED));
|
seg.selected = elem["sel"] | seg.selected;
|
||||||
seg.setOption(SEG_OPTION_REVERSED, elem["rev"] | seg.getOption(SEG_OPTION_REVERSED));
|
seg.reverse = elem["rev"] | seg.reverse;
|
||||||
seg.setOption(SEG_OPTION_MIRROR , elem[F("mi")] | seg.getOption(SEG_OPTION_MIRROR ));
|
seg.mirror = elem[F("mi")] | seg.mirror;
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
seg.setOption(SEG_OPTION_REVERSED_Y, elem[F("rY")] | seg.getOption(SEG_OPTION_REVERSED_Y));
|
seg.reverse_y = elem[F("rY")] | seg.reverse_y;
|
||||||
seg.setOption(SEG_OPTION_MIRROR_Y , elem[F("mY")] | seg.getOption(SEG_OPTION_MIRROR_Y ));
|
seg.mirror_y = elem[F("mY")] | seg.mirror_y;
|
||||||
seg.setOption(SEG_OPTION_TRANSPOSED, elem[F("tp")] | seg.getOption(SEG_OPTION_TRANSPOSED));
|
seg.transpose = elem[F("tp")] | seg.transpose;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
byte fx = seg.mode;
|
byte fx = seg.mode;
|
||||||
@ -193,8 +193,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
sOpt = extractModeDefaults(fx, SET_F("c1")); if (sOpt >= 0) seg.custom1 = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("c1")); if (sOpt >= 0) seg.custom1 = sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("c2")); if (sOpt >= 0) seg.custom2 = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("c2")); if (sOpt >= 0) seg.custom2 = sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("c3")); if (sOpt >= 0) seg.custom3 = sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("c3")); if (sOpt >= 0) seg.custom3 = sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("mp12")); if (sOpt >= 0) seg.map1D2D = sOpt & 0x03;
|
sOpt = extractModeDefaults(fx, SET_F("mp12")); if (sOpt >= 0) seg.map1D2D = sOpt & 0x07;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("ssim")); if (sOpt >= 0) seg.soundSim = sOpt & 0x07;
|
sOpt = extractModeDefaults(fx, SET_F("ssim")); if (sOpt >= 0) seg.soundSim = sOpt & 0x03;
|
||||||
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
|
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
|
||||||
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
|
||||||
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
|
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
|
||||||
@ -238,8 +238,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
strip.setBrightness(scaledBri(bri), true);
|
strip.setBrightness(scaledBri(bri), true);
|
||||||
|
|
||||||
// freeze and init to black
|
// freeze and init to black
|
||||||
if (!seg.getOption(SEG_OPTION_FREEZE)) {
|
if (!seg.freeze) {
|
||||||
seg.setOption(SEG_OPTION_FREEZE, true);
|
seg.freeze = true;
|
||||||
seg.fill(BLACK);
|
seg.fill(BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
|
|||||||
}
|
}
|
||||||
// send UDP if not in preset and something changed that is not just selection
|
// send UDP if not in preset and something changed that is not just selection
|
||||||
// send UDP if something changed that is not just selection or segment power/opacity
|
// send UDP if something changed that is not just selection or segment power/opacity
|
||||||
if ((seg.differs(prev) & 0x7E) && seg.getOption(SEG_OPTION_ON)==prev.getOption(SEG_OPTION_ON)) stateChanged = true;
|
if ((seg.differs(prev) & 0x7E) && seg.on == prev.on) stateChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// deserializes WLED state (fileDoc points to doc object if called from web server)
|
// deserializes WLED state (fileDoc points to doc object if called from web server)
|
||||||
@ -315,10 +315,10 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
|||||||
|
|
||||||
if (bri && !onBefore) { // unfreeze all segments when turning on
|
if (bri && !onBefore) { // unfreeze all segments when turning on
|
||||||
for (size_t s=0; s < strip.getSegmentsNum(); s++) {
|
for (size_t s=0; s < strip.getSegmentsNum(); s++) {
|
||||||
strip.getSegment(s).setOption(SEG_OPTION_FREEZE, false);
|
strip.getSegment(s).freeze = false;
|
||||||
}
|
}
|
||||||
if (realtimeMode && !realtimeOverride && useMainSegmentOnly) { // keep live segment frozen if live
|
if (realtimeMode && !realtimeOverride && useMainSegmentOnly) { // keep live segment frozen if live
|
||||||
strip.getMainSegment().setOption(SEG_OPTION_FREEZE, true);
|
strip.getMainSegment().freeze = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +371,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
|
|||||||
realtimeOverride = root[F("lor")] | realtimeOverride;
|
realtimeOverride = root[F("lor")] | realtimeOverride;
|
||||||
if (realtimeOverride > 2) realtimeOverride = REALTIME_OVERRIDE_ALWAYS;
|
if (realtimeOverride > 2) realtimeOverride = REALTIME_OVERRIDE_ALWAYS;
|
||||||
if (realtimeMode && useMainSegmentOnly) {
|
if (realtimeMode && useMainSegmentOnly) {
|
||||||
strip.getMainSegment().setOption(SEG_OPTION_FREEZE, !realtimeOverride);
|
strip.getMainSegment().freeze = !realtimeOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root.containsKey("live")) {
|
if (root.containsKey("live")) {
|
||||||
@ -472,14 +472,14 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!forPreset) root["len"] = seg.stop - seg.start;
|
if (!forPreset) root["len"] = seg.stop - seg.start;
|
||||||
root["grp"] = seg.grouping;
|
root["grp"] = seg.grouping;
|
||||||
root[F("spc")] = seg.spacing;
|
root[F("spc")] = seg.spacing;
|
||||||
root[F("of")] = seg.offset;
|
root[F("of")] = seg.offset;
|
||||||
root["on"] = seg.getOption(SEG_OPTION_ON);
|
root["on"] = seg.on;
|
||||||
root["frz"] = seg.getOption(SEG_OPTION_FREEZE);
|
root["frz"] = seg.freeze;
|
||||||
byte segbri = seg.opacity;
|
byte segbri = seg.opacity;
|
||||||
root["bri"] = (segbri) ? segbri : 255;
|
root["bri"] = (segbri) ? segbri : 255;
|
||||||
root["cct"] = seg.cct;
|
root["cct"] = seg.cct;
|
||||||
|
|
||||||
if (segmentBounds && seg.name != nullptr) root["n"] = reinterpret_cast<const char *>(seg.name); //not good practice, but decreases required JSON buffer
|
if (segmentBounds && seg.name != nullptr) root["n"] = reinterpret_cast<const char *>(seg.name); //not good practice, but decreases required JSON buffer
|
||||||
|
|
||||||
@ -509,12 +509,12 @@ void serializeSegment(JsonObject& root, Segment& seg, byte id, bool forPreset, b
|
|||||||
root[F("c2")] = seg.custom2;
|
root[F("c2")] = seg.custom2;
|
||||||
root[F("c3")] = seg.custom3;
|
root[F("c3")] = seg.custom3;
|
||||||
root[F("sel")] = seg.isSelected();
|
root[F("sel")] = seg.isSelected();
|
||||||
root["rev"] = seg.getOption(SEG_OPTION_REVERSED);
|
root["rev"] = seg.reverse;
|
||||||
root[F("mi")] = seg.getOption(SEG_OPTION_MIRROR);
|
root[F("mi")] = seg.mirror;
|
||||||
if (strip.isMatrix) {
|
if (strip.isMatrix) {
|
||||||
root[F("rY")] = seg.getOption(SEG_OPTION_REVERSED_Y);
|
root[F("rY")] = seg.reverse_y;
|
||||||
root[F("mY")] = seg.getOption(SEG_OPTION_MIRROR_Y);
|
root[F("mY")] = seg.mirror_y;
|
||||||
root[F("tp")] = seg.getOption(SEG_OPTION_TRANSPOSED);
|
root[F("tp")] = seg.transpose;
|
||||||
}
|
}
|
||||||
root[F("o1")] = seg.check1;
|
root[F("o1")] = seg.check1;
|
||||||
root[F("o2")] = seg.check2;
|
root[F("o2")] = seg.check2;
|
||||||
|
@ -665,8 +665,8 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
|||||||
pos = req.indexOf(F("SV=")); //segment selected
|
pos = req.indexOf(F("SV=")); //segment selected
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
byte t = getNumVal(&req, pos);
|
byte t = getNumVal(&req, pos);
|
||||||
if (t == 2) for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) strip.getSegment(i).setOption(SEG_OPTION_SELECTED, 0); // unselect other segments
|
if (t == 2) for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) strip.getSegment(i).selected = false; // unselect other segments
|
||||||
selseg.setOption(SEG_OPTION_SELECTED, t);
|
selseg.selected = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// temporary values, write directly to segments, globals are updated by setValuesFromFirstSelectedSeg()
|
// temporary values, write directly to segments, globals are updated by setValuesFromFirstSelectedSeg()
|
||||||
@ -705,15 +705,15 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
|||||||
strip.setSegment(selectedSeg, startI, stopI, grpI, spcI, UINT16_MAX, startY, stopY);
|
strip.setSegment(selectedSeg, startI, stopI, grpI, spcI, UINT16_MAX, startY, stopY);
|
||||||
|
|
||||||
pos = req.indexOf(F("RV=")); //Segment reverse
|
pos = req.indexOf(F("RV=")); //Segment reverse
|
||||||
if (pos > 0) selseg.setOption(SEG_OPTION_REVERSED, req.charAt(pos+3) != '0');
|
if (pos > 0) selseg.reverse = req.charAt(pos+3) != '0';
|
||||||
|
|
||||||
pos = req.indexOf(F("MI=")); //Segment mirror
|
pos = req.indexOf(F("MI=")); //Segment mirror
|
||||||
if (pos > 0) selseg.setOption(SEG_OPTION_MIRROR, req.charAt(pos+3) != '0');
|
if (pos > 0) selseg.mirror = req.charAt(pos+3) != '0';
|
||||||
|
|
||||||
pos = req.indexOf(F("SB=")); //Segment brightness/opacity
|
pos = req.indexOf(F("SB=")); //Segment brightness/opacity
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
byte segbri = getNumVal(&req, pos);
|
byte segbri = getNumVal(&req, pos);
|
||||||
selseg.setOption(SEG_OPTION_ON, segbri);
|
selseg.on = segbri;
|
||||||
if (segbri) {
|
if (segbri) {
|
||||||
selseg.setOpacity(segbri);
|
selseg.setOpacity(segbri);
|
||||||
}
|
}
|
||||||
@ -722,9 +722,9 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
|||||||
pos = req.indexOf(F("SW=")); //segment power
|
pos = req.indexOf(F("SW=")); //segment power
|
||||||
if (pos > 0) {
|
if (pos > 0) {
|
||||||
switch (getNumVal(&req, pos)) {
|
switch (getNumVal(&req, pos)) {
|
||||||
case 0: selseg.setOption(SEG_OPTION_ON, false); break;
|
case 0: selseg.on = false; break;
|
||||||
case 1: selseg.setOption(SEG_OPTION_ON, true); break;
|
case 1: selseg.on = true; break;
|
||||||
default: selseg.setOption(SEG_OPTION_ON, !selseg.getOption(SEG_OPTION_ON)); break;
|
default: selseg.on = !selseg.on; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,7 +981,7 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
|
|||||||
realtimeOverride = getNumVal(&req, pos);
|
realtimeOverride = getNumVal(&req, pos);
|
||||||
if (realtimeOverride > 2) realtimeOverride = REALTIME_OVERRIDE_ALWAYS;
|
if (realtimeOverride > 2) realtimeOverride = REALTIME_OVERRIDE_ALWAYS;
|
||||||
if (realtimeMode && useMainSegmentOnly) {
|
if (realtimeMode && useMainSegmentOnly) {
|
||||||
strip.getMainSegment().setOption(SEG_OPTION_FREEZE, !realtimeOverride);
|
strip.getMainSegment().freeze = !realtimeOverride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ void realtimeLock(uint32_t timeoutMs, byte md)
|
|||||||
Segment& mainseg = strip.getMainSegment();
|
Segment& mainseg = strip.getMainSegment();
|
||||||
start = mainseg.start;
|
start = mainseg.start;
|
||||||
stop = mainseg.stop;
|
stop = mainseg.stop;
|
||||||
mainseg.setOption(SEG_OPTION_FREEZE, true);
|
mainseg.freeze = true;
|
||||||
} else {
|
} else {
|
||||||
start = 0;
|
start = 0;
|
||||||
stop = strip.getLengthTotal();
|
stop = strip.getLengthTotal();
|
||||||
@ -159,7 +159,7 @@ void realtimeLock(uint32_t timeoutMs, byte md)
|
|||||||
// if WLED was off and using main segment only, freeze non-main segments so they stay off
|
// if WLED was off and using main segment only, freeze non-main segments so they stay off
|
||||||
if (useMainSegmentOnly && bri == 0) {
|
if (useMainSegmentOnly && bri == 0) {
|
||||||
for (size_t s=0; s < strip.getSegmentsNum(); s++) {
|
for (size_t s=0; s < strip.getSegmentsNum(); s++) {
|
||||||
strip.getSegment(s).setOption(SEG_OPTION_FREEZE, true);
|
strip.getSegment(s).freeze = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ void exitRealtime() {
|
|||||||
realtimeMode = REALTIME_MODE_INACTIVE; // inform UI immediately
|
realtimeMode = REALTIME_MODE_INACTIVE; // inform UI immediately
|
||||||
realtimeIP[0] = 0;
|
realtimeIP[0] = 0;
|
||||||
if (useMainSegmentOnly) { // unfreeze live segment again
|
if (useMainSegmentOnly) { // unfreeze live segment again
|
||||||
strip.getMainSegment().setOption(SEG_OPTION_FREEZE, false);
|
strip.getMainSegment().freeze = false;
|
||||||
}
|
}
|
||||||
updateInterfaces(CALL_MODE_WS_SEND);
|
updateInterfaces(CALL_MODE_WS_SEND);
|
||||||
}
|
}
|
||||||
|
@ -414,10 +414,10 @@ void deEEP() {
|
|||||||
for (byte j = 0; j < numChannels; j++) colX.add(EEPROM.read(memloc + j));
|
for (byte j = 0; j < numChannels; j++) colX.add(EEPROM.read(memloc + j));
|
||||||
}
|
}
|
||||||
|
|
||||||
segObj["fx"] = EEPROM.read(i+10);
|
segObj["fx"] = EEPROM.read(i+10);
|
||||||
segObj[F("sx")] = EEPROM.read(i+11);
|
segObj[F("sx")] = EEPROM.read(i+11);
|
||||||
segObj[F("ix")] = EEPROM.read(i+16);
|
segObj[F("ix")] = EEPROM.read(i+16);
|
||||||
segObj["pal"] = EEPROM.read(i+17);
|
segObj["pal"] = EEPROM.read(i+17);
|
||||||
} else {
|
} else {
|
||||||
Segment* seg = strip.getSegments();
|
Segment* seg = strip.getSegments();
|
||||||
memcpy(seg, EEPROM.getDataPtr() +i+2, 240);
|
memcpy(seg, EEPROM.getDataPtr() +i+2, 240);
|
||||||
@ -425,7 +425,7 @@ void deEEP() {
|
|||||||
for (byte j = 0; j < strip.getMaxSegments(); j++)
|
for (byte j = 0; j < strip.getMaxSegments(); j++)
|
||||||
{
|
{
|
||||||
strip.getSegment(j).opacity = 255;
|
strip.getSegment(j).opacity = 255;
|
||||||
strip.getSegment(j).setOption(SEG_OPTION_ON, 1);
|
strip.getSegment(j).on = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
serializeState(pObj, true, false, true);
|
serializeState(pObj, true, false, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user