From 2dce4462a06005bbe8a0400cfd28df3626726ad6 Mon Sep 17 00:00:00 2001 From: Warren Spits Date: Mon, 9 Dec 2019 23:16:16 +1100 Subject: [PATCH] Saving and loading of grouping and spacing. --- wled00/FX_fcn.cpp | 2 ++ wled00/data/settings_leds.htm | Bin 16312 -> 7982 bytes wled00/html_settings.h | 5 +++-- wled00/wled00.ino | 1 + wled00/wled01_eeprom.ino | 2 ++ wled00/wled02_xml.ino | 3 ++- wled00/wled03_set.ino | 5 +++-- wled00/wled05_init.ino | 3 ++- wled00/wled19_json.ino | 15 +++++++-------- 9 files changed, 22 insertions(+), 14 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 158a766c..3a39b01b 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -50,6 +50,8 @@ void WS2812FX::init(bool supportWhite, uint16_t countPixels, uint8_t group, uint _locked = new byte[_length]; _segments[0].start = 0; + _segments[0].group = _group; + _segments[0].spacing = _spacing; _segments[0].stop = getUsableCount(); _segments[0].rawLength = _length; diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 450512b0270776388ca3f5133829d469be188177..eb9774593584332f4a0e23e70d1617231e8f3041 100644 GIT binary patch literal 7982 zcmcIpYj4{|7X7UJidzfuLI~-cp2HoGj z=gyFnWXpD&-3{PK9L?P4xv$~yt5-jqT>fruad{G`!{iX<>9P3W!P#N%iDHC8GK(^Wgo zWa4`ZW3qhE>CBZ`6ti}aE;|#YgEURAlzrHJQgB+kB?? z@afcNo_oLMGLH6~z3`i#Po??jH;=Jr6KqawCMm$lsNFOx-5ccCxD7G1l1x?qG~;+X`x1 zV_74>70wPDd3TM2-J73o8{}*PGwjpF@)%JcBEF=1Ec4?#_;;V&l~OyBKjvJhWON}n zvhJ#fpZm3E^OZ8eg8YmF^j%_hE!%9?<{}D2E~z_s6kDJli8zGO>*5u-kno z0PadDmf2(E-&c8SOn>h^NWN6!p3LF0ops4pz+0QMY1w5i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mLlcr(|yq6Zb|$Nred~8dQE)u{}B(w z$BML`-np~?Ft8`YAQG;}s3vcw2(vs&U5EkYKOx@nM6wI#kUk=x zwH7_4Sy`6acq0u_{ep0&A+NSUecRzU*Cm%tFUT!E4B=l0zjDORB_Kv#MQ$p^BIoSn zaU?-*^h;gqwWn9gWv}u29hxUS&hR#BE%wh=ed9~EdcC)ne9>ckeE!>Zk~h;aIE#*v zggp$k!!Z8qc39GkW=9Ns!v@%+$zzTNOFCB@J*Mh?>{PY2Mb(#Ct}}#P7eCYr`Kf3d z0xxSE`|)l>YW%t>#W>!)9;Hkf+r6NTpGx@8zO-%4TyyKnBxufRSRxcJWWR2EES~x4 zHFvBt%6KGBJ42#rRdYR8Rzf+d8}f)%Gx&H@Yd6!#i=IYY6P_JicDgn6KI|#uE*H@6j`*+`S;?K2%x62 zK1Wlx$^GMeEYn zqz0Q*--p#%Q0ZwTIe z6|0?ply0CrTD}>ixn_l3_t=+x?x|S3iq3aIZ~(&7Ycq_S)p;RrTHnmKU#g?j=G$xP z64JZ2ch&fxXQF;kS7V%LS`(GF6<4$#-As!O%j
Reverse LED order (rotate 180):
Skip first LED:
-Disable repeating N LEDs:
-(Turns off N LEDs between each lit one, spacing out effects)
+LED spacing:
+(Turns off N LEDs between each lit one, spacing out effects)
+LED grouping:
)====="; diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 7052ee94..9e3d86cd 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -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 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 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) diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino index 38ea7c41..1e3d26c8 100644 --- a/wled00/wled01_eeprom.ino +++ b/wled00/wled01_eeprom.ino @@ -230,6 +230,7 @@ void saveSettingsToEEPROM() } EEPROM.write(2213, spacing); + EEPROM.write(2214, group); writeStringToEEPROM(2220, blynkApiKey, 35); @@ -481,6 +482,7 @@ void loadSettingsFromEEPROM(bool first) } spacing = EEPROM.read(2213); + group = max(1, EEPROM.read(2214)); bootPreset = EEPROM.read(389); wifiLock = EEPROM.read(393); diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 8303f7fd..5adbd900 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -237,7 +237,8 @@ void getSettingsJS(byte subPage, char* dest) sappend('i',"PB",strip.paletteBlend); sappend('c',"RV",strip.reverseMode); sappend('c',"SL",skipFirstLed); - sappend('v',"DL",spacing); + sappend('v',"SP",spacing); + sappend('v',"GR",group); } if (subPage == 3) diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 21332ddd..9762ffba 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -93,7 +93,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) if (t >= 0 && t < 4) strip.paletteBlend = t; strip.reverseMode = request->hasArg("RV"); skipFirstLed = request->hasArg("SL"); - spacing = request->arg("DL").toInt(); + spacing = request->arg("SP").toInt(); + group = request->arg("GR").toInt(); t = request->arg("BF").toInt(); 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 == 2) { - strip.init(useRGBW,ledCount,1,spacing,skipFirstLed); + strip.init(useRGBW,ledCount,group,spacing,skipFirstLed); } if (subPage == 4) alexaInit(); } diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 3559d7b6..32511be7 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -11,6 +11,7 @@ void wledInit() spacing = EEPROM.read(2213); //this was reading 255 after inital flash causing bootloop. Don't know why. spacing = spacing!= 255 ? spacing : 0; + group = max(1, EEPROM.read(2214)); #ifdef ESP8266 #if LEDPIN == 3 @@ -30,7 +31,7 @@ void wledInit() DEBUG_PRINT("heap "); 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); DEBUG_PRINT("LEDs inited. heap usage ~"); diff --git a/wled00/wled19_json.ino b/wled00/wled19_json.ino index 0d1b7d4b..cf3f6be8 100644 --- a/wled00/wled19_json.ino +++ b/wled00/wled19_json.ino @@ -8,14 +8,12 @@ void deserializeSegment(JsonObject elem, byte it) if (id < strip.getMaxSegments()) { WS2812FX::Segment& seg = strip.getSegment(id); - uint16_t start = elem["start"] | seg.start; - int stop = elem["stop"] | -1; + uint16_t start = elem.containsKey("start") ? elem["start"] : seg.start; + 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) { - uint16_t len = elem["len"]; - stop = (len > 0) ? start + len : seg.stop; - } - strip.setSegment(id, start, stop, 1, 0); + strip.setSegment(id, start, len, group, spacing); JsonArray colarr = elem["col"]; if (!colarr.isNull()) @@ -158,7 +156,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id) root["id"] = id; root["start"] = seg.start; root["stop"] = seg.stop; - root["len"] = seg.stop - seg.start; + root["len"] = seg.rawLength; JsonArray colarr = root.createNestedArray("col"); @@ -178,6 +176,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id) root["pal"] = seg.palette; root["sel"] = seg.isSelected(); root["grp"] = seg.group; + root["spc"] = seg.spacing; root["rev"] = seg.getOption(1); }