AwesomeStudioPedal
A programmable, multi-profile foot controller for DAWs, score readers, and studio automation
Loading...
Searching...
No Matches
nrf52840/include/button.h
Go to the documentation of this file.
1#pragma once
2#include "i_button.h"
3#include <cstdint>
4
13class Button : public IButton
14{
15private:
16 uint8_t PIN;
17 bool isDebounced(unsigned long now) const;
18
19public:
20 volatile uint8_t pressCount = 0;
21 volatile bool awaitingRelease = false;
22 unsigned long lastDebounceTime = 0;
23 unsigned long debounceDelay = 100;
29 explicit Button(uint8_t PIN);
30
32 void setup() override;
33
39 void isr();
40
45 bool event() override;
46
48 void reset() override;
49};
ESP32 interrupt-driven button with debouncing.
void setup() override
Configures the pin as input with pull-up.
volatile bool awaitingRelease
True after press, until pin goes HIGH.
volatile uint8_t pressCount
Incremented by ISR, decremented by event()
Button(uint8_t PIN)
Constructs a Button for the given pin.
unsigned long lastDebounceTime
Timestamp of last accepted press.
void isr()
Interrupt service routine — call from a CHANGE ISR.
unsigned long debounceDelay
Debounce window in milliseconds.
void reset() override
Clears any pending press event.
bool event() override
Consumes and returns a pending press event.
Interface for interrupt-driven button input.
Definition i_button.h:12