mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Generalize pinmode for most digitalwrites
This commit is contained in:
parent
90a14ee518
commit
84314cf921
@ -1327,14 +1327,9 @@ void SetPin(uint32_t lpin, uint32_t 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)) {
|
if (PinUsed(gpio_pin, index)) {
|
||||||
uint32_t pin = Pin(gpio_pin, index);
|
uint32_t pin = Pin(gpio_pin, index);
|
||||||
if (!bitRead(pinmode_init, pin)) {
|
pinMode(pin, OUTPUT);
|
||||||
pinMode(pin, OUTPUT);
|
|
||||||
bitSet(pinmode_init, pin);
|
|
||||||
}
|
|
||||||
digitalWrite(pin, state &1);
|
digitalWrite(pin, state &1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2048,11 +2048,7 @@ void GpioInit(void)
|
|||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PinUsed(GPIO_HEARTBEAT)) {
|
DigitalWrite(GPIO_HEARTBEAT, 0, TasmotaGlobal.heartbeat_inverted);
|
||||||
// pinMode(Pin(GPIO_HEARTBEAT), OUTPUT);
|
|
||||||
// digitalWrite(Pin(GPIO_HEARTBEAT), TasmotaGlobal.heartbeat_inverted);
|
|
||||||
DigitalWrite(GPIO_HEARTBEAT, 0, TasmotaGlobal.heartbeat_inverted);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Digital input
|
// Digital input
|
||||||
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
|
for (uint32_t i = 0; i < MAX_SWITCHES; i++) {
|
||||||
@ -2123,19 +2119,13 @@ void GpioInit(void)
|
|||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
TasmotaGlobal.leds_present++;
|
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));
|
DigitalWrite(GPIO_LED1, i, bitRead(TasmotaGlobal.led_inverted, i));
|
||||||
#ifdef USE_ARILUX_RF
|
#ifdef USE_ARILUX_RF
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PinUsed(GPIO_LEDLNK)) {
|
DigitalWrite(GPIO_LEDLNK, 0, 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
|
#ifdef USE_PWM_DIMMER
|
||||||
if (PWM_DIMMER == TasmotaGlobal.module_type && PinUsed(GPIO_REL1)) { TasmotaGlobal.devices_present--; }
|
if (PWM_DIMMER == TasmotaGlobal.module_type && PinUsed(GPIO_REL1)) { TasmotaGlobal.devices_present--; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user