mirror of
https://github.com/wled/WLED.git
synced 2025-07-14 06:16:36 +00:00
Merge pull request #4286 from blazoncek/xml-bugfix
xml comma bugfix + few string optimisations
This commit is contained in:
commit
a121f5b61b
@ -83,7 +83,7 @@ void appendGPIOinfo(Print& settingsScript) {
|
|||||||
// usermod pin reservations will become unnecessary when settings pages will read cfg.json directly
|
// usermod pin reservations will become unnecessary when settings pages will read cfg.json directly
|
||||||
if (requestJSONBufferLock(6)) {
|
if (requestJSONBufferLock(6)) {
|
||||||
// if we can't allocate JSON buffer ignore usermod pins
|
// if we can't allocate JSON buffer ignore usermod pins
|
||||||
JsonObject mods = pDoc->createNestedObject(F("um"));
|
JsonObject mods = pDoc->createNestedObject("um");
|
||||||
UsermodManager::addToConfig(mods);
|
UsermodManager::addToConfig(mods);
|
||||||
if (!mods.isNull()) fillUMPins(settingsScript, mods);
|
if (!mods.isNull()) fillUMPins(settingsScript, mods);
|
||||||
releaseJSONBufferLock();
|
releaseJSONBufferLock();
|
||||||
@ -91,35 +91,42 @@ void appendGPIOinfo(Print& settingsScript) {
|
|||||||
settingsScript.print(F("];"));
|
settingsScript.print(F("];"));
|
||||||
|
|
||||||
// add reserved (unusable) pins
|
// add reserved (unusable) pins
|
||||||
|
bool firstPin = true;
|
||||||
settingsScript.print(F("d.rsvd=["));
|
settingsScript.print(F("d.rsvd=["));
|
||||||
for (unsigned i = 0; i < WLED_NUM_PINS; i++) {
|
for (unsigned i = 0; i < WLED_NUM_PINS; i++) {
|
||||||
if (!PinManager::isPinOk(i, false)) { // include readonly pins
|
if (!PinManager::isPinOk(i, false)) { // include readonly pins
|
||||||
settingsScript.print(i); settingsScript.print(",");
|
if (!firstPin) settingsScript.print(',');
|
||||||
|
settingsScript.print(i);
|
||||||
|
firstPin = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef WLED_ENABLE_DMX
|
#ifdef WLED_ENABLE_DMX
|
||||||
settingsScript.print(F("2,")); // DMX hardcoded pin
|
if (!firstPin) settingsScript.print(',');
|
||||||
|
settingsScript.print(2); // DMX hardcoded pin
|
||||||
|
firstPin = false;
|
||||||
#endif
|
#endif
|
||||||
#if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST)
|
#if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST)
|
||||||
settingsScript.printf_P(PSTR(",%d"),hardwareTX); // debug output (TX) pin
|
if (!firstPin) settingsScript.print(',');
|
||||||
|
settingsScript.print(hardwareTX); // debug output (TX) pin
|
||||||
|
firstPin = false;
|
||||||
#endif
|
#endif
|
||||||
//Note: Using pin 3 (RX) disables Adalight / Serial JSON
|
|
||||||
#ifdef WLED_USE_ETHERNET
|
#ifdef WLED_USE_ETHERNET
|
||||||
if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) {
|
if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) {
|
||||||
for (unsigned p=0; p<WLED_ETH_RSVD_PINS_COUNT; p++) { settingsScript.printf(",%d", esp32_nonconfigurable_ethernet_pins[p].pin); }
|
if (!firstPin) settingsScript.print(',');
|
||||||
if (ethernetBoards[ethernetType].eth_power>=0) { settingsScript.printf(",%d", ethernetBoards[ethernetType].eth_power); }
|
for (unsigned p=0; p<WLED_ETH_RSVD_PINS_COUNT; p++) { settingsScript.printf("%d,",esp32_nonconfigurable_ethernet_pins[p].pin); }
|
||||||
if (ethernetBoards[ethernetType].eth_mdc>=0) { settingsScript.printf(",%d", ethernetBoards[ethernetType].eth_mdc); }
|
if (ethernetBoards[ethernetType].eth_power >= 0) { settingsScript.printf("%d,",ethernetBoards[ethernetType].eth_power); }
|
||||||
if (ethernetBoards[ethernetType].eth_mdio>=0) { settingsScript.printf(",%d", ethernetBoards[ethernetType].eth_mdio); }
|
if (ethernetBoards[ethernetType].eth_mdc >= 0) { settingsScript.printf("%d,",ethernetBoards[ethernetType].eth_mdc); }
|
||||||
switch (ethernetBoards[ethernetType].eth_clk_mode) {
|
if (ethernetBoards[ethernetType].eth_mdio >= 0) { settingsScript.printf("%d,",ethernetBoards[ethernetType].eth_mdio); }
|
||||||
|
switch (ethernetBoards[ethernetType].eth_clk_mode) {
|
||||||
case ETH_CLOCK_GPIO0_IN:
|
case ETH_CLOCK_GPIO0_IN:
|
||||||
case ETH_CLOCK_GPIO0_OUT:
|
case ETH_CLOCK_GPIO0_OUT:
|
||||||
settingsScript.print(F("0"));
|
settingsScript.print(0);
|
||||||
break;
|
break;
|
||||||
case ETH_CLOCK_GPIO16_OUT:
|
case ETH_CLOCK_GPIO16_OUT:
|
||||||
settingsScript.print(F("16"));
|
settingsScript.print(16);
|
||||||
break;
|
break;
|
||||||
case ETH_CLOCK_GPIO17_OUT:
|
case ETH_CLOCK_GPIO17_OUT:
|
||||||
settingsScript.print(F("17"));
|
settingsScript.print(17);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,11 +135,11 @@ void appendGPIOinfo(Print& settingsScript) {
|
|||||||
|
|
||||||
// add info for read-only GPIO
|
// add info for read-only GPIO
|
||||||
settingsScript.print(F("d.ro_gpio=["));
|
settingsScript.print(F("d.ro_gpio=["));
|
||||||
bool firstPin = true;
|
firstPin = true;
|
||||||
for (unsigned i = 0; i < WLED_NUM_PINS; i++) {
|
for (unsigned i = 0; i < WLED_NUM_PINS; i++) {
|
||||||
if (PinManager::isReadOnlyPin(i)) {
|
if (PinManager::isReadOnlyPin(i)) {
|
||||||
// No comma before the first pin
|
// No comma before the first pin
|
||||||
if (!firstPin) settingsScript.print(F(","));
|
if (!firstPin) settingsScript.print(',');
|
||||||
settingsScript.print(i);
|
settingsScript.print(i);
|
||||||
firstPin = false;
|
firstPin = false;
|
||||||
}
|
}
|
||||||
@ -140,9 +147,7 @@ void appendGPIOinfo(Print& settingsScript) {
|
|||||||
settingsScript.print(F("];"));
|
settingsScript.print(F("];"));
|
||||||
|
|
||||||
// add info about max. # of pins
|
// add info about max. # of pins
|
||||||
settingsScript.print(F("d.max_gpio="));
|
settingsScript.printf_P(PSTR("d.max_gpio=%d;"),WLED_NUM_PINS);
|
||||||
settingsScript.print(WLED_NUM_PINS);
|
|
||||||
settingsScript.print(F(";"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//get values for settings form in javascript
|
//get values for settings form in javascript
|
||||||
@ -152,6 +157,7 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
DEBUG_PRINTF_P(PSTR("settings resp %u\n"), (unsigned)subPage);
|
DEBUG_PRINTF_P(PSTR("settings resp %u\n"), (unsigned)subPage);
|
||||||
|
|
||||||
if (subPage <0 || subPage >10) return;
|
if (subPage <0 || subPage >10) return;
|
||||||
|
char nS[32];
|
||||||
|
|
||||||
if (subPage == SUBPAGE_MENU)
|
if (subPage == SUBPAGE_MENU)
|
||||||
{
|
{
|
||||||
@ -259,11 +265,9 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
|
|
||||||
if (subPage == SUBPAGE_LEDS)
|
if (subPage == SUBPAGE_LEDS)
|
||||||
{
|
{
|
||||||
char nS[32];
|
|
||||||
|
|
||||||
appendGPIOinfo(settingsScript);
|
appendGPIOinfo(settingsScript);
|
||||||
|
|
||||||
settingsScript.print(F("d.ledTypes=")); settingsScript.print(BusManager::getLEDTypesJSONString().c_str()); settingsScript.print(";");
|
settingsScript.printf_P(PSTR("d.ledTypes=%s;"), BusManager::getLEDTypesJSONString().c_str());
|
||||||
|
|
||||||
// set limits
|
// set limits
|
||||||
settingsScript.printf_P(PSTR("bLimits(%d,%d,%d,%d,%d,%d,%d,%d);"),
|
settingsScript.printf_P(PSTR("bLimits(%d,%d,%d,%d,%d,%d,%d,%d);"),
|
||||||
@ -399,7 +403,6 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
|
|
||||||
if (subPage == SUBPAGE_SYNC)
|
if (subPage == SUBPAGE_SYNC)
|
||||||
{
|
{
|
||||||
[[maybe_unused]] char nS[32];
|
|
||||||
printSetFormValue(settingsScript,PSTR("UP"),udpPort);
|
printSetFormValue(settingsScript,PSTR("UP"),udpPort);
|
||||||
printSetFormValue(settingsScript,PSTR("U2"),udpPort2);
|
printSetFormValue(settingsScript,PSTR("U2"),udpPort2);
|
||||||
#ifndef WLED_DISABLE_ESPNOW
|
#ifndef WLED_DISABLE_ESPNOW
|
||||||
@ -637,7 +640,7 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
ESP.getChipModel(),
|
ESP.getChipModel(),
|
||||||
#else
|
#else
|
||||||
F("esp8266"),
|
"esp8266",
|
||||||
#endif
|
#endif
|
||||||
VERSION);
|
VERSION);
|
||||||
|
|
||||||
@ -648,8 +651,7 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
{
|
{
|
||||||
printSetFormValue(settingsScript,PSTR("SOMP"),strip.isMatrix);
|
printSetFormValue(settingsScript,PSTR("SOMP"),strip.isMatrix);
|
||||||
#ifndef WLED_DISABLE_2D
|
#ifndef WLED_DISABLE_2D
|
||||||
settingsScript.printf_P(PSTR("maxPanels=%d;"),WLED_MAX_PANELS);
|
settingsScript.printf_P(PSTR("maxPanels=%d;resetPanels();"),WLED_MAX_PANELS);
|
||||||
settingsScript.print(F("resetPanels();"));
|
|
||||||
if (strip.isMatrix) {
|
if (strip.isMatrix) {
|
||||||
if(strip.panels>0){
|
if(strip.panels>0){
|
||||||
printSetFormValue(settingsScript,PSTR("PW"),strip.panel[0].width); //Set generator Width and Height to first panel size for convenience
|
printSetFormValue(settingsScript,PSTR("PW"),strip.panel[0].width); //Set generator Width and Height to first panel size for convenience
|
||||||
@ -658,12 +660,9 @@ void getSettingsJS(byte subPage, Print& settingsScript)
|
|||||||
printSetFormValue(settingsScript,PSTR("MPC"),strip.panels);
|
printSetFormValue(settingsScript,PSTR("MPC"),strip.panels);
|
||||||
// panels
|
// panels
|
||||||
for (unsigned i=0; i<strip.panels; i++) {
|
for (unsigned i=0; i<strip.panels; i++) {
|
||||||
char n[5];
|
settingsScript.printf_P(PSTR("addPanel(%d);"), i);
|
||||||
settingsScript.print(F("addPanel("));
|
|
||||||
settingsScript.print(itoa(i,n,10));
|
|
||||||
settingsScript.print(F(");"));
|
|
||||||
char pO[8] = { '\0' };
|
char pO[8] = { '\0' };
|
||||||
snprintf_P(pO, 7, PSTR("P%d"), i); // MAX_PANELS is 64 so pO will always only be 4 characters or less
|
snprintf_P(pO, 7, PSTR("P%d"), i); // WLED_MAX_PANELS is 18 so pO will always only be 4 characters or less
|
||||||
pO[7] = '\0';
|
pO[7] = '\0';
|
||||||
unsigned l = strlen(pO);
|
unsigned l = strlen(pO);
|
||||||
// create P0B, P1B, ..., P63B, etc for other PxxX
|
// create P0B, P1B, ..., P63B, etc for other PxxX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user