34class Button :
public SimpleButton,
public ActionHandler {
36 friend class ActionTrigger;
37 enum class ButtonType : uint8_t {
44 enum class OnLoadConfigType : uint8_t {
46 LOAD_BUTTON_SETUP_ONLY,
53 bool invertLogic =
false);
54 explicit Button(
int pin,
bool pullUp =
false,
bool invertLogic =
false);
59 void addAction(uint16_t action, ActionHandler &client, uint16_t event,
60 bool alwaysEnabled =
false)
override;
61 void addAction(uint16_t action, ActionHandler *client, uint16_t event,
62 bool alwaysEnabled =
false)
override;
63 void disableAction(int32_t action,
64 ActionHandler *client,
65 int32_t event)
override;
66 void enableAction(int32_t action,
67 ActionHandler *client,
68 int32_t event)
override;
70 void setHoldTime(
unsigned int timeMs);
71 void repeatOnHoldEvery(
unsigned int timeMs);
75 void setMulticlickTime(
unsigned int timeMs,
bool bistableButton =
false);
77 void setButtonType(
const ButtonType type);
78 bool isBistable()
const;
79 bool isMonostable()
const;
80 bool isMotionSensor()
const;
81 bool isCentral()
const;
84 bool disableActionsInConfigMode()
override;
85 void dontUseOnLoadConfig();
86 void setOnLoadConfigType(OnLoadConfigType type);
88 uint8_t getMaxMulticlickValue();
89 int8_t getButtonNumber()
const override;
90 void setButtonNumber(int8_t number);
92 void handleAction(
int event,
int action)
override;
96 void waitForRelease();
98 uint32_t getLastStateChange()
const;
100 void setAllowHoldOnPowerOn(
bool allow) { allowHoldOnPowerOn = allow; }
103 void evaluateMaxMulticlickValue();
106 void disableRepeatOnHold(uint32_t threshold = 0);
107 void enableRepeatOnHold();
108 const char *getButtonTypeName(ButtonType type)
const;
109 uint32_t lastStateChangeMs = 0;
110 uint16_t repeatOnHoldMs = 0;
111 uint16_t holdSend = 0;
112 uint16_t holdTimeMs = 0;
113 uint16_t multiclickTimeMs = 0;
114 ButtonType buttonType = ButtonType::MONOSTABLE;
115 enum OnLoadConfigType onLoadConfigType = OnLoadConfigType::LOAD_FULL_CONFIG;
117 uint8_t clickCounter = 0;
118 uint8_t maxMulticlickValueConfigured = 0;
119 bool repeatOnHoldEnabled =
false;
120 bool configButton =
false;
121 int8_t buttonNumber = -1;
122 bool disabled =
false;
123 bool allowHoldOnPowerOn =
false;
124 bool waitingForRelease =
false;
126 static int buttonCounter;