Add button tests
This is implemented by connecting the DTR pin of the serial device to the BTN_UP pin of the watch. Also, make it possible to flash different applications with the Makefile. Resolves #4
This commit is contained in:
@@ -40,47 +40,47 @@
|
||||
|
||||
#include "Mcu.h"
|
||||
|
||||
using BSP::Time;
|
||||
using namespace BSP;
|
||||
|
||||
// GPIOs
|
||||
|
||||
static BSP::GpioDriver g_gpioa(GPIOA);
|
||||
static GpioDriver g_gpioa(GPIOA);
|
||||
|
||||
static BSP::GpioPin g_dbg0(g_gpioa, 3);
|
||||
static BSP::GpioPin g_dbg1(g_gpioa, 6);
|
||||
static GpioPin g_dbg0(g_gpioa, 3);
|
||||
static GpioPin g_dbg1(g_gpioa, 6);
|
||||
|
||||
static BSP::GpioPin g_tx(g_gpioa, 9);
|
||||
static BSP::GpioPin g_rx(g_gpioa, 10);
|
||||
static GpioPin g_tx(g_gpioa, 9);
|
||||
static GpioPin g_rx(g_gpioa, 10);
|
||||
|
||||
static BSP::GpioPin g_btn_down(g_gpioa, 0);
|
||||
static BSP::GpioPin g_btn_mid(g_gpioa, 1);
|
||||
static BSP::GpioPin g_btn_up(g_gpioa, 2);
|
||||
static GpioPin g_btn_down(g_gpioa, 0);
|
||||
static GpioPin g_btn_mid(g_gpioa, 1);
|
||||
static GpioPin g_btn_up(g_gpioa, 2);
|
||||
|
||||
static BSP::GpioPin g_nss(g_gpioa, 4);
|
||||
static BSP::GpioPin g_sck(g_gpioa, 5);
|
||||
static BSP::GpioPin g_mosi(g_gpioa, 12);
|
||||
static BSP::GpioPin g_extcomm(g_gpioa, 7);
|
||||
static GpioPin g_nss(g_gpioa, 4);
|
||||
static GpioPin g_sck(g_gpioa, 5);
|
||||
static GpioPin g_mosi(g_gpioa, 12);
|
||||
static GpioPin g_extcomm(g_gpioa, 7);
|
||||
|
||||
// Scheduler and Tasks
|
||||
|
||||
static BSP::Schedule::LowPowerTaskScheduler<5> g_sched;
|
||||
static BSP::SpiDriver g_spi(g_sched, g_nss);
|
||||
static BSP::DisplayDriver g_display(g_sched, g_spi);
|
||||
static BSP::LptimPwm g_lptim_pwm(LPTIM1);
|
||||
static BSP::ButtonManager g_btn_manager(
|
||||
static Schedule::LowPowerTaskScheduler<5> g_sched;
|
||||
static SpiDriver g_spi(g_sched, g_nss);
|
||||
static DisplayDriver g_display(g_sched, g_spi);
|
||||
static LptimPwm g_lptim_pwm(LPTIM1);
|
||||
static ButtonManager g_btn_mgr(
|
||||
g_sched, g_btn_up, g_btn_mid, g_btn_down, Time::millis(200));
|
||||
|
||||
// Screens- contexts for the display
|
||||
static ScreenManager g_screen_manager(g_sched, g_display, g_btn_manager);
|
||||
static SetTimeScreen g_set_time_screen(g_display, g_screen_manager);
|
||||
static SetTimeScreen g_set_date_screen(g_display, g_screen_manager);
|
||||
static StopwatchScreen g_stopwatch_screen(g_display, g_screen_manager);
|
||||
static ScreenManager g_screen_mgr(g_sched, g_display, g_btn_mgr);
|
||||
static SetTimeScreen g_set_time_screen(g_display, g_screen_mgr);
|
||||
static SetTimeScreen g_set_date_screen(g_display, g_screen_mgr);
|
||||
static StopwatchScreen g_stopwatch_screen(g_display, g_screen_mgr);
|
||||
static MenuScreen g_set_face_screen(g_display,
|
||||
g_screen_manager,
|
||||
g_screen_mgr,
|
||||
"Face",
|
||||
std::initializer_list<MenuScreenItem>());
|
||||
static MenuScreen g_settings_menu_screen(g_display,
|
||||
g_screen_manager,
|
||||
g_screen_mgr,
|
||||
"Settings",
|
||||
std::initializer_list<MenuScreenItem>(
|
||||
{
|
||||
@@ -89,45 +89,45 @@ static MenuScreen g_settings_menu_screen(g_display,
|
||||
MenuScreenItem("Set Face", g_set_face_screen)
|
||||
}));
|
||||
static MenuScreen g_apps_menu_screen(g_display,
|
||||
g_screen_manager,
|
||||
g_screen_mgr,
|
||||
"Apps", std::initializer_list<MenuScreenItem>({MenuScreenItem("Stopwatch", g_stopwatch_screen)}));
|
||||
static MenuScreen g_main_menu_screen(g_display,
|
||||
g_screen_manager,
|
||||
g_screen_mgr,
|
||||
"Main Menu",
|
||||
std::initializer_list<MenuScreenItem>(
|
||||
{
|
||||
MenuScreenItem("Apps", g_apps_menu_screen),
|
||||
MenuScreenItem("Settings", g_settings_menu_screen)
|
||||
}));
|
||||
static AnalogTimeScreen g_analog_time_screen(g_display, g_screen_manager, g_main_menu_screen);
|
||||
static BigDigitalTimeScreen g_digital_time_screen(g_display, g_screen_manager, g_main_menu_screen);
|
||||
static AnalogTimeScreen g_analog_time_screen(g_display, g_screen_mgr, g_main_menu_screen);
|
||||
static BigDigitalTimeScreen g_digital_time_screen(g_display, g_screen_mgr, g_main_menu_screen);
|
||||
|
||||
[[noreturn]] void main() {
|
||||
|
||||
// Set up the system clock
|
||||
BSP::RtcDriver::init();
|
||||
BSP::SystemTimer::set_timer(BSP::RtcDriver::get_system_timer());
|
||||
BSP::LowPower::init();
|
||||
RtcDriver::init();
|
||||
SystemTimer::set_timer(RtcDriver::get_system_timer());
|
||||
LowPower::init();
|
||||
|
||||
// Initialize the tasks
|
||||
g_lptim_pwm.init();
|
||||
g_spi.init();
|
||||
g_btn_manager.init();
|
||||
g_btn_mgr.init();
|
||||
g_display.init();
|
||||
g_screen_manager.init();
|
||||
g_screen_manager.set_root_screen(g_analog_time_screen);
|
||||
g_screen_mgr.init();
|
||||
g_screen_mgr.set_root_screen(g_analog_time_screen);
|
||||
|
||||
g_set_face_screen.add_item(MenuScreenItem("Analog",
|
||||
[]() { g_screen_manager.set_root_screen(g_analog_time_screen); }));
|
||||
[]() { g_screen_mgr.set_root_screen(g_analog_time_screen); }));
|
||||
g_set_face_screen.add_item(MenuScreenItem("Digital",
|
||||
[]() { g_screen_manager.set_root_screen(g_digital_time_screen); }));
|
||||
[]() { g_screen_mgr.set_root_screen(g_digital_time_screen); }));
|
||||
|
||||
// Enqueue each of the tasks
|
||||
BSP::Schedule::NextTime asap = BSP::Schedule::NextTime::asap();
|
||||
Schedule::NextTime asap = Schedule::NextTime::asap();
|
||||
g_sched.add_task(g_spi, asap);
|
||||
g_sched.add_task(g_btn_manager, asap);
|
||||
g_sched.add_task(g_btn_mgr, asap);
|
||||
g_sched.add_task(g_display, asap);
|
||||
g_sched.add_task(g_screen_manager, asap);
|
||||
g_sched.add_task(g_screen_mgr, asap);
|
||||
|
||||
// And we're off! This will never return
|
||||
g_sched.run();
|
||||
|
||||
Reference in New Issue
Block a user