From b17cfb10bf6e8e665d4d0ff0b2c5653f685cca37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 29 Oct 2022 08:47:43 +0000 Subject: [PATCH] PFW-1404 Add more comments --- src/modules/buttons.h | 6 +++++- src/modules/debouncer.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/buttons.h b/src/modules/buttons.h index c6e5a79..99bf7ef 100644 --- a/src/modules/buttons.h +++ b/src/modules/buttons.h @@ -34,10 +34,14 @@ public: /// Performs one step of the state machine - reads the ADC, processes debouncing, updates states of individual buttons void Step(); - /// @returns true if button at index is pressed + /// @brief Indicates whether or not a particular button was pressed /// @param index of the button to check + /// @return true if button at index is pressed, false otherwise inline bool ButtonPressed(uint8_t index) const { return buttons[index].Pressed(); } + /// @brief Indicates whether or not a particular button was released + /// @param index of the button to check + /// @return true if button at index is released, false otherwise inline bool ButtonReleased(uint8_t index) const { return buttons[index].Released(); } /// @returns true if any of the button is pressed diff --git a/src/modules/debouncer.h b/src/modules/debouncer.h index a5f7946..bca8ea4 100644 --- a/src/modules/debouncer.h +++ b/src/modules/debouncer.h @@ -19,6 +19,8 @@ public: /// @returns true if debounced value is currently considered as pressed inline bool Pressed() const { return f.state == State::WaitForRelease; } + + /// @returns true if debounced value is currently considered as released inline bool Released() const { return f.state == State::Update; } /// State machine stepping routine