From 84314cf921a8211ad657eede81a1521f420099ca Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 20 May 2022 11:22:49 +0200 Subject: [PATCH] Generalize pinmode for most digitalwrites --- tasmota/support.ino | 7 +------ tasmota/support_tasmota.ino | 14 ++------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index 7364a7230..6f0e39c35 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1327,14 +1327,9 @@ void SetPin(uint32_t lpin, uint32_t gpio) { } void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state) { - static uint64_t pinmode_init = 0; // Pins 0 to 63 !!! - if (PinUsed(gpio_pin, index)) { uint32_t pin = Pin(gpio_pin, index); - if (!bitRead(pinmode_init, pin)) { - pinMode(pin, OUTPUT); - bitSet(pinmode_init, pin); - } + pinMode(pin, OUTPUT); digitalWrite(pin, state &1); } } diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 53f0768e4..a362a91e5 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -2048,11 +2048,7 @@ void GpioInit(void) #endif // ESP8266 } - if (PinUsed(GPIO_HEARTBEAT)) { -// pinMode(Pin(GPIO_HEARTBEAT), OUTPUT); -// digitalWrite(Pin(GPIO_HEARTBEAT), TasmotaGlobal.heartbeat_inverted); - DigitalWrite(GPIO_HEARTBEAT, 0, TasmotaGlobal.heartbeat_inverted); - } + DigitalWrite(GPIO_HEARTBEAT, 0, TasmotaGlobal.heartbeat_inverted); // Digital input for (uint32_t i = 0; i < MAX_SWITCHES; i++) { @@ -2123,19 +2119,13 @@ void GpioInit(void) } else { #endif TasmotaGlobal.leds_present++; -// pinMode(Pin(GPIO_LED1, i), OUTPUT); -// digitalWrite(Pin(GPIO_LED1, i), bitRead(TasmotaGlobal.led_inverted, i)); DigitalWrite(GPIO_LED1, i, bitRead(TasmotaGlobal.led_inverted, i)); #ifdef USE_ARILUX_RF } #endif } } - if (PinUsed(GPIO_LEDLNK)) { -// pinMode(Pin(GPIO_LEDLNK), OUTPUT); -// digitalWrite(Pin(GPIO_LEDLNK), TasmotaGlobal.ledlnk_inverted); - DigitalWrite(GPIO_LEDLNK, 0, TasmotaGlobal.ledlnk_inverted); - } + DigitalWrite(GPIO_LEDLNK, 0, TasmotaGlobal.ledlnk_inverted); #ifdef USE_PWM_DIMMER if (PWM_DIMMER == TasmotaGlobal.module_type && PinUsed(GPIO_REL1)) { TasmotaGlobal.devices_present--; }