Prep virtual button handler

This commit is contained in:
Theo Arends 2023-01-16 18:29:51 +01:00
parent 044606d8b8
commit e2c9a71c3b
2 changed files with 15 additions and 3 deletions

View File

@ -83,6 +83,14 @@ void ButtonTouchFlag(uint32_t button_bit) {
} }
#endif // ESP32 SOC_TOUCH_VERSION_1 or SOC_TOUCH_VERSION_2 #endif // ESP32 SOC_TOUCH_VERSION_1 or SOC_TOUCH_VERSION_2
uint32_t ButtonGetVirtualOffset(void) {
return Button.present;
}
void ButtonSetVirtual(uint32_t index, uint32_t state) {
Button.virtual_state[index] = state;
}
/*********************************************************************************************/ /*********************************************************************************************/
void ButtonProbe(void) { void ButtonProbe(void) {
@ -275,7 +283,7 @@ uint8_t ButtonSerial(uint8_t serial_in_byte) {
* SetOption73 (0) - Decouple button from relay and send just mqtt topic * SetOption73 (0) - Decouple button from relay and send just mqtt topic
\*********************************************************************************************/ \*********************************************************************************************/
void ButtonHandler(void) { void ButtonHandler(uint32_t mode) {
if (TasmotaGlobal.uptime < 4) { return; } // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit if (TasmotaGlobal.uptime < 4) { return; } // Block GPIO for 4 seconds after poweron to workaround Wemos D1 / Obi RTS circuit
uint8_t hold_time_extent = IMMINENT_RESET_FACTOR; // Extent hold time factor in case of iminnent Reset command uint8_t hold_time_extent = IMMINENT_RESET_FACTOR; // Extent hold time factor in case of iminnent Reset command
@ -300,7 +308,7 @@ void ButtonHandler(void) {
} }
} else } else
#endif // ESP8266 #endif // ESP8266
if (PinUsed(GPIO_KEY1, button_index)) { if (PinUsed(GPIO_KEY1, button_index) || (mode)) {
#if defined(SOC_TOUCH_VERSION_1) || defined(SOC_TOUCH_VERSION_2) #if defined(SOC_TOUCH_VERSION_1) || defined(SOC_TOUCH_VERSION_2)
if (bitRead(TouchButton.touch_mask, button_index) && bitRead(TouchButton.calibration, button_index +1)) { // Touch if (bitRead(TouchButton.touch_mask, button_index) && bitRead(TouchButton.calibration, button_index +1)) { // Touch
@ -528,7 +536,7 @@ void ButtonLoop(void) {
if (Button.present) { if (Button.present) {
if (TimeReached(Button.debounce)) { if (TimeReached(Button.debounce)) {
SetNextTimeInterval(Button.debounce, Settings->button_debounce); // ButtonDebounce (50) SetNextTimeInterval(Button.debounce, Settings->button_debounce); // ButtonDebounce (50)
ButtonHandler(); ButtonHandler(0);
} }
} }
} }

View File

@ -65,6 +65,10 @@ void SwitchPulldownFlag(uint32 switch_bit) {
bitSet(Switch.pulldown_mask, switch_bit); bitSet(Switch.pulldown_mask, switch_bit);
} }
uint32_t SwitchGetVirtualOffset(void) {
return Switch.present;
}
void SwitchSetVirtual(uint32_t index, uint32_t state) { void SwitchSetVirtual(uint32_t index, uint32_t state) {
Switch.virtual_state[index] = state; Switch.virtual_state[index] = state;
} }