4#ifndef SRC_SUPLA_CONTROL_SIMPLE_BUTTON_H_
5#define SRC_SUPLA_CONTROL_SIMPLE_BUTTON_H_
10#include "../element.h"
12#include "../local_action.h"
17enum StateResults { PRESSED, RELEASED, TO_PRESSED, TO_RELEASED };
23 ButtonState(
int pin,
bool pullUp,
bool invertLogic);
24 enum StateResults update();
25 enum StateResults getLastState()
const;
26 bool isPressedOrPending()
const;
27 void init(
int buttonNumber);
29 void setSwNoiseFilterDelay(
unsigned int newDelayMs);
30 void setDebounceDelay(
unsigned int newDelayMs);
36 int valueOnPress()
const;
40 uint16_t debounceDelayMs = 50;
41 uint16_t swNoiseFilterDelayMs = 20;
42 uint32_t debounceTimestampMs = 0;
43 uint32_t filterTimestampMs = 0;
44 int8_t newStatusCandidate = 0;
45 int8_t prevState = -1;
54 bool invertLogic =
false);
55 explicit SimpleButton(
int pin,
bool pullUp =
false,
bool invertLogic =
false);
59 void setSwNoiseFilterDelay(
unsigned int newDelayMs);
60 void setDebounceDelay(
unsigned int newDelayMs);
62 enum StateResults getLastState()
const;
69 virtual int8_t getButtonNumber()
const;
Base class for all elements of SuplaDevice.
Definition element.h:30
Definition local_action.h:87