From 5d9be9a4d04131364f0dda1965e183d93d31b9da Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 27 Apr 2020 10:35:38 +0200 Subject: [PATCH] Fix pin handling part 1 --- tasmota/support.ino | 6 +++--- tasmota/support_tasmota.ino | 6 +++--- tasmota/xdrv_24_buzzer.ino | 6 +++--- tasmota/xdrv_35_pwm_dimmer.ino | 2 +- tasmota/xnrg_01_hlw8012.ino | 2 +- tasmota/xnrg_04_mcp39f501.ino | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index ebcca3294..09b37d874 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1100,10 +1100,10 @@ void SetPin(uint32_t lpin, uint32_t gpio) { */ } -void DigitalWrite(uint32_t gpio_pin, uint32_t state) +void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state) { - if (Pin(gpio_pin) < 99) { - digitalWrite(Pin(gpio_pin), state &1); + if (Pin(gpio_pin, index) < 99) { + digitalWrite(Pin(gpio_pin, index), state &1); } } diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 1d66b978c..85a3e1a04 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -166,7 +166,7 @@ void SetLatchingRelay(power_t lpower, uint32_t state) for (uint32_t i = 0; i < devices_present; i++) { uint32_t port = (i << 1) + ((latching_power >> i) &1); - DigitalWrite(GPIO_REL1 +port, bitRead(rel_inverted, port) ? !state : state); + DigitalWrite(GPIO_REL1, port, bitRead(rel_inverted, port) ? !state : state); } } @@ -228,7 +228,7 @@ void SetDevicePower(power_t rpower, uint32_t source) for (uint32_t i = 0; i < devices_present; i++) { power_t state = rpower &1; if (i < MAX_RELAYS) { - DigitalWrite(GPIO_REL1 +i, bitRead(rel_inverted, i) ? !state : state); + DigitalWrite(GPIO_REL1, i, bitRead(rel_inverted, i) ? !state : state); } rpower >>= 1; } @@ -351,7 +351,7 @@ void SetLedPowerIdx(uint32_t led, uint32_t state) } else { led_power &= (0xFF ^ mask); } - DigitalWrite(Pin(GPIO_LED1, led), bitRead(led_inverted, led) ? !state : state); + DigitalWrite(GPIO_LED1, led, bitRead(led_inverted, led) ? !state : state); } #ifdef USE_BUZZER if (led == 0) { diff --git a/tasmota/xdrv_24_buzzer.ino b/tasmota/xdrv_24_buzzer.ino index 45b570f85..7c522fa7e 100644 --- a/tasmota/xdrv_24_buzzer.ino +++ b/tasmota/xdrv_24_buzzer.ino @@ -41,7 +41,7 @@ struct BUZZER { void BuzzerOff(void) { - DigitalWrite(GPIO_BUZZER, Buzzer.inverted); // Buzzer Off + DigitalWrite(GPIO_BUZZER, 0, Buzzer.inverted); // Buzzer Off } //void BuzzerBeep(uint32_t count = 1, uint32_t on = 1, uint32_t off = 1, uint32_t tune = 0, uint32_t mode = 0); @@ -81,7 +81,7 @@ void BuzzerSetStateToLed(uint32_t state) { if (Buzzer.enable && (2 == Buzzer.mode)) { Buzzer.state = (state != 0); - DigitalWrite(GPIO_BUZZER, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state); + DigitalWrite(GPIO_BUZZER, 0, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state); } } @@ -140,7 +140,7 @@ void BuzzerEvery100mSec(void) Buzzer.duration = Buzzer.set[Buzzer.state]; } } - DigitalWrite(GPIO_BUZZER, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state); + DigitalWrite(GPIO_BUZZER, 0, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state); } else { Buzzer.enable = false; } diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index ac2ceaf55..429bc7421 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -165,7 +165,7 @@ void PWMDimmerSetPoweredOffLed(void) void PWMDimmerSetPower(void) { - DigitalWrite(GPIO_REL1, bitRead(rel_inverted, 0) ? !power : power); + DigitalWrite(GPIO_REL1, 0, bitRead(rel_inverted, 0) ? !power : power); PWMDimmerSetBrightnessLeds(0); PWMDimmerSetPoweredOffLed(); } diff --git a/tasmota/xnrg_01_hlw8012.ino b/tasmota/xnrg_01_hlw8012.ino index 4cbe111cd..04cd20847 100644 --- a/tasmota/xnrg_01_hlw8012.ino +++ b/tasmota/xnrg_01_hlw8012.ino @@ -143,7 +143,7 @@ void HlwEvery200ms(void) if (Hlw.cf1_timer >= 8) { Hlw.cf1_timer = 0; Hlw.select_ui_flag = (Hlw.select_ui_flag) ? false : true; - DigitalWrite(GPIO_NRG_SEL, Hlw.select_ui_flag); + DigitalWrite(GPIO_NRG_SEL, 0, Hlw.select_ui_flag); if (Hlw.cf1_pulse_counter) { cf1_pulse_length = Hlw.cf1_summed_pulse_length / Hlw.cf1_pulse_counter; diff --git a/tasmota/xnrg_04_mcp39f501.ino b/tasmota/xnrg_04_mcp39f501.ino index 92eec2013..3adbd0800 100644 --- a/tasmota/xnrg_04_mcp39f501.ino +++ b/tasmota/xnrg_04_mcp39f501.ino @@ -570,7 +570,7 @@ void McpSnsInit(void) } else { mcp_buffer = (char*)(malloc(MCP_BUFFER_SIZE)); } - DigitalWrite(GPIO_MCP39F5_RST, 1); // MCP enable + DigitalWrite(GPIO_MCP39F5_RST, 0, 1); // MCP enable } else { energy_flg = ENERGY_NONE; }