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;