Complete rewrite of Application
This commit is contained in:
31
Button.h
Normal file
31
Button.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user