30class Button :
public SimpleButton,
public ActionHandler {
32 friend class ActionTrigger;
33 enum class ButtonType : uint8_t {
40 enum class OnLoadConfigType : uint8_t {
42 LOAD_BUTTON_SETUP_ONLY,
49 bool invertLogic =
false);
50 explicit Button(
int pin,
bool pullUp =
false,
bool invertLogic =
false);
55 void addAction(uint16_t action, ActionHandler &client, uint16_t event,
56 bool alwaysEnabled =
false)
override;
57 void addAction(uint16_t action, ActionHandler *client, uint16_t event,
58 bool alwaysEnabled =
false)
override;
59 void disableAction(int32_t action,
60 ActionHandler *client,
61 int32_t event)
override;
62 void enableAction(int32_t action,
63 ActionHandler *client,
64 int32_t event)
override;
66 void setHoldTime(
unsigned int timeMs);
67 void repeatOnHoldEvery(
unsigned int timeMs);
71 void setMulticlickTime(
unsigned int timeMs,
bool bistableButton =
false);
73 void setButtonType(
const ButtonType type);
74 bool isBistable()
const;
75 bool isMonostable()
const;
76 bool isMotionSensor()
const;
77 bool isCentral()
const;
80 bool disableActionsInConfigMode()
override;
81 void dontUseOnLoadConfig();
82 void setOnLoadConfigType(OnLoadConfigType type);
84 uint8_t getMaxMulticlickValue();
85 int8_t getButtonNumber()
const override;
86 void setButtonNumber(int8_t number);
88 void handleAction(
int event,
int action)
override;
92 void waitForRelease();
94 uint32_t getLastStateChange()
const;
96 void setAllowHoldOnPowerOn(
bool allow) { allowHoldOnPowerOn = allow; }
99 void evaluateMaxMulticlickValue();
102 void disableRepeatOnHold(uint32_t threshold = 0);
103 void enableRepeatOnHold();
104 const char *getButtonTypeName(ButtonType type)
const;
105 uint32_t lastStateChangeMs = 0;
106 uint16_t repeatOnHoldMs = 0;
107 uint16_t holdSend = 0;
108 uint16_t holdTimeMs = 0;
109 uint16_t multiclickTimeMs = 0;
110 ButtonType buttonType = ButtonType::MONOSTABLE;
111 enum OnLoadConfigType onLoadConfigType = OnLoadConfigType::LOAD_FULL_CONFIG;
113 uint8_t clickCounter = 0;
114 uint8_t maxMulticlickValueConfigured = 0;
115 bool repeatOnHoldEnabled =
false;
116 bool configButton =
false;
117 int8_t buttonNumber = -1;
118 bool disabled =
false;
119 bool allowHoldOnPowerOn =
false;
120 bool waitingForRelease =
false;
122 static int buttonCounter;