mirror of https://github.com/arendst/Tasmota.git
Berry `FUNC_BUTTON_MULTI_PRESSED` event and make `FUNC_BUTTON_PRESSED` called only on state changes (#21709)
This commit is contained in:
parent
65588b8126
commit
6842b53425
|
@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Berry `tasmota.rtc("config_time")` (#21698)
|
||||
- Berry `math.min()` and `math.max()` (#21705)
|
||||
- Berry `FUNC_ANY_KEY` event calling `any_key()` (#21708)
|
||||
- Berry `FUNC_BUTTON_MULTI_PRESSED` event and make `FUNC_BUTTON_PRESSED` called only on state changes
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
|
|
@ -946,6 +946,23 @@ bool Xdrv52(uint32_t function)
|
|||
case FUNC_SET_DEVICE_POWER:
|
||||
result = callBerryEventDispatcher(PSTR("set_power_handler"), nullptr, XdrvMailbox.index, nullptr);
|
||||
break;
|
||||
case FUNC_BUTTON_PRESSED:
|
||||
// XdrvMailbox.index = button_index;
|
||||
// XdrvMailbox.payload = button;
|
||||
// XdrvMailbox.command_code = Button.last_state[button_index];
|
||||
if (XdrvMailbox.payload != XdrvMailbox.command_code) { // fire event only when state changes
|
||||
result = callBerryEventDispatcher(PSTR("button_pressed"), nullptr,
|
||||
(XdrvMailbox.payload & 0xFF) << 16 | (XdrvMailbox.command_code & 0xFF) << 8 | (XdrvMailbox.index & 0xFF) ,
|
||||
nullptr);
|
||||
}
|
||||
break;
|
||||
case FUNC_BUTTON_MULTI_PRESSED:
|
||||
// XdrvMailbox.index = button_index;
|
||||
// XdrvMailbox.payload = Button.press_counter[button_index];
|
||||
result = callBerryEventDispatcher(PSTR("button_multi_pressed"), nullptr,
|
||||
(XdrvMailbox.payload & 0xFF) << 8 | (XdrvMailbox.index & 0xFF) ,
|
||||
nullptr);
|
||||
break;
|
||||
case FUNC_ANY_KEY:
|
||||
// XdrvMailbox.payload = device_save << 24 | key << 16 | state << 8 | device;
|
||||
// key 0 = KEY_BUTTON = button_topic
|
||||
|
@ -1014,10 +1031,6 @@ bool Xdrv52(uint32_t function)
|
|||
callBerryEventDispatcher(PSTR("after_teleperiod"), nullptr, 0, nullptr);
|
||||
break;
|
||||
|
||||
case FUNC_BUTTON_PRESSED:
|
||||
callBerryEventDispatcher(PSTR("button_pressed"), nullptr, 0, nullptr);
|
||||
break;
|
||||
|
||||
case FUNC_ACTIVE:
|
||||
result = true;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue