From ae4ec4325d05c1c926f79395cb91c3b625404d31 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 27 Apr 2020 17:16:52 +0200 Subject: [PATCH] Change pin handling part 5 --- tasmota/support_command.ino | 6 +++--- tasmota/support_tasmota.ino | 6 +++--- tasmota/xdrv_36_keeloq.ino | 2 +- tasmota/xnrg_01_hlw8012.ino | 6 +++--- tasmota/xsns_18_pms5003.ino | 2 +- tasmota/xsns_22_sr04.ino | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index cc8bb92ae..01c227f36 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -1694,7 +1694,7 @@ void CmndAltitude(void) void CmndLedPower(void) { if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_LEDS)) { - if (99 == Pin(GPIO_LEDLNK)) { XdrvMailbox.index = 1; } + if (!PinUsed(GPIO_LEDLNK)) { XdrvMailbox.index = 1; } if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 2)) { Settings.ledstate &= 8; // Disable power control uint32_t mask = 1 << (XdrvMailbox.index -1); // Led to control @@ -1713,14 +1713,14 @@ void CmndLedPower(void) break; } blinks = 0; - if (99 == Pin(GPIO_LEDLNK)) { + if (!PinUsed(GPIO_LEDLNK)) { SetLedPower(Settings.ledstate &8); } else { SetLedPowerIdx(XdrvMailbox.index -1, (led_power & mask)); } } bool state = bitRead(led_power, XdrvMailbox.index -1); - if (99 == Pin(GPIO_LEDLNK)) { + if (!PinUsed(GPIO_LEDLNK)) { state = bitRead(Settings.ledstate, 3); } ResponseCmndIdxChar(GetStateText(state)); diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 1f2ad385c..a6a293ae3 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -338,7 +338,7 @@ void SetPowerOnState(void) void SetLedPowerIdx(uint32_t led, uint32_t state) { - if ((99 == Pin(GPIO_LEDLNK)) && (0 == led)) { // Legacy - LED1 is link led only if LED2 is present + if (!PinUsed(GPIO_LEDLNK) && (0 == led)) { // Legacy - LED1 is link led only if LED2 is present if (PinUsed(GPIO_LED1, 1)) { led = 1; } @@ -362,7 +362,7 @@ void SetLedPowerIdx(uint32_t led, uint32_t state) void SetLedPower(uint32_t state) { - if (99 == Pin(GPIO_LEDLNK)) { // Legacy - Only use LED1 and/or LED2 + if (!PinUsed(GPIO_LEDLNK)) { // Legacy - Only use LED1 and/or LED2 SetLedPowerIdx(0, state); } else { power_t mask = 1; @@ -1534,7 +1534,7 @@ void GpioInit(void) for (uint32_t i = 0; i < MAX_LEDS; i++) { if (PinUsed(GPIO_LED1, i)) { #ifdef USE_ARILUX_RF - if ((3 == i) && (leds_present < 2) && (99 == Pin(GPIO_ARIRFSEL))) { + if ((3 == i) && (leds_present < 2) && !PinUsed(GPIO_ARIRFSEL)) { SetPin(Pin(GPIO_LED4), GPIO_ARIRFSEL); // Legacy support where LED4 was Arilux RF enable SetPin(99, GPIO_LED4); } else { diff --git a/tasmota/xdrv_36_keeloq.ino b/tasmota/xdrv_36_keeloq.ino index 75e3e6167..c271cf3f7 100644 --- a/tasmota/xdrv_36_keeloq.ino +++ b/tasmota/xdrv_36_keeloq.ino @@ -266,7 +266,7 @@ void KeeloqInit() \*********************************************************************************************/ bool Xdrv36(uint8_t function) { - if ((99 == Pin(GPIO_CC1101_GDO0)) || (99 == Pin(GPIO_CC1101_GDO2))) { return false; } + if (!PinUsed(GPIO_CC1101_GDO0) || !PinUsed(GPIO_CC1101_GDO2)) { return false; } bool result = false; diff --git a/tasmota/xnrg_01_hlw8012.ino b/tasmota/xnrg_01_hlw8012.ino index a1e67ecfc..12a10abb6 100644 --- a/tasmota/xnrg_01_hlw8012.ino +++ b/tasmota/xnrg_01_hlw8012.ino @@ -254,7 +254,7 @@ void HlwDrvInit(void) Hlw.model_type = 1; // HJL-01/BL0937 } - if (PinUsed(GPIO_HLW_CF)) { // HLW8012 or HJL-01 based device Power monitor + if (PinUsed(GPIO_HLW_CF)) { // HLW8012 or HJL-01 based device Power monitor Hlw.ui_flag = true; // Voltage on high if (PinUsed(GPIO_NRG_SEL_INV)) { @@ -263,8 +263,8 @@ void HlwDrvInit(void) Hlw.ui_flag = false; // Voltage on low } - if (PinUsed(GPIO_NRG_CF1)) { // Voltage and/or Current monitor - if (99 == Pin(GPIO_NRG_SEL)) { // Voltage and/or Current selector + if (PinUsed(GPIO_NRG_CF1)) { // Voltage and/or Current monitor + if (!PinUsed(GPIO_NRG_SEL)) { // Voltage and/or Current selector Energy.current_available = false; // Assume Voltage } } else { diff --git a/tasmota/xsns_18_pms5003.ino b/tasmota/xsns_18_pms5003.ino index dbac02936..d54527ddc 100644 --- a/tasmota/xsns_18_pms5003.ino +++ b/tasmota/xsns_18_pms5003.ino @@ -244,7 +244,7 @@ void PmsInit(void) if (PmsSerial->begin(9600)) { if (PmsSerial->hardwareSerial()) { ClaimSerial(); } - if (99 == Pin(GPIO_PMS5003_TX)) { // setting interval not supported if TX pin not connected + if (!PinUsed(GPIO_PMS5003_TX)) { // setting interval not supported if TX pin not connected Settings.pms_wake_interval = 0; Pms.ready = 1; } diff --git a/tasmota/xsns_22_sr04.ino b/tasmota/xsns_22_sr04.ino index 116729f66..187a67c3f 100644 --- a/tasmota/xsns_22_sr04.ino +++ b/tasmota/xsns_22_sr04.ino @@ -40,7 +40,7 @@ TasmotaSerial* sonar_serial = nullptr; uint8_t Sr04TModeDetect(void) { sr04_type = 0; - if (99 == Pin(GPIO_SR04_ECHO)) { return sr04_type; } + if (!PinUsed(GPIO_SR04_ECHO)) { return sr04_type; } int sr04_echo_pin = Pin(GPIO_SR04_ECHO); int sr04_trig_pin = (PinUsed(GPIO_SR04_TRIG)) ? Pin(GPIO_SR04_TRIG) : Pin(GPIO_SR04_ECHO); // if GPIO_SR04_TRIG is not configured use single PIN mode with GPIO_SR04_ECHO only