Busses extend total configured LEDs if required (closes #2056 )
Fixed extra button pins defaulting to 0 on first boot
This commit is contained in:
parent
e04b965659
commit
5da47636cf
@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
### Builds after release 0.12.0
|
### Builds after release 0.12.0
|
||||||
|
|
||||||
|
#### Build 2107090
|
||||||
|
|
||||||
|
- Busses extend total configured LEDs if required
|
||||||
|
- Fixed extra button pins defaulting to 0 on first boot
|
||||||
|
|
||||||
#### Build 2107080
|
#### Build 2107080
|
||||||
|
|
||||||
- Made Peek use the main websocket connection instead of opening a second one
|
- Made Peek use the main websocket connection instead of opening a second one
|
||||||
|
@ -27,6 +27,18 @@ struct BusConfig {
|
|||||||
else if (type > 40 && type < 46) nPins = NUM_PWM_PINS(type);
|
else if (type > 40 && type < 46) nPins = NUM_PWM_PINS(type);
|
||||||
for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i];
|
for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//validates start and length and extends total if needed
|
||||||
|
bool adjustBounds(uint16_t& total) {
|
||||||
|
if (!count) count = 1;
|
||||||
|
if (count > MAX_LEDS_PER_BUS) count = MAX_LEDS_PER_BUS;
|
||||||
|
if (start >= MAX_LEDS) return false;
|
||||||
|
//limit length of strip if it would exceed total permissible LEDs
|
||||||
|
if (start + count > MAX_LEDS) count = MAX_LEDS - start;
|
||||||
|
//extend total count accordingly
|
||||||
|
if (start + count > total) total = start + count;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//parent class of BusDigital and BusPwm
|
//parent class of BusDigital and BusPwm
|
||||||
|
@ -85,6 +85,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
if (fromFS || !ins.isNull()) {
|
if (fromFS || !ins.isNull()) {
|
||||||
uint8_t s = 0; //bus iterator
|
uint8_t s = 0; //bus iterator
|
||||||
strip.isRgbw = false;
|
strip.isRgbw = false;
|
||||||
|
strip.isOffRefreshRequred = false;
|
||||||
busses.removeAll();
|
busses.removeAll();
|
||||||
uint32_t mem = 0;
|
uint32_t mem = 0;
|
||||||
for (JsonObject elm : ins) {
|
for (JsonObject elm : ins) {
|
||||||
@ -99,25 +100,23 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
if (i>4) break;
|
if (i>4) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t length = elm[F("len")];
|
uint16_t length = elm[F("len")] | 1;
|
||||||
if (length==0) continue;
|
|
||||||
uint8_t colorOrder = (int)elm[F("order")];
|
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)
|
|
||||||
uint8_t skipFirst = elm[F("skip")];
|
uint8_t skipFirst = elm[F("skip")];
|
||||||
uint16_t start = elm[F("start")] | 0;
|
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["type"] | TYPE_WS2812_RGB;
|
uint8_t ledType = elm["type"] | TYPE_WS2812_RGB;
|
||||||
bool reversed = elm["rev"];
|
bool reversed = elm["rev"];
|
||||||
//RGBW mode is enabled if at least one of the strips is RGBW
|
|
||||||
strip.isRgbw = (strip.isRgbw || BusManager::isRgbw(ledType));
|
|
||||||
//refresh is required to remain off if at least one of the strips requires the refresh.
|
|
||||||
strip.isOffRefreshRequred |= BusManager::isOffRefreshRequred(ledType);
|
|
||||||
s++;
|
|
||||||
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst);
|
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst);
|
||||||
mem += busses.memUsage(bc);
|
if (bc.adjustBounds(ledCount)) {
|
||||||
if (mem <= MAX_LED_MEMORY) busses.add(bc);
|
//RGBW mode is enabled if at least one of the strips is RGBW
|
||||||
|
strip.isRgbw = (strip.isRgbw || BusManager::isRgbw(ledType));
|
||||||
|
//refresh is required to remain off if at least one of the strips requires the refresh.
|
||||||
|
strip.isOffRefreshRequred |= BusManager::isOffRefreshRequred(ledType);
|
||||||
|
s++;
|
||||||
|
mem += busses.memUsage(bc);
|
||||||
|
if (mem <= MAX_LED_MEMORY) busses.add(bc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
strip.finalizeInit(ledCount);
|
strip.finalizeInit(ledCount);
|
||||||
}
|
}
|
||||||
@ -482,7 +481,7 @@ void serializeConfig() {
|
|||||||
|
|
||||||
JsonObject wifi = doc.createNestedObject("wifi");
|
JsonObject wifi = doc.createNestedObject("wifi");
|
||||||
wifi[F("sleep")] = !noWifiSleep;
|
wifi[F("sleep")] = !noWifiSleep;
|
||||||
wifi[F("phy")] = 1;
|
//wifi[F("phy")] = 1;
|
||||||
|
|
||||||
#ifdef WLED_USE_ETHERNET
|
#ifdef WLED_USE_ETHERNET
|
||||||
JsonObject ethernet = doc.createNestedObject("eth");
|
JsonObject ethernet = doc.createNestedObject("eth");
|
||||||
@ -520,28 +519,18 @@ void serializeConfig() {
|
|||||||
hw_btn["max"] = WLED_MAX_BUTTONS; // just information about max number of buttons (not actually used)
|
hw_btn["max"] = WLED_MAX_BUTTONS; // just information about max number of buttons (not actually used)
|
||||||
JsonArray hw_btn_ins = hw_btn.createNestedArray("ins");
|
JsonArray hw_btn_ins = hw_btn.createNestedArray("ins");
|
||||||
|
|
||||||
// there is always at least one button
|
// configuration for all buttons
|
||||||
JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject();
|
for (uint8_t i=0; i<WLED_MAX_BUTTONS; i++) {
|
||||||
hw_btn_ins_0["type"] = buttonType[0];
|
JsonObject hw_btn_ins_0 = hw_btn_ins.createNestedObject();
|
||||||
JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
|
|
||||||
hw_btn_ins_0_pin.add(btnPin[0]);
|
|
||||||
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0.createNestedArray("macros");
|
|
||||||
hw_btn_ins_0_macros.add(macroButton[0]);
|
|
||||||
hw_btn_ins_0_macros.add(macroLongPress[0]);
|
|
||||||
hw_btn_ins_0_macros.add(macroDoublePress[0]);
|
|
||||||
|
|
||||||
// additional buttons
|
|
||||||
for (uint8_t i=1; i<WLED_MAX_BUTTONS; i++) {
|
|
||||||
//if (btnPin[i]<0) continue;
|
|
||||||
hw_btn_ins_0 = hw_btn_ins.createNestedObject();
|
|
||||||
hw_btn_ins_0["type"] = buttonType[i];
|
hw_btn_ins_0["type"] = buttonType[i];
|
||||||
hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
|
JsonArray hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
|
||||||
hw_btn_ins_0_pin.add(btnPin[i]);
|
hw_btn_ins_0_pin.add(btnPin[i]);
|
||||||
hw_btn_ins_0_macros = hw_btn_ins_0.createNestedArray("macros");
|
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0.createNestedArray("macros");
|
||||||
hw_btn_ins_0_macros.add(macroButton[i]);
|
hw_btn_ins_0_macros.add(macroButton[i]);
|
||||||
hw_btn_ins_0_macros.add(macroLongPress[i]);
|
hw_btn_ins_0_macros.add(macroLongPress[i]);
|
||||||
hw_btn_ins_0_macros.add(macroDoublePress[i]);
|
hw_btn_ins_0_macros.add(macroDoublePress[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
hw_btn[F("tt")] = touchThreshold;
|
hw_btn[F("tt")] = touchThreshold;
|
||||||
hw_btn["mqtt"] = buttonPublishMqtt;
|
hw_btn["mqtt"] = buttonPublishMqtt;
|
||||||
|
|
||||||
|
@ -195,10 +195,17 @@ void WLED::loop()
|
|||||||
strip.isRgbw = false;
|
strip.isRgbw = false;
|
||||||
for (uint8_t i = 0; i < WLED_MAX_BUSSES; i++) {
|
for (uint8_t i = 0; i < WLED_MAX_BUSSES; i++) {
|
||||||
if (busConfigs[i] == nullptr) break;
|
if (busConfigs[i] == nullptr) break;
|
||||||
mem += busses.memUsage(*busConfigs[i]);
|
|
||||||
if (mem <= MAX_LED_MEMORY) busses.add(*busConfigs[i]);
|
if (busConfigs[i]->adjustBounds(ledCount)) {
|
||||||
//if (BusManager::isRgbw(busConfigs[i]->type)) strip.isRgbw = true;
|
mem += busses.memUsage(*busConfigs[i]);
|
||||||
strip.isRgbw = (strip.isRgbw || BusManager::isRgbw(busConfigs[i]->type));
|
if (mem <= MAX_LED_MEMORY) {
|
||||||
|
busses.add(*busConfigs[i]);
|
||||||
|
//RGBW mode is enabled if at least one of the strips is RGBW
|
||||||
|
strip.isRgbw = (strip.isRgbw || BusManager::isRgbw(busConfigs[i]->type));
|
||||||
|
//refresh is required to remain off if at least one of the strips requires the refresh.
|
||||||
|
strip.isOffRefreshRequred |= BusManager::isOffRefreshRequred(busConfigs[i]->type);
|
||||||
|
}
|
||||||
|
}
|
||||||
delete busConfigs[i]; busConfigs[i] = nullptr;
|
delete busConfigs[i]; busConfigs[i] = nullptr;
|
||||||
}
|
}
|
||||||
strip.finalizeInit(ledCount);
|
strip.finalizeInit(ledCount);
|
||||||
@ -284,6 +291,8 @@ void WLED::setup()
|
|||||||
pinManager.allocatePin(2);
|
pinManager.allocatePin(2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (uint8_t i=1; i<WLED_MAX_BUTTONS; i++) btnPin[i] = -1;
|
||||||
|
|
||||||
bool fsinit = false;
|
bool fsinit = false;
|
||||||
DEBUGFS_PRINTLN(F("Mount FS"));
|
DEBUGFS_PRINTLN(F("Mount FS"));
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2107080
|
#define VERSION 2107090
|
||||||
|
|
||||||
//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
|
||||||
|
Loading…
Reference in New Issue
Block a user