Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
input.hpp
Go to the documentation of this file.
1/**
2 * @file input.hpp
3 * @brief Button input convenience functions
4 * @ingroup hal
5 *
6 * Composes GPIO driver reads with Button update in a single call.
7 *
8 * Usage:
9 * #include <sbl/hal/button/input.hpp>
10 *
11 * sbl::button::read<sbl::driver::Gpio>(btn, handle);
12 */
13
14#ifndef SBL_HAL_BUTTON_INPUT_HPP_
15#define SBL_HAL_BUTTON_INPUT_HPP_
16
17#include <sbl/types.hpp>
19
20namespace sbl {
21namespace button {
22
25
26/**
27 * @brief Read GPIO pin and feed into Button (debounce + edge detection)
28 *
29 * Gpio::read() returns logical value (active_low handled by driver),
30 * so Button doesn't need inversion logic.
31 *
32 * @tparam Driver GPIO driver type (e.g., sbl::driver::Gpio)
33 * @param btn Button instance to update
34 * @param handle GPIO handle for the button pin
35 *
36 * @note ISR-safe — single GPIO register read
37 */
38template<typename Driver>
39inline void read(Button& btn, const GpioHandle& handle) {
40 btn.update(Driver::read(handle));
41}
42
43} // namespace button
44} // namespace sbl
45
46#endif // SBL_HAL_BUTTON_INPUT_HPP_
Button component — debounced digital input with edge detection.
Debounced button with edge detection and held-duration tracking.
Definition button.hpp:35
void update(bool logical_state)
Feed a new logical GPIO reading.
Definition button.hpp:51
void read(Button &btn, const GpioHandle &handle)
Read GPIO pin and feed into Button (debounce + edge detection)
Definition input.hpp:39
Root namespace for all Sound Byte Libs functionality.
Definition aliases.hpp:24
GPIO pin handle with port, pin number, and polarity.
Definition handle.hpp:29
Common types for SBL hardware abstraction.