single iot-button with a range of long-hold intervals for different modes
Posted: Sat Feb 10, 2024 1:29 pm
I have a use case but it isn't clear if this is something iot-button can accommodate directly.
What I'd like is to use long holds to enable selecting multiple actions on a single button.
For example if the user presses the button there is a beep, if they continue to hold for 5 seconds I'd like to beep and flash, holds for 10 seconds, two beeps and two flashes etc. If they release from t0 -> 4.99 seconds they get 'action 1', if they release from 5 seconds to 9.99s they get 'action 2', and from 10 seconds on if they release they get 'action 3'.
Is this possible by setting and adjusting the long hold duration after the long hold callback has expired?
I'm new to iot-button and its unclear whether I should try to assign multiple iot-button instances to the same gpio with different hold durations to implement this instead.
What I'd like is to use long holds to enable selecting multiple actions on a single button.
For example if the user presses the button there is a beep, if they continue to hold for 5 seconds I'd like to beep and flash, holds for 10 seconds, two beeps and two flashes etc. If they release from t0 -> 4.99 seconds they get 'action 1', if they release from 5 seconds to 9.99s they get 'action 2', and from 10 seconds on if they release they get 'action 3'.
Is this possible by setting and adjusting the long hold duration after the long hold callback has expired?
I'm new to iot-button and its unclear whether I should try to assign multiple iot-button instances to the same gpio with different hold durations to implement this instead.