Possible pin output toggle after power on

Possible pin output toggle after power on (#15630)
This commit is contained in:
Theo Arends 2022-05-19 18:02:05 +02:00
parent cc3fc2b0ac
commit 41b82fd076
4 changed files with 26 additions and 16 deletions

View File

@ -11,7 +11,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- Possible pin output toggle after power on (#15630)
### Removed

View File

@ -127,6 +127,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Improv initial or erase device installation failing to provide Configure WiFi option
- SCD40 start low power command [#15361](https://github.com/arendst/Tasmota/issues/15361)
- BL09xx negative power presentation [#15374](https://github.com/arendst/Tasmota/issues/15374)
- Possible pin output toggle after power on [#15630](https://github.com/arendst/Tasmota/issues/15630)
### Removed
- Arduino IDE support

View File

@ -1326,10 +1326,16 @@ void SetPin(uint32_t lpin, uint32_t gpio) {
TasmotaGlobal.gpio_pin[lpin] = gpio;
}
void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state)
{
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)) {
digitalWrite(Pin(gpio_pin, index), state &1);
uint32_t pin = Pin(gpio_pin, index);
if (!bitRead(pinmode_init, pin)) {
pinMode(pin, OUTPUT);
bitSet(pinmode_init, pin);
}
digitalWrite(pin, state &1);
}
}

View File

@ -2010,12 +2010,14 @@ void GpioInit(void)
uint32_t mpin = ValidPin(i, TasmotaGlobal.my_module.io[i]);
// AddLog(LOG_LEVEL_DEBUG, PSTR("INI: gpio pin %d, mpin %d"), i, mpin);
if (AGPIO(GPIO_OUTPUT_HI) == mpin) {
pinMode(i, OUTPUT);
digitalWrite(i, 1);
// pinMode(i, OUTPUT);
// digitalWrite(i, 1);
DigitalWrite(i, 0, 1);
}
else if (AGPIO(GPIO_OUTPUT_LO) == mpin) {
pinMode(i, OUTPUT);
digitalWrite(i, 0);
// pinMode(i, OUTPUT);
// digitalWrite(i, 0);
DigitalWrite(i, 0, 0);
}
/*
@ -2049,8 +2051,9 @@ void GpioInit(void)
}
if (PinUsed(GPIO_HEARTBEAT)) {
pinMode(Pin(GPIO_HEARTBEAT), OUTPUT);
digitalWrite(Pin(GPIO_HEARTBEAT), TasmotaGlobal.heartbeat_inverted);
// pinMode(Pin(GPIO_HEARTBEAT), OUTPUT);
// digitalWrite(Pin(GPIO_HEARTBEAT), TasmotaGlobal.heartbeat_inverted);
DigitalWrite(GPIO_HEARTBEAT, 0, TasmotaGlobal.heartbeat_inverted);
}
// Digital input
@ -2106,10 +2109,8 @@ void GpioInit(void)
for (uint32_t i = 0; i < MAX_RELAYS; i++) {
if (PinUsed(GPIO_REL1, i)) {
TasmotaGlobal.devices_present++;
pinMode(Pin(GPIO_REL1, i), OUTPUT);
#ifdef ESP8266
if (EXS_RELAY == TasmotaGlobal.module_type) {
digitalWrite(Pin(GPIO_REL1, i), bitRead(TasmotaGlobal.rel_inverted, i) ? 1 : 0);
if (i &1) { TasmotaGlobal.devices_present--; }
}
#endif // ESP8266
@ -2124,16 +2125,18 @@ void GpioInit(void)
} else {
#endif
TasmotaGlobal.leds_present++;
pinMode(Pin(GPIO_LED1, i), OUTPUT);
digitalWrite(Pin(GPIO_LED1, i), bitRead(TasmotaGlobal.led_inverted, i));
// 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);
// pinMode(Pin(GPIO_LEDLNK), OUTPUT);
// digitalWrite(Pin(GPIO_LEDLNK), TasmotaGlobal.ledlnk_inverted);
DigitalWrite(GPIO_LEDLNK, 0, TasmotaGlobal.ledlnk_inverted);
}
#ifdef USE_PWM_DIMMER