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,
54 bool invertLogic =
false);
55 explicit Button(
int pin,
bool pullUp =
false,
bool invertLogic =
false);
60 void addAction(uint16_t action, ActionHandler &client, uint16_t event,
61 bool alwaysEnabled =
false)
override;
62 void addAction(uint16_t action, ActionHandler *client, uint16_t event,
63 bool alwaysEnabled =
false)
override;
64 void disableAction(int32_t action,
65 ActionHandler *client,
66 int32_t event)
override;
67 void enableAction(int32_t action,
68 ActionHandler *client,
69 int32_t event)
override;
71 void setHoldTime(
unsigned int timeMs);
72 void repeatOnHoldEvery(
unsigned int timeMs);
76 void setMulticlickTime(
unsigned int timeMs,
bool bistableButton =
false);
78 void setButtonType(
const ButtonType type);
79 bool isBistable()
const;
80 bool isMonostable()
const;
81 bool isMotionSensor()
const;
82 bool isCentral()
const;
85 bool disableActionsInConfigMode()
override;
86 void dontUseOnLoadConfig();
87 void setOnLoadConfigType(OnLoadConfigType type);
89 uint8_t getMaxMulticlickValue();
90 int8_t getButtonNumber()
const override;
91 void setButtonNumber(int8_t number);
93 void handleAction(
int event,
int action)
override;
97 void waitForRelease();
99 uint32_t getLastStateChange()
const;
101 void setAllowHoldOnPowerOn(
bool allow) { allowHoldOnPowerOn = allow; }
104 void evaluateMaxMulticlickValue();
107 void disableRepeatOnHold(uint32_t threshold = 0);
108 void enableRepeatOnHold();
109 const char *getButtonTypeName(ButtonType type)
const;
110 uint32_t lastStateChangeMs = 0;
111 uint16_t repeatOnHoldMs = 0;
112 uint16_t holdSend = 0;
113 uint16_t holdTimeMs = 0;
114 uint16_t multiclickTimeMs = 0;
115 ButtonType buttonType = ButtonType::MONOSTABLE;
116 enum OnLoadConfigType onLoadConfigType = OnLoadConfigType::LOAD_FULL_CONFIG;
118 uint8_t clickCounter = 0;
119 uint8_t maxMulticlickValueConfigured = 0;
120 bool repeatOnHoldEnabled =
false;
121 bool configButton =
false;
122 int8_t buttonNumber = -1;
123 bool disabled =
false;
124 bool allowHoldOnPowerOn =
false;
125 bool waitingForRelease =
false;
127 static int buttonCounter;