[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:
9
applications/settings/system/application.fam
Normal file
9
applications/settings/system/application.fam
Normal file
@@ -0,0 +1,9 @@
|
||||
App(
|
||||
appid="system_settings",
|
||||
name="System",
|
||||
apptype=FlipperAppType.SETTINGS,
|
||||
entry_point="system_settings_app",
|
||||
requires=["gui"],
|
||||
stack_size=1 * 1024,
|
||||
order=70,
|
||||
)
|
112
applications/settings/system/system_settings.c
Normal file
112
applications/settings/system/system_settings.c
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "system_settings.h"
|
||||
#include <loader/loader.h>
|
||||
#include <lib/toolbox/value_index.h>
|
||||
|
||||
const char* const log_level_text[] = {
|
||||
"Default",
|
||||
"None",
|
||||
"Error",
|
||||
"Warning",
|
||||
"Info",
|
||||
"Debug",
|
||||
"Trace",
|
||||
};
|
||||
|
||||
const uint32_t log_level_value[] = {
|
||||
FuriLogLevelDefault,
|
||||
FuriLogLevelNone,
|
||||
FuriLogLevelError,
|
||||
FuriLogLevelWarn,
|
||||
FuriLogLevelInfo,
|
||||
FuriLogLevelDebug,
|
||||
FuriLogLevelTrace,
|
||||
};
|
||||
|
||||
static void log_level_changed(VariableItem* item) {
|
||||
// SystemSettings* app = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, log_level_text[index]);
|
||||
furi_hal_rtc_set_log_level(log_level_value[index]);
|
||||
}
|
||||
|
||||
const char* const debug_text[] = {
|
||||
"OFF",
|
||||
"ON",
|
||||
};
|
||||
|
||||
static void debug_changed(VariableItem* item) {
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(item, debug_text[index]);
|
||||
if(index) {
|
||||
furi_hal_rtc_set_flag(FuriHalRtcFlagDebug);
|
||||
} else {
|
||||
furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug);
|
||||
}
|
||||
loader_update_menu();
|
||||
}
|
||||
|
||||
static uint32_t system_settings_exit(void* context) {
|
||||
UNUSED(context);
|
||||
return VIEW_NONE;
|
||||
}
|
||||
|
||||
SystemSettings* system_settings_alloc() {
|
||||
SystemSettings* app = malloc(sizeof(SystemSettings));
|
||||
|
||||
// Load settings
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
|
||||
VariableItem* item;
|
||||
uint8_t value_index;
|
||||
app->var_item_list = variable_item_list_alloc();
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->var_item_list, "Log Level", COUNT_OF(log_level_text), log_level_changed, app);
|
||||
value_index = value_index_uint32(
|
||||
furi_hal_rtc_get_log_level(), log_level_value, COUNT_OF(log_level_text));
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, log_level_text[value_index]);
|
||||
|
||||
item = variable_item_list_add(
|
||||
app->var_item_list, "Debug", COUNT_OF(debug_text), debug_changed, app);
|
||||
value_index = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug) ? 1 : 0;
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, debug_text[value_index]);
|
||||
|
||||
view_set_previous_callback(
|
||||
variable_item_list_get_view(app->var_item_list), system_settings_exit);
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
SystemSettingsViewVarItemList,
|
||||
variable_item_list_get_view(app->var_item_list));
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, SystemSettingsViewVarItemList);
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
void system_settings_free(SystemSettings* app) {
|
||||
furi_assert(app);
|
||||
// Variable item list
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SystemSettingsViewVarItemList);
|
||||
variable_item_list_free(app->var_item_list);
|
||||
// View dispatcher
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
// Records
|
||||
furi_record_close(RECORD_GUI);
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t system_settings_app(void* p) {
|
||||
UNUSED(p);
|
||||
SystemSettings* app = system_settings_alloc();
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
system_settings_free(app);
|
||||
return 0;
|
||||
}
|
18
applications/settings/system/system_settings.h
Normal file
18
applications/settings/system/system_settings.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
|
||||
typedef struct {
|
||||
Gui* gui;
|
||||
ViewDispatcher* view_dispatcher;
|
||||
VariableItemList* var_item_list;
|
||||
} SystemSettings;
|
||||
|
||||
typedef enum {
|
||||
SystemSettingsViewVarItemList,
|
||||
} SystemSettingsView;
|
Reference in New Issue
Block a user