diff --git a/applications/plugins/dolphinrestorer/drestorer.c b/applications/plugins/dolphinrestorer/drestorer.c index d66af3520..d2c0273d2 100644 --- a/applications/plugins/dolphinrestorer/drestorer.c +++ b/applications/plugins/dolphinrestorer/drestorer.c @@ -27,11 +27,11 @@ bool drestorer_perform(void) { path_dst = furi_string_alloc(); for(uint32_t i = 0; i < COUNT_OF(app_dirs); i++) { - furi_string_printf(path_src, "%s/%s", MOVE_SRC, app_dirs[i]); - furi_string_printf(path_dst, "%s/%s", MOVE_DST, app_dirs[i]); - storage_simply_remove_recursive(storage, furi_string_get_cstr(path_dst)); - storage_common_copy( - storage, furi_string_get_cstr(path_src), furi_string_get_cstr(path_dst)); + furi_string_printf(path_src, "%s/%s", MOVE_SRC, app_dirs[i]); + furi_string_printf(path_dst, "%s/%s", MOVE_DST, app_dirs[i]); + storage_simply_remove_recursive(storage, furi_string_get_cstr(path_dst)); + storage_common_copy( + storage, furi_string_get_cstr(path_src), furi_string_get_cstr(path_dst)); } furi_string_free(path_src); diff --git a/applications/plugins/game15/game15.c b/applications/plugins/game15/game15.c index 7e1053b4c..f89b7c5c0 100644 --- a/applications/plugins/game15/game15.c +++ b/applications/plugins/game15/game15.c @@ -46,10 +46,7 @@ static moving_cell_t moving_cell; static uint8_t loaded_saving_ticks; static uint8_t popup_menu_selected_item; -static const char* popup_menu_strings[] = { - "Continue", - "Reset" -}; +static const char* popup_menu_strings[] = {"Continue", "Reset"}; static uint8_t keys[KEY_STACK_SIZE]; static uint8_t key_stack_head = 0; @@ -227,8 +224,7 @@ static void game_tick() { switch(game_state.scene) { case ScenePlay: game_state.tick_count++; - if (loaded_saving_ticks) - loaded_saving_ticks--; + if(loaded_saving_ticks) loaded_saving_ticks--; if(moving_cell.move_direction == DirectionNone && !key_stack_is_empty()) { set_moving_cell_by_direction(key_stack_pop()); if(moving_cell.move_direction == DirectionNone) { @@ -262,27 +258,25 @@ static void game_tick() { break; case ScenePopup: - if (!key_stack_is_empty()) { - switch(key_stack_pop()) - { - case DirectionDown: - popup_menu_selected_item++; - popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS; - break; - case DirectionUp: - popup_menu_selected_item--; - popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS; - break; - case DirectionNone: - if (popup_menu_selected_item == 0) { - game_state.scene = ScenePlay; - notification_message(notification, &sequence_single_vibro); - } - else if (popup_menu_selected_item == 1) { - notification_message(notification, &sequence_single_vibro); - game_init(); - } - break; + if(!key_stack_is_empty()) { + switch(key_stack_pop()) { + case DirectionDown: + popup_menu_selected_item++; + popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS; + break; + case DirectionUp: + popup_menu_selected_item--; + popup_menu_selected_item = popup_menu_selected_item % POPUP_MENU_ITEMS; + break; + case DirectionNone: + if(popup_menu_selected_item == 0) { + game_state.scene = ScenePlay; + notification_message(notification, &sequence_single_vibro); + } else if(popup_menu_selected_item == 1) { + notification_message(notification, &sequence_single_vibro); + game_init(); + } + break; } } break; @@ -357,12 +351,13 @@ static void render_callback(Canvas* const canvas) { canvas_set_color(canvas, ColorWhite); canvas_draw_box(canvas, 0, 0, 128, 64); - if(game_state.scene == ScenePlay || game_state.scene == SceneWin || game_state.scene == ScenePopup) { + if(game_state.scene == ScenePlay || game_state.scene == SceneWin || + game_state.scene == ScenePopup) { canvas_set_color(canvas, ColorBlack); board_draw(canvas); info_draw(canvas); - if (loaded_saving_ticks && game_state.scene != ScenePopup) { + if(loaded_saving_ticks && game_state.scene != ScenePopup) { canvas_set_color(canvas, ColorWhite); canvas_draw_rbox(canvas, 20, 24, 88, 16, 4); canvas_set_color(canvas, ColorBlack); @@ -380,23 +375,23 @@ static void render_callback(Canvas* const canvas) { canvas_draw_box(canvas, 10, 23, 108, 18); canvas_set_color(canvas, ColorBlack); canvas_draw_xbm(canvas, 14, 27, 100, 10, pic_puzzled); - } - else if (game_state.scene == ScenePopup) { - gray_screen(canvas); - canvas_set_color(canvas, ColorWhite); - canvas_draw_rbox(canvas, 28, 16, 72, 32, 4); - canvas_set_color(canvas, ColorBlack); - canvas_draw_rframe(canvas, 28, 16, 72, 32, 4); + } else if(game_state.scene == ScenePopup) { + gray_screen(canvas); + canvas_set_color(canvas, ColorWhite); + canvas_draw_rbox(canvas, 28, 16, 72, 32, 4); + canvas_set_color(canvas, ColorBlack); + canvas_draw_rframe(canvas, 28, 16, 72, 32, 4); - for(int i=0; i < POPUP_MENU_ITEMS; i++) { - if ( i == popup_menu_selected_item) { - canvas_set_color(canvas, ColorBlack); - canvas_draw_box(canvas, 34, 20 + 12 * i, 60, 12); - } - - canvas_set_color(canvas, i == popup_menu_selected_item ? ColorWhite : ColorBlack); - canvas_draw_str_aligned(canvas, 64, 26 + 12 * i, AlignCenter, AlignCenter, popup_menu_strings[i]); + for(int i = 0; i < POPUP_MENU_ITEMS; i++) { + if(i == popup_menu_selected_item) { + canvas_set_color(canvas, ColorBlack); + canvas_draw_box(canvas, 34, 20 + 12 * i, 60, 12); } + + canvas_set_color(canvas, i == popup_menu_selected_item ? ColorWhite : ColorBlack); + canvas_draw_str_aligned( + canvas, 64, 26 + 12 * i, AlignCenter, AlignCenter, popup_menu_strings[i]); + } } } @@ -417,18 +412,16 @@ static void game_event_handler(GameEvent const event) { key_stack_push(DirectionLeft); break; case InputKeyOk: - if (game_state.scene == ScenePlay) { + if(game_state.scene == ScenePlay) { game_state.scene = ScenePopup; key_stack_init(); - } - else + } else key_stack_push(DirectionNone); break; case InputKeyBack: - if (game_state.scene == ScenePopup) { + if(game_state.scene == ScenePopup) { game_state.scene = ScenePlay; - } - else { + } else { storage_game_state_save(); sandbox_loop_exit(); } @@ -458,12 +451,11 @@ int32_t game15_app() { loaded_saving_ticks = 0; if(storage_game_state_load()) { - if (game_state.scene != ScenePlay) + if(game_state.scene != ScenePlay) game_init(); else loaded_saving_ticks = FPS; - } - else + } else game_init(); sandbox_init( diff --git a/applications/plugins/game15/sandbox.c b/applications/plugins/game15/sandbox.c index ac4bffeec..e3b759fc8 100644 --- a/applications/plugins/game15/sandbox.c +++ b/applications/plugins/game15/sandbox.c @@ -13,11 +13,9 @@ SandboxEventHandler sandbox_user_event_handler; static void sandbox_render_callback(Canvas* const canvas, void* context) { UNUSED(context); - if (furi_mutex_acquire(sandbox_mutex, 25) != FuriStatusOk) - return; + if(furi_mutex_acquire(sandbox_mutex, 25) != FuriStatusOk) return; - if (sandbox_user_render_callback) - sandbox_user_render_callback(canvas); + if(sandbox_user_render_callback) sandbox_user_render_callback(canvas); furi_mutex_release(sandbox_mutex); } @@ -28,7 +26,7 @@ static void sandbox_input_callback(InputEvent* input_event, void* context) { furi_message_queue_put(sandbox_event_queue, &event, FuriWaitForever); } -static void sandbox_timer_callback(void* context ) { +static void sandbox_timer_callback(void* context) { UNUSED(context); GameEvent event = {.type = EventTypeTick}; furi_message_queue_put(sandbox_event_queue, &event, 0); @@ -36,18 +34,17 @@ static void sandbox_timer_callback(void* context ) { void sandbox_loop() { sandbox_loop_processing = true; - while( sandbox_loop_processing ) { + while(sandbox_loop_processing) { GameEvent event; FuriStatus event_status = furi_message_queue_get(sandbox_event_queue, &event, 100); - if (event_status != FuriStatusOk) { + if(event_status != FuriStatusOk) { // timeout continue; } furi_mutex_acquire(sandbox_mutex, FuriWaitForever); - if (sandbox_user_event_handler) - sandbox_user_event_handler(event); + if(sandbox_user_event_handler) sandbox_user_event_handler(event); view_port_update(sandbox_view_port); furi_mutex_release(sandbox_mutex); @@ -58,8 +55,10 @@ void sandbox_loop_exit() { sandbox_loop_processing = false; } -void sandbox_init(uint8_t fps, SandboxRenderCallback u_render_callback, SandboxEventHandler u_event_handler) -{ +void sandbox_init( + uint8_t fps, + SandboxRenderCallback u_render_callback, + SandboxEventHandler u_event_handler) { sandbox_user_render_callback = u_render_callback; sandbox_user_event_handler = u_event_handler; @@ -73,17 +72,15 @@ void sandbox_init(uint8_t fps, SandboxRenderCallback u_render_callback, SandboxE sandbox_gui = furi_record_open(RECORD_GUI); gui_add_view_port(sandbox_gui, sandbox_view_port, GuiLayerFullscreen); - if (fps > 0) { + if(fps > 0) { sandbox_timer = furi_timer_alloc(sandbox_timer_callback, FuriTimerTypePeriodic, NULL); furi_timer_start(sandbox_timer, furi_kernel_get_tick_frequency() / fps); } else sandbox_timer = NULL; } -void sandbox_free() -{ - if (sandbox_timer) - furi_timer_free(sandbox_timer); +void sandbox_free() { + if(sandbox_timer) furi_timer_free(sandbox_timer); gui_remove_view_port(sandbox_gui, sandbox_view_port); view_port_enabled_set(sandbox_view_port, false); diff --git a/applications/plugins/ocarina/ocarina.c b/applications/plugins/ocarina/ocarina.c index 7bf3b54ae..3195ebaf4 100644 --- a/applications/plugins/ocarina/ocarina.c +++ b/applications/plugins/ocarina/ocarina.c @@ -40,7 +40,6 @@ void input_callback(InputEvent* input, void* ctx) { Ocarina* ocarina_alloc() { Ocarina* instance = malloc(sizeof(Ocarina)); - instance->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal); instance->event_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); @@ -63,7 +62,7 @@ void ocarina_free(Ocarina* instance) { furi_message_queue_free(instance->event_queue); furi_mutex_free(instance->model_mutex); - + furi_hal_speaker_stop(); free(instance); @@ -86,10 +85,10 @@ int32_t ocarina_app(void* p) { if(event.type == InputTypePress) { switch(event.key) { case InputKeyUp: - furi_hal_speaker_start(NOTE_UP, volume); + furi_hal_speaker_start(NOTE_UP, volume); break; case InputKeyDown: - furi_hal_speaker_start(NOTE_DOWN, volume); + furi_hal_speaker_start(NOTE_DOWN, volume); break; case InputKeyLeft: furi_hal_speaker_start(NOTE_LEFT, volume); @@ -98,18 +97,17 @@ int32_t ocarina_app(void* p) { furi_hal_speaker_start(NOTE_RIGHT, volume); break; case InputKeyOk: - furi_hal_speaker_start(NOTE_OK, volume); + furi_hal_speaker_start(NOTE_OK, volume); break; case InputKeyBack: processing = false; break; } - } else if (event.type == InputTypeRelease) { + } else if(event.type == InputTypeRelease) { furi_hal_speaker_stop(); } } - furi_mutex_release(ocarina->model_mutex); view_port_update(ocarina->view_port); // signals our draw callback } diff --git a/applications/plugins/sam/sam_app.cpp b/applications/plugins/sam/sam_app.cpp index 7358592e0..4b218d1f7 100644 --- a/applications/plugins/sam/sam_app.cpp +++ b/applications/plugins/sam/sam_app.cpp @@ -17,8 +17,7 @@ extern "C" int32_t sam_app_yes(void* p) { UNUSED(p); voice.begin(); - voice.say( - "Yes"); + voice.say("Yes"); return 0; } @@ -27,8 +26,7 @@ extern "C" int32_t sam_app_no(void* p) { UNUSED(p); voice.begin(); - voice.say( - "No"); + voice.say("No"); return 0; } \ No newline at end of file