From 5a24602d867ecbfa875ba6616259755d3789724f Mon Sep 17 00:00:00 2001 From: Erki Date: Sun, 18 Apr 2021 13:32:21 +0300 Subject: [PATCH] Move button's underlying gpio to be public --- Peripherals/Inc/peripherals_button.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Peripherals/Inc/peripherals_button.hpp b/Peripherals/Inc/peripherals_button.hpp index fe2207f..4d19e88 100644 --- a/Peripherals/Inc/peripherals_button.hpp +++ b/Peripherals/Inc/peripherals_button.hpp @@ -27,17 +27,19 @@ public: using gpio = G; using hal = H; + gpio sw; + static constexpr std::uint32_t TIMEOUT_SHORT_PRESS = 50; static constexpr std::uint32_t TIMEOUT_LONG_PRESS = 500; Button() = delete; explicit Button(const gpio& sw) - : _sw(sw) + : sw(sw) {} void update() { - const bool is_pressed = _sw.Read(); + const bool is_pressed = sw.Read(); ButtonPress new_state = ButtonPress::NOT_PRESSED; if (is_pressed && !_was_pressed) @@ -64,8 +66,6 @@ public: } private: - gpio _sw; - bool _was_pressed = false; std::uint32_t _time_pressed_down = 0; ButtonPress _current_state = ButtonPress::NOT_PRESSED;