|
ELEC-C7222
Libraries for ELEC C7222 Course Work
|
Input-only GPIO wrapper intended for push-buttons. More...
#include <button.hpp>


Public Member Functions | |
| Button (uint32_t pin, GpioPullMode pull=GpioPullMode::PullUp) | |
| Construct a button pin in input mode. | |
| virtual | ~Button ()=default |
| Destructor unregisters the button from the platform map. | |
| void | Configure (const Config &config)=delete |
| Disallow generic reconfiguration. | |
| void | Reconfigure (GpioPullMode pull=GpioPullMode::PullUp) |
| Reconfigure the button pull mode. | |
| bool | IsPressed () const |
| Return true if the button is currently pressed (active-low). | |
Public Member Functions inherited from c7222::GpioIn | |
| GpioIn (uint32_t pin) | |
| Create a GPIO input with default configuration. | |
| GpioIn (uint32_t pin, const Config &config) | |
| Create a GPIO input with the given configuration. | |
| virtual | ~GpioIn () |
| Destructor. | |
| void | EnableIrq (GpioInputEvent events, std::function< void(uint32_t)> handler) |
| Enable GPIO IRQs for the given event set and handler. | |
| void | DisableIrq () |
| Disable any IRQs configured for this input. | |
| void | Configure (const Config &config) |
| Apply a new configuration. | |
| bool | Read () const |
| Read the current GPIO level. | |
| uint32_t | GetPin () const |
| Return the GPIO number. | |
| Config | GetConfig () const |
| Return the cached configuration. | |
| bool | HasHandler () const |
| Return true if an IRQ handler is currently registered. | |
| void | CallIrqHandler (uint32_t events) const |
| Invoke the registered IRQ handler (if any). | |
Public Member Functions inherited from c7222::NonCopyable | |
| NonCopyable (const NonCopyable &)=delete | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable (NonCopyable &&)=default | |
| NonCopyable & | operator= (NonCopyable &&)=default |
Public Member Functions inherited from c7222::NonMovable | |
| NonMovable (const NonMovable &)=default | |
| NonMovable & | operator= (const NonMovable &)=default |
| NonMovable (NonMovable &&)=delete | |
| NonMovable & | operator= (NonMovable &&)=delete |
Additional Inherited Members | |
Protected Member Functions inherited from c7222::GpioIn | |
| void | ApplyConfig () |
| Apply internal configuration to the hardware. | |
Protected Member Functions inherited from c7222::NonCopyableNonMovable | |
| NonCopyableNonMovable ()=default | |
| ~NonCopyableNonMovable ()=default | |
Protected Member Functions inherited from c7222::NonCopyable | |
| NonCopyable ()=default | |
| ~NonCopyable ()=default | |
Protected Member Functions inherited from c7222::NonMovable | |
| NonMovable ()=default | |
| ~NonMovable ()=default | |
Protected Attributes inherited from c7222::GpioIn | |
| uint32_t | pin_ |
| GPIO pin number managed by this instance. | |
| Config | config_ |
| Cached configuration used to (re)apply platform settings. | |
Input-only GPIO wrapper intended for push-buttons.
Design intent:
GpioIn and deletes Configure() to prevent reconfiguration into output mode.IsPressed() provides a clear, easy-to-read API for beginners. IRQ support is still available through the inherited GpioIn API when more advanced usage is needed.Wiring assumption (C7222 Pico W board):
IsPressed() returns true when the logical state indicates a press and abstracts the active-low wiring from callers.Reconfiguration note:
Reconfigure() after releasing PWM ownership to restore input configuration.
|
explicit |
Construct a button pin in input mode.
| pin | GPIO number. |
| pull | Pull configuration (default: PullUp). |
|
virtualdefault |
Destructor unregisters the button from the platform map.
|
delete |
Disallow generic reconfiguration.
| bool c7222::Button::IsPressed | ( | ) | const |
Return true if the button is currently pressed (active-low).

| void c7222::Button::Reconfigure | ( | GpioPullMode | pull = GpioPullMode::PullUp | ) |
Reconfigure the button pull mode.
This is intended for cases where the pin was temporarily used for PWM and then returned to GPIO input control.
| pull | Pull configuration (default: PullUp). |