mirror of
https://github.com/wled/WLED.git
synced 2025-07-12 13:26:33 +00:00
Bugfix saving PWM & button pins.
This commit is contained in:
parent
1952505e52
commit
cc0f1be5d2
@ -64,7 +64,7 @@
|
|||||||
void WS2812FX::finalizeInit(void)
|
void WS2812FX::finalizeInit(void)
|
||||||
{
|
{
|
||||||
RESET_RUNTIME;
|
RESET_RUNTIME;
|
||||||
isRgbw = false;
|
isRgbw = isOffRefreshRequred = false;
|
||||||
|
|
||||||
//if busses failed to load, add default (fresh install, FS issue, ...)
|
//if busses failed to load, add default (fresh install, FS issue, ...)
|
||||||
if (busses.getNumBusses() == 0) {
|
if (busses.getNumBusses() == 0) {
|
||||||
@ -90,7 +90,10 @@ void WS2812FX::finalizeInit(void)
|
|||||||
Bus *bus = busses.getBus(i);
|
Bus *bus = busses.getBus(i);
|
||||||
if (bus == nullptr) continue;
|
if (bus == nullptr) continue;
|
||||||
if (_length+bus->getLength() > MAX_LEDS) break;
|
if (_length+bus->getLength() > MAX_LEDS) break;
|
||||||
|
//RGBW mode is enabled if at least one of the strips is RGBW
|
||||||
isRgbw |= bus->isRgbw();
|
isRgbw |= bus->isRgbw();
|
||||||
|
//refresh is required to remain off if at least one of the strips requires the refresh.
|
||||||
|
isOffRefreshRequred |= BusManager::isOffRefreshRequred(bus->getType());
|
||||||
_length += bus->getLength();
|
_length += bus->getLength();
|
||||||
}
|
}
|
||||||
ledCount = _length; // or we can use busses.getTotalLength()
|
ledCount = _length; // or we can use busses.getTotalLength()
|
||||||
|
@ -30,7 +30,7 @@ struct BusConfig {
|
|||||||
count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip;
|
count = len; start = pstart; colorOrder = pcolorOrder; reversed = rev; skipAmount = skip;
|
||||||
uint8_t nPins = 1;
|
uint8_t nPins = 1;
|
||||||
if (type > 47) nPins = 2;
|
if (type > 47) nPins = 2;
|
||||||
else if (type > 41 && 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];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -222,14 +222,10 @@ class BusDigital : public Bus {
|
|||||||
class BusPwm : public Bus {
|
class BusPwm : public Bus {
|
||||||
public:
|
public:
|
||||||
BusPwm(BusConfig &bc) : Bus(bc.type, bc.start) {
|
BusPwm(BusConfig &bc) : Bus(bc.type, bc.start) {
|
||||||
|
_valid = false;
|
||||||
if (!IS_PWM(bc.type)) return;
|
if (!IS_PWM(bc.type)) return;
|
||||||
uint8_t numPins = NUM_PWM_PINS(bc.type);
|
uint8_t numPins = NUM_PWM_PINS(bc.type);
|
||||||
|
|
||||||
#ifdef WLED_DEBUG
|
|
||||||
Serial.print(F("Init: Number of pins="));
|
|
||||||
Serial.println(numPins);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
analogWriteRange(255); //same range as one RGB channel
|
analogWriteRange(255); //same range as one RGB channel
|
||||||
analogWriteFreq(WLED_PWM_FREQ);
|
analogWriteFreq(WLED_PWM_FREQ);
|
||||||
@ -243,8 +239,7 @@ class BusPwm : public Bus {
|
|||||||
for (uint8_t i = 0; i < numPins; i++) {
|
for (uint8_t i = 0; i < numPins; i++) {
|
||||||
_pins[i] = bc.pins[i];
|
_pins[i] = bc.pins[i];
|
||||||
if (!pinManager.allocatePin(_pins[i])) {
|
if (!pinManager.allocatePin(_pins[i])) {
|
||||||
//deallocatePins(); return;
|
_pins[i] = 255; return;
|
||||||
_pins[i] = 255; break;
|
|
||||||
}
|
}
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
pinMode(_pins[i], OUTPUT);
|
pinMode(_pins[i], OUTPUT);
|
||||||
@ -280,10 +275,12 @@ class BusPwm : public Bus {
|
|||||||
|
|
||||||
//does no index check
|
//does no index check
|
||||||
uint32_t getPixelColor(uint16_t pix) {
|
uint32_t getPixelColor(uint16_t pix) {
|
||||||
|
if (!_valid) return 0;
|
||||||
return ((_data[3] << 24) | (_data[0] << 16) | (_data[1] << 8) | (_data[2]));
|
return ((_data[3] << 24) | (_data[0] << 16) | (_data[1] << 8) | (_data[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void show() {
|
void show() {
|
||||||
|
if (!_valid) return;
|
||||||
uint8_t numPins = NUM_PWM_PINS(_type);
|
uint8_t numPins = NUM_PWM_PINS(_type);
|
||||||
for (uint8_t i = 0; i < numPins; i++) {
|
for (uint8_t i = 0; i < numPins; i++) {
|
||||||
uint8_t scaled = (_data[i] * _bri) / 255;
|
uint8_t scaled = (_data[i] * _bri) / 255;
|
||||||
|
@ -69,8 +69,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
noWifiSleep = !noWifiSleep;
|
noWifiSleep = !noWifiSleep;
|
||||||
//int wifi_phy = doc[F("wifi")][F("phy")]; //force phy mode n?
|
//int wifi_phy = doc[F("wifi")][F("phy")]; //force phy mode n?
|
||||||
|
|
||||||
DEBUG_PRINTLN(F(" Done network."));
|
|
||||||
|
|
||||||
JsonObject hw = doc[F("hw")];
|
JsonObject hw = doc[F("hw")];
|
||||||
|
|
||||||
// initialize LED pins and lengths prior to other HW
|
// initialize LED pins and lengths prior to other HW
|
||||||
@ -89,7 +87,6 @@ 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;
|
|
||||||
busses.removeAll();
|
busses.removeAll();
|
||||||
uint32_t mem = 0;
|
uint32_t mem = 0;
|
||||||
for (JsonObject elm : ins) {
|
for (JsonObject elm : ins) {
|
||||||
@ -112,24 +109,17 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
uint8_t skipFirst = elm[F("skip")];
|
uint8_t skipFirst = elm[F("skip")];
|
||||||
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
|
//if ((bool)elm[F("rgbw")]) SET_BIT(ledType,7); else UNSET_BIT(ledType,7); // hack bit 7 to indicate RGBW (as an override if necessary)
|
||||||
// if ((bool)elm[F("rgbw")]) SET_BIT(ledType,7); else UNSET_BIT(ledType,7); // hack bit 7 to indicate RGBW (as an override if necessary)
|
|
||||||
// strip.isRgbw |= (bool)elm[F("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++;
|
s++;
|
||||||
lC += length;
|
lC += length;
|
||||||
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst);
|
BusConfig bc = BusConfig(ledType, pins, start, length, colorOrder, reversed, skipFirst);
|
||||||
mem += BusManager::memUsage(bc);
|
mem += BusManager::memUsage(bc);
|
||||||
DEBUG_PRINT(F(" Adding bus no. "));
|
|
||||||
DEBUG_PRINTLN(busses.getNumBusses());
|
|
||||||
if (mem <= MAX_LED_MEMORY && busses.getNumBusses() <= WLED_MAX_BUSSES) busses.add(bc); // finalization will be done in WLED::beginStrip()
|
if (mem <= MAX_LED_MEMORY && busses.getNumBusses() <= WLED_MAX_BUSSES) busses.add(bc); // finalization will be done in WLED::beginStrip()
|
||||||
}
|
}
|
||||||
|
// finalization done in beginStrip()
|
||||||
//strip.finalizeInit();
|
//strip.finalizeInit();
|
||||||
}
|
}
|
||||||
if (lC > ledCount) ledCount = lC; // fix incorrect total length (honour analog setup)
|
if (lC > ledCount) ledCount = lC; // fix incorrect total length (honour analog setup)
|
||||||
DEBUG_PRINTLN(F(" Done LEDs."));
|
|
||||||
|
|
||||||
// read multiple button configuration
|
// read multiple button configuration
|
||||||
JsonArray hw_btn_ins = hw[F("btn")][F("ins")];
|
JsonArray hw_btn_ins = hw[F("btn")][F("ins")];
|
||||||
@ -138,14 +128,12 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
for (JsonObject btn : hw_btn_ins) {
|
for (JsonObject btn : hw_btn_ins) {
|
||||||
CJSON(buttonType[s], btn["type"]);
|
CJSON(buttonType[s], btn["type"]);
|
||||||
int8_t pin = btn[F("pin")][0] | -1;
|
int8_t pin = btn[F("pin")][0] | -1;
|
||||||
if (pin > -1) {
|
if (pin > -1 && pinManager.allocatePin(pin,false)) {
|
||||||
if (pinManager.allocatePin(pin,false)) {
|
|
||||||
btnPin[s] = pin;
|
btnPin[s] = pin;
|
||||||
pinMode(btnPin[s], INPUT_PULLUP);
|
pinMode(btnPin[s], INPUT_PULLUP);
|
||||||
} else {
|
} else {
|
||||||
btnPin[s] = -1;
|
btnPin[s] = -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
JsonArray hw_btn_ins_0_macros = btn[F("macros")];
|
JsonArray hw_btn_ins_0_macros = btn[F("macros")];
|
||||||
CJSON(macroButton[s], hw_btn_ins_0_macros[0]);
|
CJSON(macroButton[s], hw_btn_ins_0_macros[0]);
|
||||||
CJSON(macroLongPress[s],hw_btn_ins_0_macros[1]);
|
CJSON(macroLongPress[s],hw_btn_ins_0_macros[1]);
|
||||||
@ -172,26 +160,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CJSON(touchThreshold,hw[F("btn")][F("tt")]);
|
CJSON(touchThreshold,hw[F("btn")][F("tt")]);
|
||||||
DEBUG_PRINTLN(F(" Done buttons."));
|
|
||||||
|
|
||||||
/*
|
|
||||||
JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0];
|
|
||||||
CJSON(buttonType, hw_btn_ins_0["type"]);
|
|
||||||
int hw_btn_pin = hw_btn_ins_0[F("pin")][0] | -2; //-2 = not present in doc, keep current. -1 = disable
|
|
||||||
if (hw_btn_pin > -1) {
|
|
||||||
if (pinManager.allocatePin(hw_btn_pin,false)) {
|
|
||||||
btnPin = hw_btn_pin;
|
|
||||||
pinMode(btnPin, INPUT_PULLUP);
|
|
||||||
} else {
|
|
||||||
btnPin = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonArray hw_btn_ins_0_macros = hw_btn_ins_0[F("macros")];
|
|
||||||
CJSON(macroButton, hw_btn_ins_0_macros[0]);
|
|
||||||
CJSON(macroLongPress,hw_btn_ins_0_macros[1]);
|
|
||||||
CJSON(macroDoublePress, hw_btn_ins_0_macros[2]);
|
|
||||||
*/
|
|
||||||
#ifndef WLED_DISABLE_INFRARED
|
#ifndef WLED_DISABLE_INFRARED
|
||||||
int hw_ir_pin = hw["ir"]["pin"] | -2; // 4
|
int hw_ir_pin = hw["ir"]["pin"] | -2; // 4
|
||||||
if (hw_ir_pin > -2) {
|
if (hw_ir_pin > -2) {
|
||||||
@ -217,7 +186,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
if (relay.containsKey("rev")) {
|
if (relay.containsKey("rev")) {
|
||||||
rlyMde = !relay["rev"];
|
rlyMde = !relay["rev"];
|
||||||
}
|
}
|
||||||
DEBUG_PRINTLN(F(" Done HW."));
|
|
||||||
|
|
||||||
//int hw_status_pin = hw[F("status")]["pin"]; // -1
|
//int hw_status_pin = hw[F("status")]["pin"]; // -1
|
||||||
|
|
||||||
@ -570,7 +538,6 @@ void serializeConfig() {
|
|||||||
|
|
||||||
// additional buttons
|
// additional buttons
|
||||||
for (uint8_t i=1; i<WLED_MAX_BUTTONS; i++) {
|
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 = 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");
|
hw_btn_ins_0_pin = hw_btn_ins_0.createNestedArray("pin");
|
||||||
|
@ -85,7 +85,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
if (btnPin[s]>=0 && pinManager.isPinAllocated(btnPin[s]))
|
if (btnPin[s]>=0 && pinManager.isPinAllocated(btnPin[s]))
|
||||||
pinManager.deallocatePin(btnPin[s]);
|
pinManager.deallocatePin(btnPin[s]);
|
||||||
|
|
||||||
strip.isRgbw = false;
|
|
||||||
uint8_t colorOrder, type, skip;
|
uint8_t colorOrder, type, skip;
|
||||||
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};
|
||||||
@ -98,7 +97,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
char ls[4] = "LS"; ls[2] = 48+s; ls[3] = 0; //strip start LED
|
char ls[4] = "LS"; ls[2] = 48+s; ls[3] = 0; //strip start LED
|
||||||
char cv[4] = "CV"; cv[2] = 48+s; cv[3] = 0; //strip reverse
|
char cv[4] = "CV"; cv[2] = 48+s; cv[3] = 0; //strip reverse
|
||||||
char sl[4] = "SL"; sl[2] = 48+s; sl[3] = 0; //skip 1st LED
|
char sl[4] = "SL"; sl[2] = 48+s; sl[3] = 0; //skip 1st LED
|
||||||
// char ew[4] = "EW"; ew[2] = 48+s; ew[3] = 0; //strip RGBW override
|
//char ew[4] = "EW"; ew[2] = 48+s; ew[3] = 0; //strip RGBW override
|
||||||
if (!request->hasArg(lp)) {
|
if (!request->hasArg(lp)) {
|
||||||
DEBUG_PRINTLN(F("No data.")); break;
|
DEBUG_PRINTLN(F("No data.")); break;
|
||||||
}
|
}
|
||||||
@ -108,9 +107,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
pins[i] = (request->arg(lp).length() > 0) ? request->arg(lp).toInt() : 255;
|
pins[i] = (request->arg(lp).length() > 0) ? request->arg(lp).toInt() : 255;
|
||||||
}
|
}
|
||||||
type = request->arg(lt).toInt();
|
type = request->arg(lt).toInt();
|
||||||
// if (request->hasArg(ew)) SET_BIT(type,7); else UNSET_BIT(type,7); // hack bit 7 to indicate RGBW (as a LED type override if necessary)
|
//if (request->hasArg(ew)) SET_BIT(type,7); else UNSET_BIT(type,7); // hack bit 7 to indicate RGBW (as a LED type override if necessary)
|
||||||
// strip.isRgbw = strip.isRgbw || request->hasArg(ew);
|
|
||||||
strip.isRgbw = strip.isRgbw || Bus::isRgbw(type);
|
|
||||||
skip = request->hasArg(sl) ? LED_SKIP_AMOUNT : 0;
|
skip = request->hasArg(sl) ? LED_SKIP_AMOUNT : 0;
|
||||||
|
|
||||||
colorOrder = request->arg(co).toInt();
|
colorOrder = request->arg(co).toInt();
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// version code in format yymmddb (b = daily build)
|
// version code in format yymmddb (b = daily build)
|
||||||
#define VERSION 2105211
|
#define VERSION 2105212
|
||||||
|
|
||||||
//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…
x
Reference in New Issue
Block a user