25 #ifndef ACE_BUTTON_ACE_BUTTON_H
26 #define ACE_BUTTON_ACE_BUTTON_H
29 #include "ButtonConfig.h"
31 class __FlashStringHelper;
33 namespace ace_button {
126 static __FlashStringHelper*
eventName(uint8_t event);
162 uint8_t defaultReleasedState = HIGH,
166 init(pin, defaultReleasedState,
id);
195 uint8_t defaultReleasedState = HIGH,
197 init(buttonConfig, pin, defaultReleasedState,
id);
207 uint8_t defaultReleasedState = HIGH,
219 uint8_t defaultReleasedState = HIGH,
224 return mButtonConfig;
233 mButtonConfig = buttonConfig;
274 uint8_t
getId()
const {
return mId; }
293 return mLastButtonState;
353 void setPin(uint8_t pin) { mPin = pin; }
362 void setDefaultReleasedState(uint8_t state);
365 void setId(uint8_t
id) { mId = id; }
370 typedef uint16_t FlagType;
371 static const FlagType kFlagDefaultReleasedState = 0x01;
372 static const FlagType kFlagDebouncing = 0x02;
373 static const FlagType kFlagPressed = 0x04;
374 static const FlagType kFlagClicked = 0x08;
375 static const FlagType kFlagDoubleClicked = 0x10;
376 static const FlagType kFlagLongPressed = 0x20;
377 static const FlagType kFlagRepeatPressed = 0x40;
378 static const FlagType kFlagClickPostponed = 0x80;
379 static const FlagType kFlagHeartRunning = 0x100;
381 bool isFlag(FlagType flag)
const {
382 return mFlags & flag;
385 void setFlag(FlagType flag) {
389 void clearFlag(FlagType flag) {
398 bool checkDebounced(uint16_t now, uint8_t buttonState);
406 bool checkInitialized(uint16_t buttonState);
409 void checkEvent(uint16_t now, uint8_t buttonState);
412 void checkLongPress(uint16_t now, uint8_t buttonState);
415 void checkRepeatPress(uint16_t now, uint8_t buttonState);
418 void checkChanged(uint16_t now, uint8_t buttonState);
424 void checkReleased(uint16_t now, uint8_t buttonState);
427 void checkPressed(uint16_t now, uint8_t buttonState);
430 void checkClicked(uint16_t now);
436 void checkDoubleClicked(uint16_t now);
446 void checkOrphanedClick(uint16_t now);
452 void checkPostponedClick(uint16_t now);
455 void checkHeartBeat(uint16_t now);
509 void handleEvent(uint8_t eventType);
513 ButtonConfig* mButtonConfig;
528 uint8_t mLastButtonState;
533 uint16_t mLastDebounceTime;
534 uint16_t mLastClickTime;
535 uint16_t mLastPressTime;
536 uint16_t mLastRepeatPressTime;
537 uint16_t mLastHeartBeatTime;