AceButton  1.0.0
An Adjustable Compact Event-driven (ACE) button library for Arduino.
Public Member Functions | List of all members
ace_button::testing::TestableButtonConfig Class Reference

A subclass of ButtonConfig which overrides getClock() and readButton() so that their values can be controlled manually. More...

#include <TestableButtonConfig.h>

Inheritance diagram for ace_button::testing::TestableButtonConfig:
Inheritance graph
[legend]
Collaboration diagram for ace_button::testing::TestableButtonConfig:
Collaboration graph
[legend]

Public Member Functions

virtual void init () override
 Initialize to its pristine state. More...
 
virtual unsigned long getClock () override
 Read the time of the fake clock. More...
 
virtual int readButton (uint8_t pin) override
 Read the fake physical button. More...
 
void setClock (unsigned long millis)
 Set the time of the fake clock. More...
 
void setButtonState (int buttonState)
 Set the state of the fake physical button. More...
 
- Public Member Functions inherited from ace_button::ButtonConfig
 ButtonConfig ()
 Constructor. More...
 
virtual uint16_t getDebounceDelay ()
 Milliseconds to wait for debouncing. More...
 
virtual uint16_t getClickDelay ()
 Milliseconds to wait for a possible click. More...
 
virtual uint16_t getDoubleClickDelay ()
 Milliseconds between the first and second click to register as a double-click.
 
virtual uint16_t getLongPressDelay ()
 Milliseconds for a long press event. More...
 
virtual uint16_t getRepeatPressDelay ()
 Milliseconds that a button needs to be Pressed down before the start of the sequence of RepeatPressed events. More...
 
virtual uint16_t getRepeatPressInterval ()
 Milliseconds between two successive RepeatPressed events.
 
bool isFeature (uint8_t features) ACE_BUTTON_INLINE
 Check if the given features are enabled. More...
 
void setFeature (uint8_t features) ACE_BUTTON_INLINE
 Enable the given features. More...
 
void clearFeature (uint8_t features) ACE_BUTTON_INLINE
 Disable the given features. More...
 
EventHandler getEventHandler () ACE_BUTTON_INLINE
 Return the eventHandler. More...
 
void setEventHandler (EventHandler eventHandler) ACE_BUTTON_INLINE
 Install the event handler. More...
 

Additional Inherited Members

- Public Types inherited from ace_button::ButtonConfig
typedef void(* EventHandler) (AceButton *button, uint8_t eventType, uint8_t buttonState)
 The event handler signature. More...
 
- Static Public Member Functions inherited from ace_button::ButtonConfig
static ButtonConfiggetSystemButtonConfig () ACE_BUTTON_INLINE
 Return a pointer to the singleton instance of the ButtonConfig which is attached to all AceButton instances by default.
 
- Static Public Attributes inherited from ace_button::ButtonConfig
static const uint16_t kDebounceDelay = 50
 Default value returned by getDebounceDelay(). More...
 
static const uint16_t kClickDelay = 200
 Default value returned by getClickDelay(). More...
 
static const uint16_t kDoubleClickDelay = 400
 Default value returned by getDoubleClickDelay(). More...
 
static const uint16_t kLongPressDelay = 1000
 Default value returned by getLongPressDelay(). More...
 
static const uint16_t kRepeatPressDelay = 1000
 Default value returned by getRepeatPressDelay(). More...
 
static const uint16_t kRepeatPressInterval = 200
 Default value returned by getRepeatPressInterval(). More...
 
static const uint8_t kFeatureClick = 0x01
 Flag to activate the AceButton::kEventClicked event. More...
 
static const uint8_t kFeatureDoubleClick = 0x02
 Flag to activate the AceButton::kEventDoubleClicked event. More...
 
static const uint8_t kFeatureLongPress = 0x04
 Flag to activate the AceButton::kEventLongPress event. More...
 
static const uint8_t kFeatureRepeatPress = 0x08
 Flag to activate the AceButton::kEventRepeatPressed event. More...
 
static const uint8_t kFeatureSuppressAfterClick = 0x10
 Flag to suppress kEventReleased after a kEventClicked. More...
 
static const uint8_t kFeatureSuppressAfterDoubleClick = 0x20
 Flag to suppress kEventReleased after a kEventDoubleClicked. More...
 
static const uint8_t kFeatureSuppressAfterLongPress = 0x40
 Flag to suppress kEventReleased after a kEventLongPressed. More...
 
static const uint8_t kFeatureSuppressAfterRepeatPress = 0x80
 Flag to suppress kEventReleased after a kEventRepeatPressed. More...
 
static const uint8_t kFeatureSuppressAll
 Convenience flag to suppress all suppressions. More...
 

Detailed Description

A subclass of ButtonConfig which overrides getClock() and readButton() so that their values can be controlled manually.

This is intended to be used for unit testing.

Member Function Documentation

◆ getClock()

virtual unsigned long ace_button::testing::TestableButtonConfig::getClock ( )
inlineoverridevirtual

Read the time of the fake clock.

Reimplemented from ace_button::ButtonConfig.

◆ init()

virtual void ace_button::testing::TestableButtonConfig::init ( )
inlineoverridevirtual

Initialize to its pristine state.

This method is needed because ArduinoUnit does not create a new instance of the Test class for each test case, so we have to reuse objects between test cases, so we need a way to reinitialize this object to its pristine state just after construction.

Reimplemented from ace_button::ButtonConfig.

◆ readButton()

virtual int ace_button::testing::TestableButtonConfig::readButton ( uint8_t  pin)
inlineoverridevirtual

Read the fake physical button.

Reimplemented from ace_button::ButtonConfig.

◆ setButtonState()

void ace_button::testing::TestableButtonConfig::setButtonState ( int  buttonState)
inline

Set the state of the fake physical button.

◆ setClock()

void ace_button::testing::TestableButtonConfig::setClock ( unsigned long  millis)
inline

Set the time of the fake clock.


The documentation for this class was generated from the following file: