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) {
89 runtimeFlags.allowHoldOnPowerOn = allow;
94 uint16_t actionTriggerModeLocked : 1;
95 uint16_t actionTriggerLocalUnlockAllowed : 1;
96 uint16_t keepConfigButtonTriggerAlwaysAvailable : 1;
97 uint16_t actionTriggerSuppressActionsUntilRelease : 1;
98 uint16_t actionTriggerDispatching : 1;
99 uint16_t suppressActionsUntilRelease : 1;
100 uint16_t repeatOnHoldEnabled : 1;
101 uint16_t configButton : 1;
102 uint16_t disabled : 1;
103 uint16_t allowHoldOnPowerOn : 1;
104 uint16_t waitingForRelease : 1;
105 uint16_t conditionalActionsOnClick1 : 1;
106 uint16_t reserved : 4;
110 "Button runtime flags must fit in uint16_t");
112 void setActionTriggerModeLocked(
bool locked);
113 void setActionTriggerModeLocked(
bool locked,
114 bool localUnlockAllowed,
115 bool keepConfigButtonTriggerAlwaysAvailable);
116 bool runActionWithActionTriggerPolicy(uint16_t event);
117 void evaluateMaxMulticlickValue();
121 void setConditionalActionsOnClick1(
bool enabled);
124 void disableRepeatOnHold(uint32_t threshold = 0);
125 void enableRepeatOnHold();
126 const char *getButtonTypeName(ButtonType type)
const;
127 uint32_t lastStateChangeMs = 0;
128 uint16_t repeatOnHoldMs = 0;
129 uint16_t holdSend = 0;
130 uint16_t holdTimeMs = 0;
131 uint16_t multiclickTimeMs = 0;
133 ButtonType buttonType = ButtonType::MONOSTABLE;
134 enum OnLoadConfigType onLoadConfigType = OnLoadConfigType::LOAD_FULL_CONFIG;
136 uint8_t clickCounter = 0;
137 uint8_t maxMulticlickValueConfigured = 0;
138 int8_t buttonNumber = -1;
140 static int buttonCounter;