From 1b2c31da6f7e2d1e28ee63670167bc1dad07b565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Thu, 25 Feb 2021 13:22:46 +0300 Subject: [PATCH] Power subsystem improvements and bug fixes (#353) * BT: render icon statically. * Move API HAL Power init call to api_hal_init. * API HAL Power: replace stop2 mode with stop1 to ensure usb and lptim2 proper work. --- applications/bt/bt.c | 7 ++----- applications/bt/bt_i.h | 1 - applications/power/power.c | 2 -- firmware/targets/f4/api-hal/api-hal-power.c | 2 +- firmware/targets/f4/api-hal/api-hal.c | 1 + firmware/targets/f5/api-hal/api-hal-power.c | 2 +- firmware/targets/f5/api-hal/api-hal.c | 1 + 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/applications/bt/bt.c b/applications/bt/bt.c index de5b0b84..87e8f547 100644 --- a/applications/bt/bt.c +++ b/applications/bt/bt.c @@ -8,9 +8,8 @@ Bt* bt_alloc() { bt->gui = furi_record_open("gui"); bt->menu = furi_record_open("menu"); - bt->statusbar_icon = assets_icons_get(I_Bluetooth_5x8); bt->statusbar_view_port = view_port_alloc(); - view_port_set_width(bt->statusbar_view_port, icon_get_width(bt->statusbar_icon)); + view_port_set_width(bt->statusbar_view_port, 5); view_port_draw_callback_set(bt->statusbar_view_port, bt_draw_statusbar_callback, bt); view_port_enabled_set(bt->statusbar_view_port, false); gui_add_view_port(bt->gui, bt->statusbar_view_port, GuiLayerStatusBarLeft); @@ -24,9 +23,7 @@ Bt* bt_alloc() { } void bt_draw_statusbar_callback(Canvas* canvas, void* context) { - assert(context); - Bt* bt = context; - canvas_draw_icon(canvas, 0, 0, bt->statusbar_icon); + canvas_draw_icon_name(canvas, 0, 0, I_Bluetooth_5x8); } void bt_cli_info(string_t args, void* context) { diff --git a/applications/bt/bt_i.h b/applications/bt/bt_i.h index dbedab8a..26d47def 100644 --- a/applications/bt/bt_i.h +++ b/applications/bt/bt_i.h @@ -18,7 +18,6 @@ typedef struct { Gui* gui; ValueMutex* menu; // Status bar - Icon* statusbar_icon; ViewPort* statusbar_view_port; // Menu Icon* menu_icon; diff --git a/applications/power/power.c b/applications/power/power.c index bbd99500..1250b141 100644 --- a/applications/power/power.c +++ b/applications/power/power.c @@ -199,8 +199,6 @@ int32_t power_task(void* p) { with_value_mutex( power->menu_vm, (Menu * menu) { menu_item_add(menu, power->menu); }); - api_hal_power_init(); - furi_record_create("power", power); while(1) { diff --git a/firmware/targets/f4/api-hal/api-hal-power.c b/firmware/targets/f4/api-hal/api-hal-power.c index dcc2f606..d6d8bedb 100644 --- a/firmware/targets/f4/api-hal/api-hal-power.c +++ b/firmware/targets/f4/api-hal/api-hal-power.c @@ -64,7 +64,7 @@ void api_hal_power_deep_sleep() { LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0); // Prepare deep sleep - LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2); + LL_PWR_SetPowerMode(LL_PWR_MODE_STOP1); LL_LPM_EnableDeepSleep(); #if defined ( __CC_ARM) diff --git a/firmware/targets/f4/api-hal/api-hal.c b/firmware/targets/f4/api-hal/api-hal.c index 3a5948a8..f337be81 100644 --- a/firmware/targets/f4/api-hal/api-hal.c +++ b/firmware/targets/f4/api-hal/api-hal.c @@ -5,5 +5,6 @@ void api_hal_init() { api_hal_vcp_init(); api_hal_spi_init(); api_hal_i2c_init(); + api_hal_power_init(); api_hal_light_init(); } diff --git a/firmware/targets/f5/api-hal/api-hal-power.c b/firmware/targets/f5/api-hal/api-hal-power.c index dcc2f606..d6d8bedb 100644 --- a/firmware/targets/f5/api-hal/api-hal-power.c +++ b/firmware/targets/f5/api-hal/api-hal-power.c @@ -64,7 +64,7 @@ void api_hal_power_deep_sleep() { LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0); // Prepare deep sleep - LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2); + LL_PWR_SetPowerMode(LL_PWR_MODE_STOP1); LL_LPM_EnableDeepSleep(); #if defined ( __CC_ARM) diff --git a/firmware/targets/f5/api-hal/api-hal.c b/firmware/targets/f5/api-hal/api-hal.c index 3f782e4a..70fe3108 100644 --- a/firmware/targets/f5/api-hal/api-hal.c +++ b/firmware/targets/f5/api-hal/api-hal.c @@ -5,5 +5,6 @@ void api_hal_init() { api_hal_vcp_init(); api_hal_spi_init(); api_hal_i2c_init(); + api_hal_power_init(); api_hal_light_init(); } \ No newline at end of file