evert-arias / EasyButton

Arduino library for debouncing momentary contact switches, detect press, release, long press and sequences with event definitions and callbacks.
https://easybtn.earias.me
MIT License
447 stars 62 forks source link

Enhancement: Periodic callback when button is held down #72

Open fastbike opened 1 year ago

fastbike commented 1 year ago

My use case is for a light switch that normally functions as a momentary switch, but acts as a dim up/dim down switch when it is held for more than 250ms.

So to achieve this I have attached a function for the onPressedFor callback



I would then like another function to be called back every 50 ms so the lighting can be ramped up or down
````    powerButton.onPresseContinuesr(50, keepDimming); // notify the dimmer to move down a level

I have made some changes to a fork of the code. Are you interested in reviewing them for a pull request ?
fastbike commented 1 year ago

You can see my changes here, feel free to use https://github.com/fastbike/EasyButton/commit/ed3ad1022b2044c51145c139fcd420070052d77d