Doxygen with github
Loading...
Searching...
No Matches
ksResetButton.h
1/*
2 * Copyright (c) 2021-2023, Krzysztof Strehlau
3 *
4 * This file is a part of the ksIotFramework library.
5 * All licensing information can be found inside LICENSE.md file.
6 *
7 * https://github.com/cziter15/ksIotFrameworkLib/blob/master/LICENSE
8 */
9
10#pragma once
11
12#include <Arduino.h>
13#include "../ksComponent.h"
14
15namespace ksf::comps
16{
26 {
27 KSF_RTTI_DECLARATIONS(ksResetButton, ksComponent)
28
29 protected:
30 uint8_t pin{0};
31 uint8_t triggerState{0};
32 uint8_t lastState{0};
33 uint8_t mode{INPUT};
34 uint32_t pressedTime{0};
35 uint32_t releasedTime{0};
36
37 public:
44 ksResetButton(uint8_t pin, uint8_t triggerState, uint8_t mode);
45
51 bool init(ksApplication* app) override;
52
58 bool loop(ksApplication* app) override;
59
64 uint8_t getPin() const { return pin; }
65
69 virtual ~ksResetButton();
70 };
71}
A component that implements reset button functionality.
Definition ksResetButton.h:26
uint8_t triggerState
State that triggers reset logic.
Definition ksResetButton.h:31
bool loop(ksApplication *app) override
Handles the reset button component logic.
Definition ksResetButton.cpp:41
uint8_t getPin() const
Retrieves pin number assigned to the button.
Definition ksResetButton.h:64
uint8_t pin
Cached pin number.
Definition ksResetButton.h:30
uint32_t releasedTime
Release timestamp (milliseconds since boot).
Definition ksResetButton.h:35
ksResetButton(uint8_t pin, uint8_t triggerState, uint8_t mode)
Constructs the reset button component.
Definition ksResetButton.cpp:30
uint8_t mode
Cached pin mode.
Definition ksResetButton.h:33
uint32_t pressedTime
Press timestamp (milliseconds since boot).
Definition ksResetButton.h:34
virtual ~ksResetButton()
Destructs ksResetButton, restoring INPUT pin state.
Definition ksResetButton.cpp:72
uint8_t lastState
Previous state (for debouncing).
Definition ksResetButton.h:32
bool init(ksApplication *app) override
Initializes the reset button component.
Definition ksResetButton.cpp:34
A class that is a base for user-defined application.
Definition ksApplication.h:43
Base component class.
Definition ksComponent.h:51