Skip to content

Commit c850a8c

Browse files
committed
upstream compatibility: support I2CSDAPIN/I2CSCLPIN as alternatives to HW_PIN_SDA/HW_PIN_SCL
support I2C and SPI pin defines used by upstream WLED.
1 parent cc12261 commit c850a8c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

wled00/const.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,17 @@ static_assert( (MAX_LEDS_PER_BUS) <= (MAX_LEDS), "configuration error: MAX_LEDS_
615615
#define PIN_RETRY_COOLDOWN 3000 // time in ms after an incorrect attempt PIN and OTA pass will be rejected even if correct
616616
#define PIN_TIMEOUT 900000 // time in ms after which the PIN will be required again, 15 minutes
617617

618+
// WLEDMM upstream WLED compatibility: allow to over-override HW_PIN_SDA / HW_PIN_SCL with I2CDSAPIN/I2CSCLPIN
619+
// * WLEDMM uses HW_PIN_SDA / HW_PIN_SCL for default I2C init. Pins can be changed in usermod settings.
620+
// * The I2C bus driver is _not_ started by default on startup. Its initialized when the first usermod calls pinManager.joinWire().
621+
// * This approach improves UX (changing I2C pins does not always require a restart), and it simplifies usermod code because a UM only calls pinManager.joinWire() to attach itself to the I2C bus.
622+
#if defined(I2CSCLPIN) && !defined(HW_PIN_SCL)
623+
#define HW_PIN_SCL I2CSCLPIN
624+
#endif
625+
#if defined(I2CSDAPIN) && !defined(HW_PIN_SDA)
626+
#define HW_PIN_SDA I2CSDAPIN
627+
#endif
628+
618629
// HW_PIN_SCL & HW_PIN_SDA are used for information in usermods settings page and usermods themselves
619630
// which GPIO pins are actually used in a hardware layout (controller board)
620631
//WLEDMM: unchangeable pins are not treated here by undef them, but elsewhere in the code
@@ -626,6 +637,17 @@ static_assert( (MAX_LEDS_PER_BUS) <= (MAX_LEDS), "configuration error: MAX_LEDS_
626637
#define HW_PIN_SDA -1 //WLEDMM if not defined, -1 will be used (not SDA/21) (also for esp8266?)
627638
#endif
628639

640+
// WLEDMM upstream WLED compatibility: allow to over-override SPI pins with SPISCLKPIN/SPIMOSIPIN/SPIMISOPIN
641+
#if defined(SPISCLKPIN) && !defined(HW_PIN_CLOCKSPI)
642+
#define HW_PIN_CLOCKSPI SPISCLKPIN
643+
#endif
644+
#if defined(SPIMOSIPIN) && !defined(HW_PIN_MOSISPI)
645+
#define HW_PIN_MOSISPI SPIMOSIPIN
646+
#endif
647+
#if defined(SPIMISOPIN) && !defined(HW_PIN_MISOSPI)
648+
#define HW_PIN_MISOSPI SPIMISOPIN
649+
#endif
650+
629651
// HW_PIN_SCLKSPI & HW_PIN_MOSISPI & HW_PIN_MISOSPI are used for information in usermods settings page and usermods themselves
630652
// which GPIO pins are actually used in a hardware layout (controller board)
631653
//WLEDMM: unchangeable pins are not treated here by undef them, but elsewhere in the code

0 commit comments

Comments
 (0)