[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:
SG
2022-09-15 02:11:38 +10:00
committed by Aleksandr Kutuzov
parent 0f6f9ad52e
commit b9a766d909
895 changed files with 8862 additions and 1465 deletions

View File

@@ -0,0 +1,30 @@
#include "file_browser_scene.h"
// Generate scene on_enter handlers array
#define ADD_SCENE(prefix, name, id) prefix##_scene_##name##_on_enter,
void (*const file_browser_scene_on_enter_handlers[])(void*) = {
#include "file_browser_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 file_browser_scene_on_event_handlers[])(void* context, SceneManagerEvent event) = {
#include "file_browser_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 file_browser_scene_on_exit_handlers[])(void* context) = {
#include "file_browser_scene_config.h"
};
#undef ADD_SCENE
// Initialize scene handlers configuration structure
const SceneManagerHandlers file_browser_scene_handlers = {
.on_enter_handlers = file_browser_scene_on_enter_handlers,
.on_event_handlers = file_browser_scene_on_event_handlers,
.on_exit_handlers = file_browser_scene_on_exit_handlers,
.scene_num = FileBrowserSceneNum,
};

View File

@@ -0,0 +1,29 @@
#pragma once
#include <gui/scene_manager.h>
// Generate scene id and total number
#define ADD_SCENE(prefix, name, id) FileBrowserScene##id,
typedef enum {
#include "file_browser_scene_config.h"
FileBrowserSceneNum,
} FileBrowserScene;
#undef ADD_SCENE
extern const SceneManagerHandlers file_browser_scene_handlers;
// Generate scene on_enter handlers declaration
#define ADD_SCENE(prefix, name, id) void prefix##_scene_##name##_on_enter(void*);
#include "file_browser_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 "file_browser_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 "file_browser_scene_config.h"
#undef ADD_SCENE

View File

@@ -0,0 +1,43 @@
#include "../file_browser_app_i.h"
#include <core/check.h>
#include <core/log.h>
#include "furi_hal.h"
#include "m-string.h"
#define DEFAULT_PATH "/"
#define EXTENSION "*"
bool file_browser_scene_browser_on_event(void* context, SceneManagerEvent event) {
UNUSED(context);
FileBrowserApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
scene_manager_next_scene(app->scene_manager, FileBrowserSceneResult);
consumed = true;
} else if(event.type == SceneManagerEventTypeTick) {
}
return consumed;
}
static void file_browser_callback(void* context) {
FileBrowserApp* app = context;
furi_assert(app);
view_dispatcher_send_custom_event(app->view_dispatcher, SceneManagerEventTypeCustom);
}
void file_browser_scene_browser_on_enter(void* context) {
FileBrowserApp* app = context;
file_browser_set_callback(app->file_browser, file_browser_callback, app);
file_browser_start(app->file_browser, app->file_path);
view_dispatcher_switch_to_view(app->view_dispatcher, FileBrowserAppViewBrowser);
}
void file_browser_scene_browser_on_exit(void* context) {
FileBrowserApp* app = context;
file_browser_stop(app->file_browser);
}

View File

@@ -0,0 +1,3 @@
ADD_SCENE(file_browser, start, Start)
ADD_SCENE(file_browser, browser, Browser)
ADD_SCENE(file_browser, result, Result)

View File

@@ -0,0 +1,36 @@
#include "../file_browser_app_i.h"
#include "furi_hal.h"
#include "m-string.h"
void file_browser_scene_result_ok_callback(InputType type, void* context) {
furi_assert(context);
FileBrowserApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, type);
}
bool file_browser_scene_result_on_event(void* context, SceneManagerEvent event) {
UNUSED(context);
//FileBrowserApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
} else if(event.type == SceneManagerEventTypeTick) {
}
return consumed;
}
void file_browser_scene_result_on_enter(void* context) {
FileBrowserApp* app = context;
widget_add_string_multiline_element(
app->widget, 64, 10, AlignCenter, AlignTop, FontSecondary, string_get_cstr(app->file_path));
view_dispatcher_switch_to_view(app->view_dispatcher, FileBrowserAppViewResult);
}
void file_browser_scene_result_on_exit(void* context) {
UNUSED(context);
FileBrowserApp* app = context;
widget_reset(app->widget);
}

View File

@@ -0,0 +1,46 @@
#include "../file_browser_app_i.h"
#include <furi_hal.h>
#include <gui/modules/widget_elements/widget_element_i.h>
#include <storage/storage.h>
static void
file_browser_scene_start_ok_callback(GuiButtonType result, InputType type, void* context) {
UNUSED(result);
furi_assert(context);
FileBrowserApp* app = context;
if(type == InputTypeShort) {
view_dispatcher_send_custom_event(app->view_dispatcher, type);
}
}
bool file_browser_scene_start_on_event(void* context, SceneManagerEvent event) {
FileBrowserApp* app = context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
string_set_str(app->file_path, ANY_PATH("badusb/demo_windows.txt"));
scene_manager_next_scene(app->scene_manager, FileBrowserSceneBrowser);
consumed = true;
} else if(event.type == SceneManagerEventTypeTick) {
}
return consumed;
}
void file_browser_scene_start_on_enter(void* context) {
FileBrowserApp* app = context;
widget_add_string_multiline_element(
app->widget, 64, 20, AlignCenter, AlignTop, FontSecondary, "Press OK to start");
widget_add_button_element(
app->widget, GuiButtonTypeCenter, "Ok", file_browser_scene_start_ok_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, FileBrowserAppViewStart);
}
void file_browser_scene_start_on_exit(void* context) {
UNUSED(context);
FileBrowserApp* app = context;
widget_reset(app->widget);
}