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 void init(
int buttonNumber);
28 void setSwNoiseFilterDelay(
unsigned int newDelayMs);
29 void setDebounceDelay(
unsigned int newDelayMs);
35 int valueOnPress()
const;
39 uint16_t debounceDelayMs = 50;
40 uint16_t swNoiseFilterDelayMs = 20;
41 uint32_t debounceTimestampMs = 0;
42 uint32_t filterTimestampMs = 0;
43 int8_t newStatusCandidate = 0;
44 int8_t prevState = -1;
53 bool invertLogic =
false);
54 explicit SimpleButton(
int pin,
bool pullUp =
false,
bool invertLogic =
false);
58 void setSwNoiseFilterDelay(
unsigned int newDelayMs);
59 void setDebounceDelay(
unsigned int newDelayMs);
61 enum StateResults getLastState()
const;
68 virtual int8_t getButtonNumber()
const;
Base class for all elements of SuplaDevice.
Definition element.h:27
Definition local_action.h:42