31 lines
446 B
C++
31 lines
446 B
C++
#ifndef BUTTON_H
|
|
#define BUTTON_H
|
|
|
|
#include <Arduino.h>
|
|
|
|
class Button {
|
|
private:
|
|
uint8_t pin;
|
|
|
|
bool stableState;
|
|
bool lastReading;
|
|
bool prevStableState;
|
|
|
|
unsigned long lastDebounceTime;
|
|
const unsigned long debounceDelay = 50;
|
|
|
|
unsigned long pressStart;
|
|
|
|
public:
|
|
Button(uint8_t pin);
|
|
|
|
void begin();
|
|
void update(unsigned long now);
|
|
|
|
bool pressed();
|
|
bool released();
|
|
bool isDown();
|
|
bool held(unsigned long ms);
|
|
};
|
|
|
|
#endif |