2016-11-06 11:03:06 +01:00
|
|
|
#pragma once
|
|
|
|
#include "Arduino.h"
|
|
|
|
extern "C" {
|
|
|
|
#include "osapi.h"
|
|
|
|
}
|
2016-11-13 23:34:21 +01:00
|
|
|
|
2016-11-06 11:03:06 +01:00
|
|
|
// Human Interface Button
|
|
|
|
class HIB {
|
|
|
|
private:
|
2016-11-11 10:16:26 +01:00
|
|
|
ETSTimer timer;
|
|
|
|
unsigned long previousMillis;
|
|
|
|
unsigned long longPressMsec;
|
2016-11-13 23:34:21 +01:00
|
|
|
unsigned long shortPressMsec;
|
|
|
|
void onInternalButtonPressed();
|
|
|
|
void onInternalButtonReleased();
|
|
|
|
void onInternalLongButtonPressed();
|
|
|
|
void invertState();
|
|
|
|
void (* onButtonPressed)(uint8_t pin);
|
|
|
|
void (* onButtonReleased)(uint8_t pin);
|
|
|
|
void (* onLongButtonPressed)(uint8_t pin);
|
|
|
|
friend void __timerCallback(void *data);
|
2016-11-06 11:03:06 +01:00
|
|
|
public:
|
2016-11-11 10:16:26 +01:00
|
|
|
uint8_t pin;
|
|
|
|
uint8_t initialState;
|
|
|
|
uint8_t state;
|
|
|
|
uint8_t debouncing;
|
2016-11-13 23:34:21 +01:00
|
|
|
HIB(uint8_t pin, uint8_t initialState,
|
|
|
|
void (* onButtonPressed)(uint8_t pin) = NULL,
|
|
|
|
void (* onButtonReleased)(uint8_t pin) = NULL,
|
|
|
|
void (* onLongButtonPressed)(uint8_t pin) = NULL,
|
|
|
|
unsigned long longPressMsec = 5000, unsigned long shortPressMsec = 50);
|
2016-11-11 10:16:26 +01:00
|
|
|
void IRQ_handler();
|
2016-11-06 11:03:06 +01:00
|
|
|
};
|