Verify the main app mostly sleeps
This validates that the main watch app spends at least 99.5% of it's time sleeping in the first 10 seconds.
This commit is contained in:
@@ -37,7 +37,7 @@ BigDigitalTimeScreen::BigDigitalTimeScreen(BSP::DisplayDriver &driver,
|
||||
, m_last_time()
|
||||
, m_manager(manager)
|
||||
, m_menu_screen(menu_screen)
|
||||
, m_display_seconds(true)
|
||||
, m_display_seconds(false)
|
||||
{}
|
||||
|
||||
static char get_char_for_digit(uint8_t bcd_digit)
|
||||
|
||||
@@ -104,10 +104,16 @@ static BigDigitalTimeScreen g_digital_time_screen(g_display, g_screen_mgr, g_mai
|
||||
|
||||
[[noreturn]] void main() {
|
||||
|
||||
g_gpioa.init();
|
||||
g_gpioa.enable();
|
||||
|
||||
g_dbg0.configure_output(GpioDriver::output_mode_t::PUSH_PULL,
|
||||
GpioDriver::output_speed_t::LOW);
|
||||
|
||||
// Set up the system clock
|
||||
RtcDriver::init();
|
||||
SystemTimer::set_timer(RtcDriver::get_system_timer());
|
||||
LowPower::init();
|
||||
LowPower::init(g_dbg0);
|
||||
|
||||
// Initialize the tasks
|
||||
g_lptim_pwm.init();
|
||||
@@ -115,7 +121,7 @@ static BigDigitalTimeScreen g_digital_time_screen(g_display, g_screen_mgr, g_mai
|
||||
g_btn_mgr.init();
|
||||
g_display.init();
|
||||
g_screen_mgr.init();
|
||||
g_screen_mgr.set_root_screen(g_analog_time_screen);
|
||||
g_screen_mgr.set_root_screen(g_digital_time_screen);
|
||||
|
||||
g_set_face_screen.add_item(MenuScreenItem("Analog",
|
||||
[]() { g_screen_mgr.set_root_screen(g_analog_time_screen); }));
|
||||
|
||||
@@ -31,9 +31,19 @@ namespace BSP {
|
||||
|
||||
using BSP::ReturnCode;
|
||||
|
||||
GpioPin *LowPower::m_timing_pin = nullptr;
|
||||
|
||||
ReturnCode LowPower::init()
|
||||
{
|
||||
enable_debug();
|
||||
m_timing_pin = nullptr;
|
||||
return ReturnCode::OK;
|
||||
}
|
||||
|
||||
ReturnCode LowPower::init(GpioPin &timing_pin)
|
||||
{
|
||||
m_timing_pin = &timing_pin;
|
||||
m_timing_pin->write(0);
|
||||
|
||||
return ReturnCode::OK;
|
||||
}
|
||||
|
||||
@@ -93,7 +103,13 @@ ReturnCode LowPower::stop()
|
||||
CLR(RCC->CFGR, RCC_CFGR_STOPWUCK); // MSI oscillator is wake-up from stop clock
|
||||
SET(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); // low-power mode = stop mode
|
||||
|
||||
__WFI(); // enter low-power mode (Wake from interrupt)
|
||||
if (m_timing_pin != nullptr) {
|
||||
m_timing_pin->write(1);
|
||||
__WFI(); // enter low-power mode (Wake from interrupt)
|
||||
m_timing_pin->write(0);
|
||||
} else{
|
||||
__WFI();
|
||||
}
|
||||
|
||||
wakeups++;
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Bsp/ReturnCode.h"
|
||||
#include "Bsp/Drivers/GpioDriver.h"
|
||||
|
||||
extern uint32_t wakeups;
|
||||
|
||||
@@ -32,10 +33,14 @@ public:
|
||||
LowPower() = delete;
|
||||
|
||||
static BSP::ReturnCode init();
|
||||
static BSP::ReturnCode init(GpioPin &timing_pin);
|
||||
|
||||
static BSP::ReturnCode sleep();
|
||||
static BSP::ReturnCode stop();
|
||||
static BSP::ReturnCode enable_debug();
|
||||
static BSP::ReturnCode disable_debug();
|
||||
|
||||
static GpioPin *m_timing_pin;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ using namespace BSP::Schedule;
|
||||
LowPowerTaskScheduler<10> g_sched;
|
||||
GpioDriver g_gpioa(GPIOA);
|
||||
UsartDriver g_test_uart(USART1, g_sched);
|
||||
GpioPin g_debug0_pin(g_gpioa, 4);
|
||||
|
||||
void board_init() {
|
||||
g_gpioa.enable();
|
||||
|
||||
@@ -31,11 +31,13 @@ using namespace BSP::Schedule;
|
||||
LowPowerTaskScheduler<10> g_sched;
|
||||
GpioDriver g_gpioa(GPIOA);
|
||||
UsartDriver g_test_uart(USART2, g_sched);
|
||||
GpioPin g_debug0_pin(g_gpioa, 3);
|
||||
static GpioPin g_tx_pin(g_gpioa, 9);
|
||||
|
||||
void board_init() {
|
||||
g_gpioa.enable();
|
||||
g_tx_pin.configure_alternate_function(4);
|
||||
g_debug0_pin.configure_input(GpioDriver::input_pull_t::PULL_UP);
|
||||
g_test_uart.init();
|
||||
|
||||
RtcDriver::init();
|
||||
|
||||
@@ -30,3 +30,4 @@ void board_init();
|
||||
extern BSP::Schedule::LowPowerTaskScheduler<10> g_sched;
|
||||
extern BSP::GpioDriver g_gpioa;
|
||||
extern BSP::UsartDriver g_test_uart;
|
||||
extern BSP::GpioPin g_debug0_pin;
|
||||
|
||||
Reference in New Issue
Block a user