Skip to content

Commit

Permalink
fix 5v power mag
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Aug 13, 2023
1 parent d67a689 commit a26aa0f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mag.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,24 @@ int32_t mag_app(void* p) {

mag_make_app_folder(mag);

// Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering
uint8_t attempts = 0;
bool otg_was_enabled = furi_hal_power_is_otg_enabled();
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
furi_hal_power_enable_otg();
furi_delay_ms(10);
}

view_dispatcher_attach_to_gui(mag->view_dispatcher, mag->gui, ViewDispatcherTypeFullscreen);
scene_manager_next_scene(mag->scene_manager, MagSceneStart);

view_dispatcher_run(mag->view_dispatcher);

// Disable 5v power
if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
furi_hal_power_disable_otg();
}

mag_free(mag);

return 0;
Expand Down

0 comments on commit a26aa0f

Please sign in to comment.