mirror of https://github.com/arendst/Tasmota.git
`FUNC_BUTTON_PRESSED` now contains `press_counter` encoded in `XdrvMailbox.command_code` (#21724)
This commit is contained in:
parent
a260d334d0
commit
243df3f2cf
|
@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
|
|||
- 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 and once per second (#21711)
|
||||
- Support for Sonoff POWCT Ring (#21131)
|
||||
- `FUNC_BUTTON_PRESSED` now contains `press_counter` encoded in `XdrvMailbox.command_code`
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ void ButtonHandler(void) {
|
|||
|
||||
XdrvMailbox.index = button_index;
|
||||
XdrvMailbox.payload = button;
|
||||
XdrvMailbox.command_code = Button.last_state[button_index];
|
||||
XdrvMailbox.command_code = (Button.last_state[button_index] & 0xFF) | ((Button.press_counter[button_index] & 0xFF) << 8);
|
||||
if (XdrvCall(FUNC_BUTTON_PRESSED)) {
|
||||
// Serviced
|
||||
}
|
||||
|
|
|
@ -952,10 +952,12 @@ bool Xdrv52(uint32_t function)
|
|||
// XdrvMailbox.index = button_index;
|
||||
// XdrvMailbox.payload = button;
|
||||
// XdrvMailbox.command_code = Button.last_state[button_index];
|
||||
if ((XdrvMailbox.payload != XdrvMailbox.command_code) || TimeReached(timer_last_button_sent)) { // fire event only when state changes
|
||||
uint8_t state = (XdrvMailbox.command_code & 0xFF);
|
||||
uint8_t multipress_state = (XdrvMailbox.command_code >> 8) & 0xFF;
|
||||
if ((XdrvMailbox.payload != state) || TimeReached(timer_last_button_sent)) { // fire event only when state changes
|
||||
timer_last_button_sent = millis() + 1000; // wait for 1 second
|
||||
result = callBerryEventDispatcher(PSTR("button_pressed"), nullptr,
|
||||
(XdrvMailbox.payload & 0xFF) << 16 | (XdrvMailbox.command_code & 0xFF) << 8 | (XdrvMailbox.index & 0xFF) ,
|
||||
(multipress_state & 0xFF) << 24 | (XdrvMailbox.payload & 0xFF) << 16 | (XdrvMailbox.command_code & 0xFF) << 8 | (XdrvMailbox.index & 0xFF) ,
|
||||
nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ bool ShellyProButton(void) {
|
|||
if (button_index > 2) { return false; } // Only support Up, Down, Ok
|
||||
|
||||
uint32_t button = XdrvMailbox.payload;
|
||||
uint32_t last_state = XdrvMailbox.command_code;
|
||||
uint32_t last_state = (XdrvMailbox.command_code & 0xFF);
|
||||
if ((PRESSED == button) && (NOT_PRESSED == last_state)) { // Button pressed
|
||||
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHP: Button %d pressed"), button_index +1);
|
||||
|
|
|
@ -307,7 +307,7 @@ bool ShellyProButton(void) {
|
|||
if (button_index > 2) { return false; } // Only support Up, Down, Ok
|
||||
|
||||
uint32_t button = XdrvMailbox.payload;
|
||||
uint32_t last_state = XdrvMailbox.command_code;
|
||||
uint32_t last_state = (XdrvMailbox.command_code & 0xFF);
|
||||
if ((PRESSED == button) && (NOT_PRESSED == last_state)) { // Button pressed
|
||||
|
||||
AddLog(LOG_LEVEL_DEBUG, PSTR("SHP: Button %d pressed"), button_index +1);
|
||||
|
|
Loading…
Reference in New Issue