Saving and loading of grouping and spacing.

This commit is contained in:
Warren Spits 2019-12-09 23:16:16 +11:00
parent 55e2bc27c6
commit 2dce4462a0
9 changed files with 22 additions and 14 deletions

View File

@ -50,6 +50,8 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, uint8_t group, uint
_locked = new byte[_length]; _locked = new byte[_length];
_segments[0].start = 0; _segments[0].start = 0;
_segments[0].group = _group;
_segments[0].spacing = _spacing;
_segments[0].stop = getUsableCount(); _segments[0].stop = getUsableCount();
_segments[0].rawLength = _length; _segments[0].rawLength = _length;

Binary file not shown.

View File

@ -151,8 +151,9 @@ Palette blending:
</select><br> </select><br>
Reverse LED order (rotate 180): <input type=checkbox name=RV><br> Reverse LED order (rotate 180): <input type=checkbox name=RV><br>
Skip first LED: <input type=checkbox name=SL><br> Skip first LED: <input type=checkbox name=SL><br>
Disable repeating N LEDs: <input type=number min=0 max=255 name=DL><br> LED spacing: <input type=number min=0 max=255 name=SP><br>
(Turns off N LEDs between each lit one, spacing out effects)<hr> (Turns off N LEDs between each lit one, spacing out effects)<br>
LED grouping: <input type=number min=1 max=255 name=GR><hr>
<button type=button onclick=B()>Back</button><button type=submit>Save</button> <button type=button onclick=B()>Back</button><button type=submit>Save</button>
</form></body></html>)====="; </form></body></html>)=====";

View File

@ -150,6 +150,7 @@ uint16_t transitionDelay = 750; //default crossfade duration in ms
//bool strip.reverseMode = false; //flip entire LED strip (reverses all effect directions) --> edit in WS2812FX.h //bool strip.reverseMode = false; //flip entire LED strip (reverses all effect directions) --> edit in WS2812FX.h
bool skipFirstLed = false; //ignore first LED in strip (useful if you need the LED as signal repeater) bool skipFirstLed = false; //ignore first LED in strip (useful if you need the LED as signal repeater)
uint8_t spacing = 0; //disables N LEDs between active nodes. (Useful for spacing out lights for more traditional christmas light look) uint8_t spacing = 0; //disables N LEDs between active nodes. (Useful for spacing out lights for more traditional christmas light look)
uint8_t group = 1; //Group LEDs into one logical LED
byte briMultiplier = 100; //% of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127) byte briMultiplier = 100; //% of brightness to set (to limit power, if you set it to 50 and set bri to 255, actual brightness will be 127)

View File

@ -230,6 +230,7 @@ void saveSettingsToEEPROM()
} }
EEPROM.write(2213, spacing); EEPROM.write(2213, spacing);
EEPROM.write(2214, group);
writeStringToEEPROM(2220, blynkApiKey, 35); writeStringToEEPROM(2220, blynkApiKey, 35);
@ -481,6 +482,7 @@ void loadSettingsFromEEPROM(bool first)
} }
spacing = EEPROM.read(2213); spacing = EEPROM.read(2213);
group = max(1, EEPROM.read(2214));
bootPreset = EEPROM.read(389); bootPreset = EEPROM.read(389);
wifiLock = EEPROM.read(393); wifiLock = EEPROM.read(393);

View File

@ -237,7 +237,8 @@ void getSettingsJS(byte subPage, char* dest)
sappend('i',"PB",strip.paletteBlend); sappend('i',"PB",strip.paletteBlend);
sappend('c',"RV",strip.reverseMode); sappend('c',"RV",strip.reverseMode);
sappend('c',"SL",skipFirstLed); sappend('c',"SL",skipFirstLed);
sappend('v',"DL",spacing); sappend('v',"SP",spacing);
sappend('v',"GR",group);
} }
if (subPage == 3) if (subPage == 3)

View File

