Hack in support for other boards/microcontrollers, add GpioDriver
There's definitely plenty of cleanup work to be done (see: "ifdefs").
This commit is contained in:
@@ -26,22 +26,23 @@
|
||||
#include "Bsp/TaskScheduler.h"
|
||||
#include "Bsp/Task.h"
|
||||
#include "Bsp/ReturnCode.h"
|
||||
#include "Bsp/Drivers/GpioDriver.h"
|
||||
|
||||
namespace BSP {
|
||||
|
||||
class ButtonManager : public BSP::Schedule::Task {
|
||||
public:
|
||||
ButtonManager(BSP::Schedule::TaskScheduler &scheduler,
|
||||
uint8_t up_gpio_idx,
|
||||
uint8_t mid_gpio_idx,
|
||||
uint8_t down_gpio_idx,
|
||||
GpioPin &btn_down,
|
||||
GpioPin &btn_mid,
|
||||
GpioPin &btn_up,
|
||||
BSP::time_t debounce_time)
|
||||
: m_scheduler(scheduler)
|
||||
, m_buttons
|
||||
{
|
||||
button_state(up_gpio_idx, debounce_time, ButtonManager::nop_callback),
|
||||
button_state(mid_gpio_idx, debounce_time, ButtonManager::nop_callback),
|
||||
button_state(down_gpio_idx, debounce_time, ButtonManager::nop_callback),
|
||||
button_state(btn_down, debounce_time, ButtonManager::nop_callback),
|
||||
button_state(btn_mid, debounce_time, ButtonManager::nop_callback),
|
||||
button_state(btn_up, debounce_time, ButtonManager::nop_callback),
|
||||
}
|
||||
{
|
||||
m_instance = this;
|
||||
@@ -78,16 +79,16 @@ private:
|
||||
|
||||
struct button_state {
|
||||
|
||||
button_state(uint8_t gpio_index,
|
||||
button_state(GpioPin &pin,
|
||||
BSP::time_t debounce_time,
|
||||
ChangeCallback callback)
|
||||
: m_gpio_idx(gpio_index)
|
||||
: m_pin(pin)
|
||||
, m_debounce_time(debounce_time)
|
||||
, m_state(ButtonState::NOT_PRESSED)
|
||||
, m_state_change_ts(0)
|
||||
, m_callback(callback)
|
||||
{}
|
||||
uint8_t const m_gpio_idx;
|
||||
GpioPin &m_pin;
|
||||
BSP::time_t const m_debounce_time;
|
||||
|
||||
ButtonState m_prev_call_state; /*<! The last state the button was in when it the callback was called */
|
||||
|
||||
Reference in New Issue
Block a user