Auto create segments setting (#2183)

This commit is contained in:
Christian Schwinne 2021-09-11 01:17:42 +02:00 committed by GitHub
parent 6a01658355
commit c24ab1b21d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 71 additions and 30 deletions

View File

@ -2,6 +2,13 @@
### Builds after release 0.12.0 ### Builds after release 0.12.0
#### Build 2109100
- Added an auto create segments per bus setting
- Added 15 new palettes from SR branch (PR #2134)
- Fixed segment runtime not reset on FX change via HTTP API
- Changed AsyncTCP dependency to pbolduc fork v1.2.0
#### Build 2108250 #### Build 2108250
- Added Sync groups (PR #2150) - Added Sync groups (PR #2150)

View File

@ -210,7 +210,7 @@ build_flags = -g
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
makuna/NeoPixelBus @ 2.6.7 makuna/NeoPixelBus @ 2.6.7
https://github.com/pbolduc/AsyncTCP.git https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
[esp32s2] [esp32s2]
build_flags = -g build_flags = -g
@ -224,7 +224,7 @@ build_flags = -g
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
makuna/NeoPixelBus @ 2.6.7 makuna/NeoPixelBus @ 2.6.7
https://github.com/pbolduc/AsyncTCP.git https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# WLED BUILDS # WLED BUILDS

View File

@ -98,11 +98,11 @@ void WS2812FX::finalizeInit(uint16_t countPixels)
setBrightness(_brightness); setBrightness(_brightness);
//TODO make sure segments are only refreshed when bus config actually changed (new settings page) //TODO make sure segments are only refreshed when bus config actually changed (new settings page)
//make one segment per bus
uint8_t s = 0; uint8_t s = 0;
for (uint8_t i = 0; i < busses.getNumBusses(); i++) { for (uint8_t i = 0; i < busses.getNumBusses(); i++) {
Bus* b = busses.getBus(i); Bus* b = busses.getBus(i);
if (autoSegments) { //make one segment per bus
segStarts[s] = b->getStart(); segStarts[s] = b->getStart();
segStops[s] = segStarts[s] + b->getLength(); segStops[s] = segStarts[s] + b->getLength();
@ -116,6 +116,7 @@ void WS2812FX::finalizeInit(uint16_t countPixels)
} }
} }
s++; s++;
}
#ifdef ESP8266 #ifdef ESP8266
if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue; if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue;
@ -126,10 +127,30 @@ void WS2812FX::finalizeInit(uint16_t countPixels)
#endif #endif
} }
if (autoSegments) {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) { for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) {
_segments[i].start = segStarts[i]; _segments[i].start = segStarts[i];
_segments[i].stop = segStops [i]; _segments[i].stop = segStops [i];
} }
} else {
//expand the main seg to the entire length, but only if there are no other segments
uint8_t mainSeg = getMainSegmentId();
bool isMultipleSegs = false;
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (i != mainSeg && _segments[i].isActive()) isMultipleSegs = true;
}
if (!isMultipleSegs) {
_segments[mainSeg].start = 0; _segments[mainSeg].stop = _length;
} else {
//there are multiple segments, leave them, but prune length to total
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].start > _length) _segments[i].stop = 0;
if (_segments[i].stop > _length) _segments[i].stop = _length;
}
}
}
} }
void WS2812FX::service() { void WS2812FX::service() {

View File

@ -202,6 +202,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
JsonObject light = doc[F("light")]; JsonObject light = doc[F("light")];
CJSON(briMultiplier, light[F("scale-bri")]); CJSON(briMultiplier, light[F("scale-bri")]);
CJSON(strip.paletteBlend, light[F("pal-mode")]); CJSON(strip.paletteBlend, light[F("pal-mode")]);
CJSON(autoSegments, light[F("aseg")]);
float light_gc_bri = light["gc"]["bri"]; float light_gc_bri = light["gc"]["bri"];
float light_gc_col = light["gc"]["col"]; // 2.8 float light_gc_col = light["gc"]["col"]; // 2.8
@ -565,6 +566,7 @@ void serializeConfig() {
JsonObject light = doc.createNestedObject(F("light")); JsonObject light = doc.createNestedObject(F("light"));
light[F("scale-bri")] = briMultiplier; light[F("scale-bri")] = briMultiplier;
light[F("pal-mode")] = strip.paletteBlend; light[F("pal-mode")] = strip.paletteBlend;
light[F("aseg")] = autoSegments;
JsonObject light_gc = light.createNestedObject("gc"); JsonObject light_gc = light.createNestedObject("gc");
light_gc["bri"] = (strip.gammaCorrectBri) ? 2.8 : 1.0; light_gc["bri"] = (strip.gammaCorrectBri) ? 2.8 : 1.0;

View File

@ -369,7 +369,9 @@ Reverse (rotated 180°): <input type="checkbox" name="CV${i}">
<div id="ledwarning" style="color: orange; display: none;"> <div id="ledwarning" style="color: orange; display: none;">
&#9888; You might run into stability or lag issues.<br> &#9888; You might run into stability or lag issues.<br>
Use less than <span id="wreason">800 LEDs per pin</span> for the best experience!<br> Use less than <span id="wreason">800 LEDs per pin</span> for the best experience!<br>
</div><hr style="width:260px"> </div>
Make a segment for each output: <input type="checkbox" name="MS"> <br>
<hr style="width:260px">
<div id="btns"></div> <div id="btns"></div>
Touch threshold: <input type="number" class="s" min="0" max="100" name="TT" required><br> Touch threshold: <input type="number" class="s" min="0" max="100" name="TT" required><br>
IR pin: <input type="number" class="xs" min="-1" max="40" name="IR" onchange="UI()">&nbsp;<select name="IT" onchange="UI()"> IR pin: <input type="number" class="xs" min="-1" max="40" name="IR" onchange="UI()">&nbsp;<select name="IT" onchange="UI()">

View File

@ -113,7 +113,8 @@ id="dbar"
style="display:inline-block;width:100px;height:10px;border-radius:20px"></div> style="display:inline-block;width:100px;height:10px;border-radius:20px"></div>
<br><div id="ledwarning" style="color:orange;display:none"> <br><div id="ledwarning" style="color:orange;display:none">
&#9888; You might run into stability or lag issues.<br>Use less than <span &#9888; You might run into stability or lag issues.<br>Use less than <span
id="wreason">800 LEDs per pin</span> for the best experience!<br></div><hr id="wreason">800 LEDs per pin</span> for the best experience!<br></div>
Make a segment for each output: <input type="checkbox" name="MS"><br><hr
style="width:260px"><div id="btns"></div>Touch threshold: <input type="number" style="width:260px"><div id="btns"></div>Touch threshold: <input type="number"
class="s" min="0" max="100" name="TT" required><br>IR pin: <input type="number" class="s" min="0" max="100" name="TT" required><br>IR pin: <input type="number"
class="xs" min="-1" max="40" name="IR" onchange="UI()">&nbsp;<select name="IT" class="xs" min="-1" max="40" name="IR" onchange="UI()">&nbsp;<select name="IT"

View File

@ -119,7 +119,7 @@ void onHueData(void* arg, AsyncClient* client, void *data, size_t len)
const char* apikey = root[0][F("success")][F("username")]; const char* apikey = root[0][F("success")][F("username")];
if (apikey != nullptr && strlen(apikey) < sizeof(hueApiKey)) if (apikey != nullptr && strlen(apikey) < sizeof(hueApiKey))
{ {
strcpy(hueApiKey, apikey); strlcpy(hueApiKey, apikey, sizeof(hueApiKey));
hueAuthRequired = false; hueAuthRequired = false;
hueNewKey = true; hueNewKey = true;
} }

View File

@ -26,21 +26,21 @@ void onMqttConnect(bool sessionPresent)
char subuf[38]; char subuf[38];
if (mqttDeviceTopic[0] != 0) { if (mqttDeviceTopic[0] != 0) {
strcpy(subuf, mqttDeviceTopic); strlcpy(subuf, mqttDeviceTopic, 33);
mqtt->subscribe(subuf, 0); mqtt->subscribe(subuf, 0);
strcat_P(subuf, PSTR("/col")); strcat_P(subuf, PSTR("/col"));
mqtt->subscribe(subuf, 0); mqtt->subscribe(subuf, 0);
strcpy(subuf, mqttDeviceTopic); strlcpy(subuf, mqttDeviceTopic, 33);
strcat_P(subuf, PSTR("/api")); strcat_P(subuf, PSTR("/api"));
mqtt->subscribe(subuf, 0); mqtt->subscribe(subuf, 0);
} }
if (mqttGroupTopic[0] != 0) { if (mqttGroupTopic[0] != 0) {
strcpy(subuf, mqttGroupTopic); strlcpy(subuf, mqttGroupTopic, 33);
mqtt->subscribe(subuf, 0); mqtt->subscribe(subuf, 0);
strcat_P(subuf, PSTR("/col")); strcat_P(subuf, PSTR("/col"));
mqtt->subscribe(subuf, 0); mqtt->subscribe(subuf, 0);
strcpy(subuf, mqttGroupTopic); strlcpy(subuf, mqttGroupTopic, 33);
strcat_P(subuf, PSTR("/api")); strcat_P(subuf, PSTR("/api"));
mqtt->subscribe(subuf, 0); mqtt->subscribe(subuf, 0);
} }
@ -122,22 +122,22 @@ void publishMqtt()
char subuf[38]; char subuf[38];
sprintf_P(s, PSTR("%u"), bri); sprintf_P(s, PSTR("%u"), bri);
strcpy(subuf, mqttDeviceTopic); strlcpy(subuf, mqttDeviceTopic, 33);
strcat_P(subuf, PSTR("/g")); strcat_P(subuf, PSTR("/g"));
mqtt->publish(subuf, 0, true, s); mqtt->publish(subuf, 0, true, s);
sprintf_P(s, PSTR("#%06X"), (col[3] << 24) | (col[0] << 16) | (col[1] << 8) | (col[2])); sprintf_P(s, PSTR("#%06X"), (col[3] << 24) | (col[0] << 16) | (col[1] << 8) | (col[2]));
strcpy(subuf, mqttDeviceTopic); strlcpy(subuf, mqttDeviceTopic, 33);
strcat_P(subuf, PSTR("/c")); strcat_P(subuf, PSTR("/c"));
mqtt->publish(subuf, 0, true, s); mqtt->publish(subuf, 0, true, s);
strcpy(subuf, mqttDeviceTopic); strlcpy(subuf, mqttDeviceTopic, 33);
strcat_P(subuf, PSTR("/status")); strcat_P(subuf, PSTR("/status"));
mqtt->publish(subuf, 0, true, "online"); mqtt->publish(subuf, 0, true, "online");
char apires[1024]; char apires[1024];
XML_response(nullptr, apires); XML_response(nullptr, apires);
strcpy(subuf, mqttDeviceTopic); strlcpy(subuf, mqttDeviceTopic, 33);
strcat_P(subuf, PSTR("/v")); strcat_P(subuf, PSTR("/v"));
mqtt->publish(subuf, 0, false, apires); mqtt->publish(subuf, 0, false, apires);
} }
@ -167,7 +167,7 @@ bool initMqtt()
mqtt->setClientId(mqttClientID); mqtt->setClientId(mqttClientID);
if (mqttUser[0] && mqttPass[0]) mqtt->setCredentials(mqttUser, mqttPass); if (mqttUser[0] && mqttPass[0]) mqtt->setCredentials(mqttUser, mqttPass);
strcpy(mqttStatusTopic, mqttDeviceTopic); strlcpy(mqttStatusTopic, mqttDeviceTopic, 33);
strcat_P(mqttStatusTopic, PSTR("/status")); strcat_P(mqttStatusTopic, PSTR("/status"));
mqtt->setWill(mqttStatusTopic, 0, true, "offline"); mqtt->setWill(mqttStatusTopic, 0, true, "offline");
mqtt->setKeepAlive(MQTT_KEEP_ALIVE_TIME); mqtt->setKeepAlive(MQTT_KEEP_ALIVE_TIME);

View File

@ -95,6 +95,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
uint16_t length, start; uint16_t length, start;
uint8_t pins[5] = {255, 255, 255, 255, 255}; uint8_t pins[5] = {255, 255, 255, 255, 255};
autoSegments = request->hasArg(F("MS"));
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) { for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length char lc[4] = "LC"; lc[2] = 48+s; lc[3] = 0; //strip length
@ -327,7 +329,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
analogClockSecondsTrail = request->hasArg(F("OS")); analogClockSecondsTrail = request->hasArg(F("OS"));
#ifndef WLED_DISABLE_CRONIXIE #ifndef WLED_DISABLE_CRONIXIE
strcpy(cronixieDisplay,request->arg(F("CX")).c_str()); strlcpy(cronixieDisplay,request->arg(F("CX")).c_str(),7);
cronixieBacklight = request->hasArg(F("CB")); cronixieBacklight = request->hasArg(F("CB"));
#endif #endif
countdownMode = request->hasArg(F("CE")); countdownMode = request->hasArg(F("CE"));

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2108250 #define VERSION 2109100
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG
@ -267,6 +267,11 @@ WLED_GLOBAL uint16_t ledCount _INIT(DEFAULT_LED_COUNT); // overcurrent prevent
WLED_GLOBAL bool turnOnAtBoot _INIT(true); // turn on LEDs at power-up WLED_GLOBAL bool turnOnAtBoot _INIT(true); // turn on LEDs at power-up
WLED_GLOBAL byte bootPreset _INIT(0); // save preset to load after power-up WLED_GLOBAL byte bootPreset _INIT(0); // save preset to load after power-up
//if true, a segment per bus will be created on boot and LED settings save
//if false, only one segment spanning the total LEDs is created,
//but not on LED settings save if there is more than one segment currently
WLED_GLOBAL bool autoSegments _INIT(false);
WLED_GLOBAL byte col[] _INIT_N(({ 255, 160, 0, 0 })); // current RGB(W) primary color. col[] should be updated if you want to change the color. WLED_GLOBAL byte col[] _INIT_N(({ 255, 160, 0, 0 })); // current RGB(W) primary color. col[] should be updated if you want to change the color.
WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) secondary color WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) secondary color
WLED_GLOBAL byte briS _INIT(128); // default brightness WLED_GLOBAL byte briS _INIT(128); // default brightness

View File

@ -322,6 +322,7 @@ void getSettingsJS(byte subPage, char* dest)
oappend(";"); oappend(";");
sappend('v',SET_F("LC"),ledCount); sappend('v',SET_F("LC"),ledCount);
sappend('c',SET_F("MS"),autoSegments);
for (uint8_t s=0; s < busses.getNumBusses(); s++) { for (uint8_t s=0; s < busses.getNumBusses(); s++) {
Bus* bus = busses.getBus(s); Bus* bus = busses.getBus(s);