diff --git a/tasmota/support.ino b/tasmota/support.ino index d58e19f0f..1b99b5cf1 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1338,7 +1338,7 @@ int ICACHE_RAM_ATTR Pin(uint32_t gpio, uint32_t index) { bool PinUsed(uint32_t gpio, uint32_t index = 0); bool PinUsed(uint32_t gpio, uint32_t index) { - return (Pin(gpio, index) > -1); + return (Pin(gpio, index) >= 0); } uint32_t GetPin(uint32_t lpin) { diff --git a/tasmota/support_rotary.ino b/tasmota/support_rotary.ino index 4f5eda5a6..06ca99f7c 100644 --- a/tasmota/support_rotary.ino +++ b/tasmota/support_rotary.ino @@ -168,7 +168,7 @@ void RotaryInit(void) { attachInterruptArg(Encoder[index].pina, RotaryIsrArg, &Encoder[index], FALLING); } } - Rotary.present |= (Encoder[index].pinb > -1); + Rotary.present |= (Encoder[index].pinb >= 0); } } @@ -213,7 +213,7 @@ void RotaryHandler(void) { #ifdef USE_LIGHT if (!Settings.flag4.rotary_uses_rules) { // SetOption98 - Use rules instead of light control - bool second_rotary = (Encoder[1].pinb > -1); + bool second_rotary = (Encoder[1].pinb >= 0); if (0 == index) { // Rotary1 if (button_pressed) { if (second_rotary) { // Color RGB diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 634405322..4dad93867 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -412,7 +412,7 @@ void SetLedLink(uint32_t state) if (-1 == led_pin) { // Legacy - LED1 is status SetLedPowerIdx(0, state); } - else if (led_pin > -1) { + else if (led_pin >= 0) { if (state) { state = 1; } digitalWrite(led_pin, (led_inv) ? !state : state); } diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index 560745b2d..5636b905a 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -1517,7 +1517,7 @@ void ZigbeeGlowPermitJoinLight(void) { // change the led state int led_pin = Pin(GPIO_LEDLNK); - if (led_pin > -1) { + if (led_pin >= 0) { analogWrite(led_pin, TasmotaGlobal.ledlnk_inverted ? 1023 - led_power : led_power); } } diff --git a/tasmota/xdsp_04_ili9341.ino b/tasmota/xdsp_04_ili9341.ino index c5087c290..54bb6e821 100644 --- a/tasmota/xdsp_04_ili9341.ino +++ b/tasmota/xdsp_04_ili9341.ino @@ -44,6 +44,7 @@ void ILI9341_InitDriver() #ifdef USE_M5STACK_CORE2 if (TasmotaGlobal.spi_enabled) { #else + // There are displays without CS if (PinUsed(GPIO_ILI9341_CS) || PinUsed(GPIO_ILI9341_DC) && (TasmotaGlobal.spi_enabled || TasmotaGlobal.soft_spi_enabled)) { #endif @@ -66,11 +67,8 @@ void ILI9341_InitDriver() #ifdef USE_M5STACK_CORE2 // fixed pins on m5stack core2 - ili9341_2 = new ILI9341_2(5, -2, 15, -2); + ili9341_2 = new ILI9341_2(5, -2, 15, -2); #else - - // There are displays without CS - // check for special case with 2 SPI busses (ESP32 bitcoin) if (TasmotaGlobal.soft_spi_enabled) { // Init renderer, may use hardware spi, however we use SSPI defintion because SD card uses SPI definition (2 spi busses) diff --git a/tasmota/xlgt_03_sm16716.ino b/tasmota/xlgt_03_sm16716.ino index 540b6d392..590aa2788 100644 --- a/tasmota/xlgt_03_sm16716.ino +++ b/tasmota/xlgt_03_sm16716.ino @@ -62,7 +62,7 @@ void SM16716_SendByte(uint8_t v) void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b) { - if (Sm16716.pin_sel > -1) { + if (Sm16716.pin_sel >= 0) { bool should_enable = (duty_r | duty_g | duty_b); if (!Sm16716.enabled && should_enable) { DEBUG_DRIVER_LOG(PSTR(D_LOG_SM16716 "turning color on")); @@ -104,7 +104,7 @@ bool SM16716_ModuleSelected(void) Sm16716.pin_dat = Pin(GPIO_SM16716_DAT); Sm16716.pin_sel = Pin(GPIO_SM16716_SEL); DEBUG_DRIVER_LOG(PSTR(D_LOG_SM16716 "ModuleSelected; clk_pin=%d, dat_pin=%d)"), Sm16716.pin_clk, Sm16716.pin_dat); - return (Sm16716.pin_clk > -1) && (Sm16716.pin_dat > -1); + return (Sm16716.pin_clk >= 0) && (Sm16716.pin_dat >= 0); } */ @@ -165,7 +165,7 @@ void Sm16716ModuleSelected(void) pinMode(Sm16716.pin_dat, OUTPUT); digitalWrite(Sm16716.pin_dat, LOW); - if (Sm16716.pin_sel > -1) { + if (Sm16716.pin_sel >= 0) { pinMode(Sm16716.pin_sel, OUTPUT); digitalWrite(Sm16716.pin_sel, LOW); // no need to call SM16716_Init here, it will be called after sel goes HIGH