You've already forked M5StickCPlus2-UserDemo
mirror of
https://github.com/m5stack/M5StickCPlus2-UserDemo.git
synced 2026-05-20 11:06:31 -07:00
34 lines
566 B
C++
34 lines
566 B
C++
/*
|
|
Button - a small library for Arduino to handle button debouncing
|
|
|
|
MIT licensed.
|
|
*/
|
|
|
|
#ifndef Button_h
|
|
#define Button_h
|
|
#include "Arduino.h"
|
|
|
|
class Button
|
|
{
|
|
public:
|
|
Button(uint8_t pin, uint16_t debounce_ms = 100);
|
|
void begin();
|
|
bool read();
|
|
bool toggled();
|
|
bool pressed();
|
|
bool released();
|
|
bool has_changed();
|
|
|
|
const static bool PRESSED = LOW;
|
|
const static bool RELEASED = HIGH;
|
|
|
|
private:
|
|
uint8_t _pin;
|
|
uint16_t _delay;
|
|
bool _state;
|
|
uint32_t _ignore_until;
|
|
bool _has_changed;
|
|
};
|
|
|
|
#endif
|