From 10b925acb7ec0a440491940bb3cde537da50c1d5 Mon Sep 17 00:00:00 2001 From: Damian Schneider Date: Wed, 23 Apr 2025 15:06:31 +0200 Subject: [PATCH] bugfix in enumerating buttons and busses (#4657) char value was changed from "55" to 'A' which is 65. need to deduct 10 so the result is 'A' if index counter is 10. --- wled00/set.cpp | 6 +++--- wled00/xml.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wled00/set.cpp b/wled00/set.cpp index c817f2553..725875023 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -146,7 +146,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) bool busesChanged = false; for (int s = 0; s < 36; s++) { // theoretical limit is 36 : "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" - int offset = s < 10 ? '0' : 'A'; + int offset = s < 10 ? '0' : 'A' - 10; char lp[4] = "L0"; lp[2] = offset+s; lp[3] = 0; //ascii 0-9 //strip data pin char lc[4] = "LC"; lc[2] = offset+s; lc[3] = 0; //strip length char co[4] = "CO"; co[2] = offset+s; co[3] = 0; //strip color order @@ -220,7 +220,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) // we will not bother with pre-allocating ColorOrderMappings vector BusManager::getColorOrderMap().reset(); for (int s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) { - int offset = s < 10 ? '0' : 'A'; + int offset = s < 10 ? '0' : 'A' - 10; char xs[4] = "XS"; xs[2] = offset+s; xs[3] = 0; //start LED char xc[4] = "XC"; xc[2] = offset+s; xc[3] = 0; //strip length char xo[4] = "XO"; xo[2] = offset+s; xo[3] = 0; //color order @@ -259,7 +259,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) disablePullUp = (bool)request->hasArg(F("IP")); touchThreshold = request->arg(F("TT")).toInt(); for (int i = 0; i < WLED_MAX_BUTTONS; i++) { - int offset = i < 10 ? '0' : 'A'; + int offset = i < 10 ? '0' : 'A' - 10; char bt[4] = "BT"; bt[2] = offset+i; bt[3] = 0; // button pin (use A,B,C,... if WLED_MAX_BUTTONS>10) char be[4] = "BE"; be[2] = offset+i; be[3] = 0; // button type (use A,B,C,... if WLED_MAX_BUTTONS>10) int hw_btn_pin = request->arg(bt).toInt(); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 19868d01d..de2f5590d 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -298,7 +298,7 @@ void getSettingsJS(byte subPage, Print& settingsScript) for (int s = 0; s < BusManager::getNumBusses(); s++) { const Bus* bus = BusManager::getBus(s); if (!bus || !bus->isOk()) break; // should not happen but for safety - int offset = s < 10 ? '0' : 'A'; + int offset = s < 10 ? '0' : 'A' - 10; char lp[4] = "L0"; lp[2] = offset+s; lp[3] = 0; //ascii 0-9 //strip data pin char lc[4] = "LC"; lc[2] = offset+s; lc[3] = 0; //strip length char co[4] = "CO"; co[2] = offset+s; co[3] = 0; //strip color order