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.
This commit is contained in:
あく 2021-02-25 13:22:46 +03:00 committed by GitHub
parent a0db2986b5
commit 1b2c31da6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 6 additions and 10 deletions

View File

@ -8,9 +8,8 @@ Bt* bt_alloc() {
bt->gui = furi_record_open("gui"); bt->gui = furi_record_open("gui");
bt->menu = furi_record_open("menu"); bt->menu = furi_record_open("menu");
bt->statusbar_icon = assets_icons_get(I_Bluetooth_5x8);
bt->statusbar_view_port = view_port_alloc(); 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_draw_callback_set(bt->statusbar_view_port, bt_draw_statusbar_callback, bt);
view_port_enabled_set(bt->statusbar_view_port, false); view_port_enabled_set(bt->statusbar_view_port, false);
gui_add_view_port(bt->gui, bt->statusbar_view_port, GuiLayerStatusBarLeft); 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) { void bt_draw_statusbar_callback(Canvas* canvas, void* context) {
assert(context); canvas_draw_icon_name(canvas, 0, 0, I_Bluetooth_5x8);
Bt* bt = context;
canvas_draw_icon(canvas, 0, 0, bt->statusbar_icon);
} }
void bt_cli_info(string_t args, void* context) { void bt_cli_info(string_t args, void* context) {

View File

@ -18,7 +18,6 @@ typedef struct {
Gui* gui; Gui* gui;
ValueMutex* menu; ValueMutex* menu;
// Status bar // Status bar
Icon* statusbar_icon;
ViewPort* statusbar_view_port; ViewPort* statusbar_view_port;
// Menu // Menu
Icon* menu_icon; Icon* menu_icon;

View File

@ -199,8 +199,6 @@ int32_t power_task(void* p) {
with_value_mutex( with_value_mutex(
power->menu_vm, (Menu * menu) { menu_item_add(menu, power->menu); }); power->menu_vm, (Menu * menu) { menu_item_add(menu, power->menu); });
api_hal_power_init();
furi_record_create("power", power); furi_record_create("power", power);
while(1) { while(1) {

View File

@ -64,7 +64,7 @@ void api_hal_power_deep_sleep() {
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0); LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0);
// Prepare deep sleep // Prepare deep sleep
LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2); LL_PWR_SetPowerMode(LL_PWR_MODE_STOP1);
LL_LPM_EnableDeepSleep(); LL_LPM_EnableDeepSleep();
#if defined ( __CC_ARM) #if defined ( __CC_ARM)

View File

@ -5,5 +5,6 @@ void api_hal_init() {
api_hal_vcp_init(); api_hal_vcp_init();
api_hal_spi_init(); api_hal_spi_init();
api_hal_i2c_init(); api_hal_i2c_init();
api_hal_power_init();
api_hal_light_init(); api_hal_light_init();
} }

View File

@ -64,7 +64,7 @@ void api_hal_power_deep_sleep() {
LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0); LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0);
// Prepare deep sleep // Prepare deep sleep
LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2); LL_PWR_SetPowerMode(LL_PWR_MODE_STOP1);
LL_LPM_EnableDeepSleep(); LL_LPM_EnableDeepSleep();
#if defined ( __CC_ARM) #if defined ( __CC_ARM)

View File

@ -5,5 +5,6 @@ void api_hal_init() {
api_hal_vcp_init(); api_hal_vcp_init();
api_hal_spi_init(); api_hal_spi_init();
api_hal_i2c_init(); api_hal_i2c_init();
api_hal_power_init();
api_hal_light_init(); api_hal_light_init();
} }