Doxygen with github
Loading...
Searching...
No Matches
ksf::comps::ksResetButton Class Reference

A component that implements reset button functionality. More...

#include <ksResetButton.h>

+ Inheritance diagram for ksf::comps::ksResetButton:

Public Member Functions

virtual const std::size_t getInstanceType () const
 Retrieves type ID of the object.
 
virtual bool isA (const std::size_t id) const
 Checks whether object is of given type.
 
 ksResetButton (uint8_t pin, uint8_t triggerState, uint8_t mode)
 Constructs the reset button component.
 
virtual ~ksResetButton ()
 Destructs ksResetButton, restoring INPUT pin state.
 
bool init (ksApplication *app) override
 Initializes the reset button component.
 
bool loop (ksApplication *app) override
 Handles the reset button component logic.
 
uint8_t getPin () const
 Retrieves pin number assigned to the button.
 
- Public Member Functions inherited from ksf::ksComponent
virtual bool postInit (ksApplication *app)
 Method called after component initialization, used to setup references to other components.
 
- Public Member Functions inherited from ksf::ksRtti
virtual ~ksRtti ()=default
 Destructor.
 
template<typename TType >
TType * as ()
 Tries to cast object to the type provided as a template parameter.
 
template<typename TType >
const TType * as () const
 Tries to cast object to the type provided as a template parameter (const version).
 

Static Public Member Functions

static const std::size_t getClassType ()
 
- Static Public Member Functions inherited from ksf::ksComponent
static const std::size_t getClassType ()
 

Protected Attributes

uint8_t pin {0}
 Cached pin number.
 
uint8_t triggerState {0}
 State that triggers reset logic.
 
uint8_t lastState {0}
 Previous state (for debouncing).
 
uint8_t mode {INPUT}
 Cached pin mode.
 
uint32_t pressedTime {0}
 Press timestamp (milliseconds since boot).
 
uint32_t releasedTime {0}
 Release timestamp (milliseconds since boot).
 
- Protected Attributes inherited from ksf::ksComponent
ksComponentState::TYPE componentState { ksComponentState::NotInitialized }
 Holds current state of the component.
 

Detailed Description

A component that implements reset button functionality.

On a short press, the component loop returns false, prompting ksAppRotator to switch to the next application. On a long press, it performs a factory reset by erasing user data.

The component also includes built-in debounce handling.

Constructor & Destructor Documentation

◆ ksResetButton()

ksf::comps::ksResetButton::ksResetButton ( uint8_t pin,
uint8_t triggerState,
uint8_t mode )

Constructs the reset button component.

Parameters
pinPin number assigned to the button.
triggerStatePin state that triggers the reset logic (LOW or HIGH).
modePin mode (INPUT / INPUT_PULLUP etc).

Member Function Documentation

◆ getInstanceType()

virtual const std::size_t ksf::comps::ksResetButton::getInstanceType ( ) const
inlinevirtual

Retrieves type ID of the object.

Returns
Object type ID.

Reimplemented from ksf::ksComponent.

◆ getPin()

uint8_t ksf::comps::ksResetButton::getPin ( ) const
inline

Retrieves pin number assigned to the button.

Returns
Pin number assigned to the reset button.

References pin.

◆ init()

bool ksf::comps::ksResetButton::init ( ksApplication * app)
overridevirtual

Initializes the reset button component.

Parameters
appPointer to the parent ksApplication.
Returns
True on success, false otherwise.

Reimplemented from ksf::ksComponent.

References lastState, mode, and pin.

◆ isA()

virtual bool ksf::comps::ksResetButton::isA ( const std::size_t id) const
inlinevirtual

Checks whether object is of given type.

Parameters
idType ID to check against.
Returns
True if object is of given type, otherwise false.

Reimplemented from ksf::ksComponent.

◆ loop()

bool ksf::comps::ksResetButton::loop ( ksApplication * app)
overridevirtual

Handles the reset button component logic.

Parameters
appPointer to the parent ksApplication.
Returns
True on success, false otherwise.

Reimplemented from ksf::ksComponent.

References lastState, pin, pressedTime, releasedTime, and triggerState.


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