Dev-Tools/HIB.h
Mathieu Maret 187dbd40af Possibility to handle multiple button
Hib should be instantiate on the heap (new Hib()) because of memory
overflow on the stack (c.f.
https://github.com/esp8266/Arduino/issues/2667)
2016-11-11 10:16:26 +01:00

25 lines
517 B
C++

#pragma once
#include "Arduino.h"
extern "C" {
#include "osapi.h"
}
// Human Interface Button
class HIB {
private:
ETSTimer timer;
unsigned long previousMillis;
unsigned long longPressMsec;
public:
uint8_t pin;
uint8_t initialState;
uint8_t state;
uint8_t debouncing;
HIB(uint8_t pin, uint8_t initialState, unsigned long longPressMsec = 5000);
void IRQ_handler();
void onButtonPressed();
void onButtonReleased();
void onLongButtonPressed();
void invertState();
};