@ -93,7 +93,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (t >= 0 && t < 4) strip.paletteBlend = t; if (t >= 0 && t < 4) strip.paletteBlend = t;
strip.reverseMode = request->hasArg("RV"); strip.reverseMode = request->hasArg("RV");
skipFirstLed = request->hasArg("SL"); skipFirstLed = request->hasArg("SL");
spacing = request->arg("DL").toInt(); spacing = request->arg("SP").toInt();
group = request->arg("GR").toInt();
t = request->arg("BF").toInt(); t = request->arg("BF").toInt();
if (t > 0) briMultiplier = t; if (t > 0) briMultiplier = t;
} }
@ -274,7 +275,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
} }
if (subPage != 6 || !doReboot) saveSettingsToEEPROM(); //do not save if factory reset if (subPage != 6 || !doReboot) saveSettingsToEEPROM(); //do not save if factory reset
if (subPage == 2) { if (subPage == 2) {
strip.init(useRGBW,ledCount,1,spacing,skipFirstLed); strip.init(useRGBW,ledCount,group,spacing,skipFirstLed);
} }
if (subPage == 4) alexaInit(); if (subPage == 4) alexaInit();
} }

View File

@ -11,6 +11,7 @@ void wledInit()
spacing = EEPROM.read(2213); spacing = EEPROM.read(2213);
//this was reading 255 after inital flash causing bootloop. Don't know why. //this was reading 255 after inital flash causing bootloop. Don't know why.
spacing = spacing!= 255 ? spacing : 0; spacing = spacing!= 255 ? spacing : 0;
group = max(1, EEPROM.read(2214));
#ifdef ESP8266 #ifdef ESP8266
#if LEDPIN == 3 #if LEDPIN == 3
@ -30,7 +31,7 @@ void wledInit()
DEBUG_PRINT("heap "); DEBUG_PRINT("heap ");
DEBUG_PRINTLN(ESP.getFreeHeap()); DEBUG_PRINTLN(ESP.getFreeHeap());
strip.init(EEPROM.read(372),ledCount,1,spacing,EEPROM.read(2204)); //init LEDs quickly strip.init(EEPROM.read(372),ledCount,group,spacing,EEPROM.read(2204)); //init LEDs quickly
strip.setBrightness(0); strip.setBrightness(0);
DEBUG_PRINT("LEDs inited. heap usage ~"); DEBUG_PRINT("LEDs inited. heap usage ~");

View File

@ -8,14 +8,12 @@ void deserializeSegment(JsonObject elem, byte it)
if (id < strip.getMaxSegments()) if (id < strip.getMaxSegments())
{ {
WS2812FX::Segment& seg = strip.getSegment(id); WS2812FX::Segment& seg = strip.getSegment(id);
uint16_t start = elem["start"] | seg.start; uint16_t start = elem.containsKey("start") ? elem["start"] : seg.start;
int stop = elem["stop"] | -1; uint16_t len = elem.containsKey("len") ? elem["len"] : seg.rawLength;
uint8_t group = max(1, elem["grp"] | seg.group);
uint8_t spacing = elem.containsKey("spc") ? elem["spc"] : seg.spacing;
if (stop < 0) { strip.setSegment(id, start, len, group, spacing);
uint16_t len = elem["len"];
stop = (len > 0) ? start + len : seg.stop;
}
strip.setSegment(id, start, stop, 1, 0);
JsonArray colarr = elem["col"]; JsonArray colarr = elem["col"];
if (!colarr.isNull()) if (!colarr.isNull())
@ -158,7 +156,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id)
root["id"] = id; root["id"] = id;
root["start"] = seg.start; root["start"] = seg.start;
root["stop"] = seg.stop; root["stop"] = seg.stop;
root["len"] = seg.stop - seg.start; root["len"] = seg.rawLength;
JsonArray colarr = root.createNestedArray("col"); JsonArray colarr = root.createNestedArray("col");
@ -178,6 +176,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id)
root["pal"] = seg.palette; root["pal"] = seg.palette;
root["sel"] = seg.isSelected(); root["sel"] = seg.isSelected();
root["grp"] = seg.group; root["grp"] = seg.group;
root["spc"] = seg.spacing;
root["rev"] = seg.getOption(1); root["rev"] = seg.getOption(1);
} }