Skip to content

Commit

Permalink
fix default pin assignement for unassigned buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
PaoloTK committed Aug 11, 2024
1 parent db5e66a commit ec75191
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions wled00/wled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ void WLED::setup()

DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap());

// Set all button pins without an assigned type to -1.
// This is necessary because partially initializing an array fills the remaining elements with 0, which is a valid GPIO.
for (unsigned i=0; i<WLED_MAX_BUTTONS; i++) if (buttonType[i] == BTN_TYPE_NONE) btnPin[i] = -1;

bool fsinit = false;
DEBUGFS_PRINTLN(F("Mount FS"));
#ifdef ARDUINO_ARCH_ESP32
Expand Down
4 changes: 2 additions & 2 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,10 @@ WLED_GLOBAL char otaPass[33] _INIT(DEFAULT_OTA_PASS);

// Hardware and pin config
#ifndef BTNPIN
#define BTNPIN 0,-1
#define BTNPIN 0
#endif
#ifndef BTNTYPE
#define BTNTYPE BTN_TYPE_PUSH,BTN_TYPE_NONE
#define BTNTYPE BTN_TYPE_PUSH
#endif
#ifndef RLYPIN
WLED_GLOBAL int8_t rlyPin _INIT(-1);
Expand Down

0 comments on commit ec75191

Please sign in to comment.