Skip to content

Commit 2a766f6

Browse files
DedeHaiblazoncek
authored andcommitted
bugfix in enumerating buttons and busses (wled#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.
1 parent de65943 commit 2a766f6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

wled00/set.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
147147

148148
bool busesChanged = false;
149149
for (int s = 0; s < 36; s++) { // theoretical limit is 36 : "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
150-
int offset = s < 10 ? '0' : 'A';
150+
int offset = s < 10 ? '0' : 'A' - 10;
151151
char lp[4] = "L0"; lp[2] = offset+s; lp[3] = 0; //ascii 0-9 //strip data pin
152152
char lc[4] = "LC"; lc[2] = offset+s; lc[3] = 0; //strip length
153153
char co[4] = "CO"; co[2] = offset+s; co[3] = 0; //strip color order
@@ -221,7 +221,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
221221
// we will not bother with pre-allocating ColorOrderMappings vector
222222
BusManager::getColorOrderMap().reset();
223223
for (int s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) {
224-
int offset = s < 10 ? '0' : 'A';
224+
int offset = s < 10 ? '0' : 'A' - 10;
225225
char xs[4] = "XS"; xs[2] = offset+s; xs[3] = 0; //start LED
226226
char xc[4] = "XC"; xc[2] = offset+s; xc[3] = 0; //strip length
227227
char xo[4] = "XO"; xo[2] = offset+s; xo[3] = 0; //color order
@@ -260,7 +260,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
260260
disablePullUp = (bool)request->hasArg(F("IP"));
261261
touchThreshold = request->arg(F("TT")).toInt();
262262
for (int i = 0; i < WLED_MAX_BUTTONS; i++) {
263-
int offset = i < 10 ? '0' : 'A';
263+
int offset = i < 10 ? '0' : 'A' - 10;
264264
char bt[4] = "BT"; bt[2] = offset+i; bt[3] = 0; // button pin (use A,B,C,... if WLED_MAX_BUTTONS>10)
265265
char be[4] = "BE"; be[2] = offset+i; be[3] = 0; // button type (use A,B,C,... if WLED_MAX_BUTTONS>10)
266266
int hw_btn_pin = request->arg(bt).toInt();

wled00/xml.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void getSettingsJS(byte subPage, Print& settingsScript)
301301
for (size_t s = 0; s < BusManager::getNumBusses(); s++) {
302302
const Bus *bus = BusManager::getBus(s);
303303
if (!bus || !bus->isOk()) break; // should not happen but for safety
304-
int offset = s < 10 ? '0' : 'A';
304+
int offset = s < 10 ? '0' : 'A' - 10;
305305
char lp[4] = "L0"; lp[2] = offset+s; lp[3] = 0; //ascii 0-9 //strip data pin
306306
char lc[4] = "LC"; lc[2] = offset+s; lc[3] = 0; //strip length
307307
char co[4] = "CO"; co[2] = offset+s; co[3] = 0; //strip color order

0 commit comments

Comments
 (0)