From b1b5261a83ec4215221328807103b40ebf8580d5 Mon Sep 17 00:00:00 2001 From: Paul C Diem Date: Sun, 16 Jan 2022 13:23:30 -0600 Subject: [PATCH] Fix millisecond comparisons --- tasmota/xdrv_35_pwm_dimmer.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasmota/xdrv_35_pwm_dimmer.ino b/tasmota/xdrv_35_pwm_dimmer.ino index 803751500..4c1c9d067 100644 --- a/tasmota/xdrv_35_pwm_dimmer.ino +++ b/tasmota/xdrv_35_pwm_dimmer.ino @@ -854,7 +854,8 @@ bool Xdrv35(uint8_t function) } // If hold time has arrived and no rule is enabled that handles the button hold, handle it. - else if (button_hold_time[button_index] <= now) { + else if ((int32_t)(now - button_hold_time[button_index]) >= 0) { + #ifdef USE_RULES Response_P(PSTR("{\"Button%u\":{\"State\":3}}"), button_index + 1); Rules.no_execute = true; @@ -908,7 +909,8 @@ bool Xdrv35(uint8_t function) case FUNC_ANY_KEY: { uint32_t state = (XdrvMailbox.payload >> 8) & 0xFF; // 0 = Off, 1 = On, 2 = Toggle, 3 = Hold, 10,11,12,13 and 14 for Button Multipress - if ((state == 2 || state == 10) && ignore_any_key_time < millis()) { + if ((state == 2 || state == 10) && (int32_t)(millis() - ignore_any_key_time) > 0) { + uint32_t button_index = (XdrvMailbox.payload & 0xFF) - 1; button_unprocessed[button_index] = false; PWMDimmerHandleButton(button_index, false);