Move button's underlying gpio to be public
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Erki 2021-04-18 13:32:21 +03:00
parent 4773801101
commit 5a24602d86

View File

@ -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;