Remove MotorController, use nrf_gpio Motor pin, apptimer repeat (#34)

Remove the custom MotorController class and use the upstream
MotorController instead.

To enable this move add custom code in nrf_gpio to handle the Motor pin
instead of the custom motor_is_running member variable.

Also implement the repeating app_timer type used in the upstream
MotorController.
This commit is contained in:
NeroBurner
2022-06-05 22:03:53 +02:00
committed by GitHub
parent f64e1aab80
commit ce22ba29c9
7 changed files with 49 additions and 108 deletions

View File

@@ -6,8 +6,20 @@
#include <stdexcept>
#include <string> // std::to_string
void nrf_gpio_cfg_default(uint32_t pin_number) {}
void nrf_gpio_pin_set(uint32_t pin_number) {}
bool motor_running = false;
void nrf_gpio_cfg_default(uint32_t pin_number) {
if (pin_number == Pinetime::PinMap::Motor)
{
motor_running = true;
}
}
void nrf_gpio_pin_set(uint32_t pin_number) {
if (pin_number == Pinetime::PinMap::Motor)
{
motor_running = false;
}
}
uint32_t nrf_gpio_pin_read(uint32_t pin_number)
{
if (pin_number == Pinetime::PinMap::Button) {
@@ -16,12 +28,21 @@ uint32_t nrf_gpio_pin_read(uint32_t pin_number)
bool right_click = (buttons & SDL_BUTTON_RMASK) != 0;
return right_click;
}
else if (pin_number == Pinetime::PinMap::Motor)
{
return motor_running;
}
throw std::runtime_error("nrf_gpio_pin_read: unhandled pin_number: " + std::to_string(pin_number));
return 0;
}
void nrf_gpio_cfg_output(uint32_t pin_number) {}
void nrf_gpio_pin_clear(uint32_t pin_number) {}
void nrf_gpio_pin_clear(uint32_t pin_number) {
if (pin_number == Pinetime::PinMap::Motor)
{
motor_running = true;
}
}
void nrf_gpio_range_cfg_input(uint32_t pin_range_start,
uint32_t pin_range_end,
nrf_gpio_pin_pull_t pull_config) {}