Multipin appears to work

This commit is contained in:
cschwinne 2021-01-31 00:38:27 +01:00
parent 9518c5f2e4
commit f3aa8d368e
7 changed files with 44 additions and 50 deletions

View File

@ -2,6 +2,10 @@
### Development versions after 0.11.1 release ### Development versions after 0.11.1 release
#### Build 2101310
- First alpha configurable multipin
#### Build 2101130 #### Build 2101130
- Added color transitions for all segments and slots and for segment brightness - Added color transitions for all segments and slots and for segment brightness

View File

@ -62,7 +62,7 @@ void WS2812FX::finalizeInit(bool supportWhite, uint16_t countPixels, bool skipFi
_lengthRaw += LED_SKIP_AMOUNT; _lengthRaw += LED_SKIP_AMOUNT;
} }
//if busses failed to load (FS issue...) //if busses failed to load, add default (FS issue...)
if (busses.getNumBusses() == 0) { if (busses.getNumBusses() == 0) {
uint8_t defPin[] = {LEDPIN}; uint8_t defPin[] = {LEDPIN};
BusConfig defCfg = BusConfig(TYPE_WS2812_RGB, defPin, 0, _lengthRaw, COL_ORDER_GRB); BusConfig defCfg = BusConfig(TYPE_WS2812_RGB, defPin, 0, _lengthRaw, COL_ORDER_GRB);

View File

@ -12,50 +12,6 @@ void getStringFromJson(char* dest, const char* src, size_t len) {
if (src != nullptr) strlcpy(dest, src, len); if (src != nullptr) strlcpy(dest, src, len);
} }
//populates bus objects from instance JsonArray, called by deserializeConfig() and by doInitStrip
bool initBusInstances(JsonArray ins) {
uint8_t s = 0;
useRGBW = false;
busses.removeAll();
for (JsonObject elm : ins) {
if (s >= WLED_MAX_BUSSES) break;
uint8_t pins[5] = {255, 255, 255, 255, 255};
JsonArray pinArr = elm[F("pin")];
if (pinArr.size() == 0) continue;
pins[0] = pinArr[0];
uint8_t i = 0;
for (int p : pinArr) {
pins[i] = p;
i++;
if (i>4) break;
}
uint16_t length = elm[F("len")];
if (length==0) continue;
uint8_t colorOrder = (int)elm[F("order")];
//only use skip from the first strip (this shouldn't have been in ins obj. but remains here for compatibility)
if (s==0) skipFirstLed = elm[F("skip")];
uint16_t start = elm[F("start")] | 0;
if (start >= ledCount) continue;
//limit length of strip if it would exceed total configured LEDs
if (start + length > ledCount) length = ledCount - start;
uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB;
bool reversed = elm[F("rev")];
//RGBW mode is enabled if at least one of the strips is RGBW
useRGBW = (useRGBW || BusManager::isRgbw(ledType));
s++;
BusConfig bc = BusConfig(ledType, pins, start, ledCount, colorOrder, reversed);
busses.add(bc);
}
//if no bus inited successfully (empty cfg or invalid), init default
if (s==0) {
uint8_t defPin[] = {LEDPIN};
BusConfig defCfg = BusConfig(TYPE_WS2812_RGB, defPin, 0, ledCount, COL_ORDER_GRB);
busses.add(defCfg);
}
return s;
}
void deserializeConfig() { void deserializeConfig() {
bool fromeep = false; bool fromeep = false;
bool success = deserializeConfigSec(); bool success = deserializeConfigSec();
@ -142,8 +98,41 @@ void deserializeConfig() {
CJSON(strip.reverseMode, hw_led[F("rev")]); CJSON(strip.reverseMode, hw_led[F("rev")]);
CJSON(strip.rgbwMode, hw_led[F("rgbwm")]); CJSON(strip.rgbwMode, hw_led[F("rgbwm")]);
JsonVariant strVar = hw_led["ins"]; JsonArray ins = hw_led["ins"];
initBusInstances(strVar.as<JsonArray>()); uint8_t s = 0;
useRGBW = false;
busses.removeAll();
for (JsonObject elm : ins) {
if (s >= WLED_MAX_BUSSES) break;
uint8_t pins[5] = {255, 255, 255, 255, 255};
JsonArray pinArr = elm[F("pin")];
if (pinArr.size() == 0) continue;
pins[0] = pinArr[0];
uint8_t i = 0;
for (int p : pinArr) {
pins[i] = p;
i++;
if (i>4) break;
}
uint16_t length = elm[F("len")];
if (length==0) continue;
uint8_t colorOrder = (int)elm[F("order")];
//only use skip from the first strip (this shouldn't have been in ins obj. but remains here for compatibility)
if (s==0) skipFirstLed = elm[F("skip")];
uint16_t start = elm[F("start")] | 0;
if (start >= ledCount) continue;
//limit length of strip if it would exceed total configured LEDs
if (start + length > ledCount) length = ledCount - start;
uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB;
bool reversed = elm[F("rev")];
//RGBW mode is enabled if at least one of the strips is RGBW
useRGBW = (useRGBW || BusManager::isRgbw(ledType));
s++;
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed);
busses.add(bc);
}
strip.finalizeInit(useRGBW, ledCount, skipFirstLed);
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0]; JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
CJSON(buttonEnabled, hw_btn_ins_0[F("type")]); CJSON(buttonEnabled, hw_btn_ins_0[F("type")]);

View File

@ -26,7 +26,6 @@ void handleButton();
void handleIO(); void handleIO();
//cfg.cpp //cfg.cpp
bool initBusInstances(JsonArray ins);
void deserializeConfig(); void deserializeConfig();
bool deserializeConfigSec(); bool deserializeConfigSec();
void serializeConfig(); void serializeConfig();

View File

@ -402,7 +402,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
} }
#endif #endif
if (subPage != 6 || !doReboot) serializeConfig(); //do not save if factory reset if (subPage != 2 && (subPage != 6 || !doReboot)) serializeConfig(); //do not save if factory reset or LED settings (which are saved after LED re-init)
if (subPage == 4) alexaInit(); if (subPage == 4) alexaInit();
} }

View File

@ -204,6 +204,8 @@ void WLED::loop()
delete busConfigs[i]; busConfigs[i] = nullptr; delete busConfigs[i]; busConfigs[i] = nullptr;
} }
strip.finalizeInit(useRGBW, ledCount, skipFirstLed); strip.finalizeInit(useRGBW, ledCount, skipFirstLed);
yield();
serializeConfig();
} }
yield(); yield();

View File

@ -306,7 +306,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('v',lt,bus->getType()); sappend('v',lt,bus->getType());
sappend('v',co,bus->getColorOrder()); sappend('v',co,bus->getColorOrder());
sappend('v',ls,bus->getStart()); sappend('v',ls,bus->getStart());
sappend('c',ls,bus->reversed); sappend('c',cv,bus->reversed);
} }
sappend('v',SET_F("MA"),strip.ablMilliampsMax); sappend('v',SET_F("MA"),strip.ablMilliampsMax);
sappend('v',SET_F("LA"),strip.milliampsPerLed); sappend('v',SET_F("LA"),strip.milliampsPerLed);