update button handling

This commit is contained in:
2024-06-10 20:06:08 +02:00
parent 51a5e6fc28
commit b631a44abb
6 changed files with 133 additions and 52 deletions

View File

@ -8,8 +8,10 @@ class Buttons
public:
static constexpr uint8_t PRESSED = 0;
static constexpr uint8_t LONG_PRESSED = 1;
static constexpr uint8_t RELEASED = 2;
static constexpr uint8_t LONG_PRESSED = 1;
static constexpr uint8_t LONG_RELEASED= 3;
private:
volatile uint8_t * const pinReg = &PIND;
@ -31,7 +33,8 @@ void Buttons::tick()
{
if(readPin(pinReg, button[i]) == true)
{
if(buttonCount[i] > 2) _eventHandler(i, RELEASED, _userData);
if(buttonCount[i] >= 100) _eventHandler(i, LONG_RELEASED, _userData);
else if(buttonCount[i] >= 3)_eventHandler(i, RELEASED, _userData);
buttonCount[i] = 0;
}
else