[FL-2627] Flipper applications: SDK, build and debug system (#1387)
* Added support for running applications from SD card (FAPs - Flipper Application Packages) * Added plugin_dist target for fbt to build FAPs * All apps of type FlipperAppType.EXTERNAL and FlipperAppType.PLUGIN are built as FAPs by default * Updated VSCode configuration for new fbt features - re-deploy stock configuration to use them * Added debugging support for FAPs with fbt debug & VSCode * Added public firmware API with automated versioning Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		| @@ -0,0 +1,30 @@ | ||||
| #include "storage_move_to_sd_scene.h" | ||||
|  | ||||
| // Generate scene on_enter handlers array | ||||
| #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter, | ||||
| void (*const storage_move_to_sd_on_enter_handlers[])(void*) = { | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
| }; | ||||
| #undef ADD_SCENE | ||||
|  | ||||
| // Generate scene on_event handlers array | ||||
| #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_event, | ||||
| bool (*const storage_move_to_sd_on_event_handlers[])(void* context, SceneManagerEvent event) = { | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
| }; | ||||
| #undef ADD_SCENE | ||||
|  | ||||
| // Generate scene on_exit handlers array | ||||
| #define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_exit, | ||||
| void (*const storage_move_to_sd_on_exit_handlers[])(void* context) = { | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
| }; | ||||
| #undef ADD_SCENE | ||||
|  | ||||
| // Initialize scene handlers configuration structure | ||||
| const SceneManagerHandlers storage_move_to_sd_scene_handlers = { | ||||
|     .on_enter_handlers = storage_move_to_sd_on_enter_handlers, | ||||
|     .on_event_handlers = storage_move_to_sd_on_event_handlers, | ||||
|     .on_exit_handlers = storage_move_to_sd_on_exit_handlers, | ||||
|     .scene_num = StorageMoveToSdSceneNum, | ||||
| }; | ||||
| @@ -0,0 +1,29 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <gui/scene_manager.h> | ||||
|  | ||||
| // Generate scene id and total number | ||||
| #define ADD_SCENE(prefix, name, id) StorageMoveToSd##id, | ||||
| typedef enum { | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
|     StorageMoveToSdSceneNum, | ||||
| } StorageMoveToSdScene; | ||||
| #undef ADD_SCENE | ||||
|  | ||||
| extern const SceneManagerHandlers storage_move_to_sd_scene_handlers; | ||||
|  | ||||
| // Generate scene on_enter handlers declaration | ||||
| #define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*); | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
| #undef ADD_SCENE | ||||
|  | ||||
| // Generate scene on_event handlers declaration | ||||
| #define ADD_SCENE(prefix, name, id) \ | ||||
|     bool prefix##_scene_##name##_on_event(void* context, SceneManagerEvent event); | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
| #undef ADD_SCENE | ||||
|  | ||||
| // Generate scene on_exit handlers declaration | ||||
| #define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_exit(void* context); | ||||
| #include "storage_move_to_sd_scene_config.h" | ||||
| #undef ADD_SCENE | ||||
| @@ -0,0 +1,2 @@ | ||||
| ADD_SCENE(storage_move_to_sd, confirm, Confirm) | ||||
| ADD_SCENE(storage_move_to_sd, progress, Progress) | ||||
| @@ -0,0 +1,70 @@ | ||||
| #include "../storage_move_to_sd.h" | ||||
| #include "gui/canvas.h" | ||||
| #include "gui/modules/widget_elements/widget_element_i.h" | ||||
| #include "storage/storage.h" | ||||
|  | ||||
| static void storage_move_to_sd_scene_confirm_widget_callback( | ||||
|     GuiButtonType result, | ||||
|     InputType type, | ||||
|     void* context) { | ||||
|     StorageMoveToSd* app = context; | ||||
|     furi_assert(app); | ||||
|     if(type == InputTypeShort) { | ||||
|         if(result == GuiButtonTypeRight) { | ||||
|             view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventConfirm); | ||||
|         } else if(result == GuiButtonTypeLeft) { | ||||
|             view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventExit); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| void storage_move_to_sd_scene_confirm_on_enter(void* context) { | ||||
|     StorageMoveToSd* app = context; | ||||
|  | ||||
|     widget_add_button_element( | ||||
|         app->widget, | ||||
|         GuiButtonTypeLeft, | ||||
|         "Cancel", | ||||
|         storage_move_to_sd_scene_confirm_widget_callback, | ||||
|         app); | ||||
|     widget_add_button_element( | ||||
|         app->widget, | ||||
|         GuiButtonTypeRight, | ||||
|         "Confirm", | ||||
|         storage_move_to_sd_scene_confirm_widget_callback, | ||||
|         app); | ||||
|  | ||||
|     widget_add_string_element( | ||||
|         app->widget, 64, 10, AlignCenter, AlignCenter, FontPrimary, "SD card inserted"); | ||||
|     widget_add_string_multiline_element( | ||||
|         app->widget, | ||||
|         64, | ||||
|         32, | ||||
|         AlignCenter, | ||||
|         AlignCenter, | ||||
|         FontSecondary, | ||||
|         "Move data from\ninternal storage to SD card?"); | ||||
|  | ||||
|     view_dispatcher_switch_to_view(app->view_dispatcher, StorageMoveToSdViewWidget); | ||||
| } | ||||
|  | ||||
| bool storage_move_to_sd_scene_confirm_on_event(void* context, SceneManagerEvent event) { | ||||
|     StorageMoveToSd* app = context; | ||||
|     bool consumed = false; | ||||
|  | ||||
|     if(event.type == SceneManagerEventTypeCustom) { | ||||
|         if(event.event == MoveToSdCustomEventConfirm) { | ||||
|             scene_manager_next_scene(app->scene_manager, StorageMoveToSdProgress); | ||||
|             consumed = true; | ||||
|         } else if(event.event == MoveToSdCustomEventExit) { | ||||
|             view_dispatcher_stop(app->view_dispatcher); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     return consumed; | ||||
| } | ||||
|  | ||||
| void storage_move_to_sd_scene_confirm_on_exit(void* context) { | ||||
|     StorageMoveToSd* app = context; | ||||
|     widget_reset(app->widget); | ||||
| } | ||||
| @@ -0,0 +1,31 @@ | ||||
| #include "../storage_move_to_sd.h" | ||||
|  | ||||
| void storage_move_to_sd_scene_progress_on_enter(void* context) { | ||||
|     StorageMoveToSd* app = context; | ||||
|  | ||||
|     widget_add_string_element( | ||||
|         app->widget, 64, 10, AlignCenter, AlignCenter, FontPrimary, "Moving..."); | ||||
|  | ||||
|     view_dispatcher_switch_to_view(app->view_dispatcher, StorageMoveToSdViewWidget); | ||||
|  | ||||
|     storage_move_to_sd_perform(); | ||||
|     view_dispatcher_send_custom_event(app->view_dispatcher, MoveToSdCustomEventExit); | ||||
| } | ||||
|  | ||||
| bool storage_move_to_sd_scene_progress_on_event(void* context, SceneManagerEvent event) { | ||||
|     StorageMoveToSd* app = context; | ||||
|     bool consumed = false; | ||||
|  | ||||
|     if(event.type == SceneManagerEventTypeCustom) { | ||||
|         view_dispatcher_stop(app->view_dispatcher); | ||||
|     } else if(event.type == SceneManagerEventTypeBack) { | ||||
|         consumed = true; | ||||
|     } | ||||
|  | ||||
|     return consumed; | ||||
| } | ||||
|  | ||||
| void storage_move_to_sd_scene_progress_on_exit(void* context) { | ||||
|     StorageMoveToSd* app = context; | ||||
|     widget_reset(app->widget); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user