24 enum class ButtonType : uint8_t {
31 enum class OnLoadConfigType : uint8_t {
33 LOAD_BUTTON_SETUP_ONLY,
41 bool invertLogic =
false);
42 explicit Button(
int pin,
bool pullUp =
false,
bool invertLogic =
false);
47 void addAction(uint16_t action,
ActionHandler &client, uint16_t event,
48 bool alwaysEnabled =
false)
override;
49 void addAction(uint16_t action,
ActionHandler *client, uint16_t event,
50 bool alwaysEnabled =
false)
override;
51 void disableAction(int32_t action,
53 int32_t event)
override;
54 void enableAction(int32_t action,
56 int32_t event)
override;
58 void setHoldTime(
unsigned int timeMs);
59 void repeatOnHoldEvery(
unsigned int timeMs);
63 void setMulticlickTime(
unsigned int timeMs,
bool bistableButton =
false);
65 void setButtonType(
const ButtonType type);
66 bool isBistable()
const;
67 bool isMonostable()
const;
68 bool isMotionSensor()
const;
69 bool isCentral()
const;
72 bool disableActionsInConfigMode()
override;
73 void dontUseOnLoadConfig();
74 void setOnLoadConfigType(OnLoadConfigType type);
76 uint8_t getMaxMulticlickValue();
77 int8_t getButtonNumber()
const override;
78 void setButtonNumber(int8_t number);
80 void handleAction(
int event,
int action)
override;
84 void waitForRelease();
86 uint32_t getLastStateChange()
const;
88 void setAllowHoldOnPowerOn(
bool allow) { allowHoldOnPowerOn = allow; }
91 void evaluateMaxMulticlickValue();
94 void disableRepeatOnHold(uint32_t threshold = 0);
95 void enableRepeatOnHold();
96 const char *getButtonTypeName(ButtonType type)
const;
97 uint32_t lastStateChangeMs = 0;
98 uint16_t repeatOnHoldMs = 0;
99 uint16_t holdSend = 0;
100 uint16_t holdTimeMs = 0;
101 uint16_t multiclickTimeMs = 0;
102 ButtonType buttonType = ButtonType::MONOSTABLE;
103 enum OnLoadConfigType onLoadConfigType = OnLoadConfigType::LOAD_FULL_CONFIG;
105 uint8_t clickCounter = 0;
106 uint8_t maxMulticlickValueConfigured = 0;
107 bool repeatOnHoldEnabled =
false;
108 bool configButton =
false;
109 int8_t buttonNumber = -1;
110 bool disabled =
false;
111 bool allowHoldOnPowerOn =
false;
112 bool waitingForRelease =
false;
114 static int buttonCounter;