Auto-create segments based on configured busses

pull/2043/head
cschwinne 2021-06-24 02:29:14 +02:00
rodzic b73aaecd22
commit 660de0b4e5
5 zmienionych plików z 44 dodań i 11 usunięć

Wyświetl plik

@ -0,0 +1,6 @@
# Name, Type, SubType, Offset, Size, Flags
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, ota_0, 0x10000, 0x200000,
app1, app, ota_1, 0x210000,0x200000,
spiffs, data, spiffs, 0x410000,0xBE0000,
1 # Name Type SubType Offset Size Flags
2 nvs data nvs 0x9000 0x5000
3 otadata data ota 0xe000 0x2000
4 app0 app ota_0 0x10000 0x200000
5 app1 app ota_1 0x210000 0x200000
6 spiffs data spiffs 0x410000 0xBE0000

Wyświetl plik

@ -137,7 +137,9 @@ class MyExampleUsermod : public Usermod {
void readFromConfig(JsonObject& root) void readFromConfig(JsonObject& root)
{ {
JsonObject top = root["top"]; JsonObject top = root["top"];
userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot) if (!top.isNull()) {
userVar0 = top["great"] | 42; //The value right of the pipe "|" is the default value in case your setting was not present in cfg.json (e.g. first boot)
}
} }

Wyświetl plik

@ -801,7 +801,7 @@ class WS2812FX {
CRGBPalette16 currentPalette; CRGBPalette16 currentPalette;
CRGBPalette16 targetPalette; CRGBPalette16 targetPalette;
uint16_t _length, _lengthRaw, _virtualSegmentLength; uint16_t _length, _virtualSegmentLength;
uint16_t _rand16seed; uint16_t _rand16seed;
uint8_t _brightness; uint8_t _brightness;
uint16_t _usedSegmentData = 0; uint16_t _usedSegmentData = 0;

Wyświetl plik

@ -60,12 +60,15 @@
#define DEFAULT_LED_TYPE TYPE_WS2812_RGB #define DEFAULT_LED_TYPE TYPE_WS2812_RGB
#endif #endif
#if MAX_NUM_SEGMENTS < WLED_MAX_BUSSES
#error "Max segments must be at least max number of busses!"
#endif
//do not call this method from system context (network callback) //do not call this method from system context (network callback)
void WS2812FX::finalizeInit(uint16_t countPixels) void WS2812FX::finalizeInit(uint16_t countPixels)
{ {
RESET_RUNTIME; RESET_RUNTIME;
_length = countPixels; _length = countPixels;
_lengthRaw = _length;
//if busses failed to load, add default (FS issue...) //if busses failed to load, add default (FS issue...)
if (busses.getNumBusses() == 0) { if (busses.getNumBusses() == 0) {
@ -77,7 +80,7 @@ void WS2812FX::finalizeInit(uint16_t countPixels)
for (uint8_t i = 0; i < defNumBusses; i++) { for (uint8_t i = 0; i < defNumBusses; i++) {
uint8_t defPin[] = {defDataPins[i]}; uint8_t defPin[] = {defDataPins[i]};
uint16_t start = prevLen; uint16_t start = prevLen;
uint16_t count = _lengthRaw; uint16_t count = _length;
if (defNumBusses > 1 && defNumCounts) { if (defNumBusses > 1 && defNumCounts) {
count = defCounts[(i < defNumCounts) ? i : defNumCounts -1]; count = defCounts[(i < defNumCounts) ? i : defNumCounts -1];
} }
@ -89,22 +92,44 @@ void WS2812FX::finalizeInit(uint16_t countPixels)
deserializeMap(); deserializeMap();
//make segment 0 cover the entire strip uint16_t segStarts[MAX_NUM_SEGMENTS] = {0};
_segments[0].start = 0; uint16_t segStops [MAX_NUM_SEGMENTS] = {0};
_segments[0].stop = _length;
setBrightness(_brightness); setBrightness(_brightness);
#ifdef ESP8266 //TODO make sure segments are only refreshed when bus config actually changed (new settings page)
//make one segment per bus
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);
segStarts[s] = b->getStart();
segStops[s] = segStarts[s] + b->getLength();
//check for overlap with previous segments
for (uint8_t j = 0; j < s; j++) {
if (segStops[j] > segStarts[s] && segStarts[j] < segStops[s]) {
//segments overlap, merge
segStarts[j] = min(segStarts[s],segStarts[j]);
segStops [j] = max(segStops [s],segStops [j]); segStops[s] = 0;
s--;
}
}
s++;
#ifdef ESP8266
if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue; if ((!IS_DIGITAL(b->getType()) || IS_2PIN(b->getType()))) continue;
uint8_t pins[5]; uint8_t pins[5];
b->getPins(pins); b->getPins(pins);
BusDigital* bd = static_cast<BusDigital*>(b); BusDigital* bd = static_cast<BusDigital*>(b);
if (pins[0] == 3) bd->reinit(); if (pins[0] == 3) bd->reinit();
#endif
}
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) {
_segments[i].start = segStarts[i];
_segments[i].stop = segStops [i];
} }
#endif
} }
void WS2812FX::service() { void WS2812FX::service() {
@ -503,7 +528,7 @@ uint32_t WS2812FX::getPixelColor(uint16_t i)
if (i < customMappingSize) i = customMappingTable[i]; if (i < customMappingSize) i = customMappingTable[i];
if (i >= _lengthRaw) return 0; if (i >= _length) return 0;
return busses.getPixelColor(i); return busses.getPixelColor(i);
} }

Wyświetl plik

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2106200 #define VERSION 2106240
//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