parent
6d7ecf9a44
commit
f0bda07742
@ -9,7 +9,6 @@
|
||||
typedef struct {
|
||||
FuriApp* handler;
|
||||
Widget* widget;
|
||||
MenuItem* menu_plugins;
|
||||
const FlipperStartupApp* current_app;
|
||||
} AppLoaderState;
|
||||
|
||||
@ -44,6 +43,8 @@ static void input_callback(InputEvent* input_event, void* _ctx) {
|
||||
static void handle_menu(void* _ctx) {
|
||||
AppLoaderContext* ctx = (AppLoaderContext*)_ctx;
|
||||
|
||||
if(ctx->app->app == NULL) return;
|
||||
|
||||
widget_enabled_set(ctx->state->widget, true);
|
||||
|
||||
// TODO how to call this?
|
||||
@ -56,6 +57,8 @@ static void handle_menu(void* _ctx) {
|
||||
static void handle_cli(string_t args, void* _ctx) {
|
||||
AppLoaderContext* ctx = (AppLoaderContext*)_ctx;
|
||||
|
||||
if(ctx->app->app == NULL) return;
|
||||
|
||||
cli_print("Starting furi application\r\n");
|
||||
|
||||
ctx->state->current_app = ctx->app;
|
||||
@ -80,8 +83,6 @@ void app_loader(void* p) {
|
||||
widget_draw_callback_set(state.widget, render_callback, &state);
|
||||
widget_input_callback_set(state.widget, input_callback, &state);
|
||||
|
||||
state.menu_plugins = menu_item_alloc_menu("Plugins", assets_icons_get(A_Plugins_14));
|
||||
|
||||
ValueMutex* menu_mutex = furi_open("menu");
|
||||
if(menu_mutex == NULL) {
|
||||
printf("menu is not available\n");
|
||||
@ -98,19 +99,25 @@ void app_loader(void* p) {
|
||||
}
|
||||
gui->add_widget(gui, state.widget, GuiLayerFullscreen);
|
||||
|
||||
{
|
||||
// FURI startup
|
||||
const size_t flipper_app_count = sizeof(FLIPPER_APPS) / sizeof(FLIPPER_APPS[0]);
|
||||
const size_t flipper_plugins_count = sizeof(FLIPPER_PLUGINS) / sizeof(FLIPPER_PLUGINS[0]);
|
||||
|
||||
// Main menu
|
||||
with_value_mutex(
|
||||
menu_mutex, (Menu * menu) {
|
||||
for(size_t i = 0; i < flipper_app_count; i++) {
|
||||
AppLoaderContext* ctx = furi_alloc(sizeof(AppLoaderContext));
|
||||
ctx->state = &state;
|
||||
ctx->app = &FLIPPER_APPS[i];
|
||||
|
||||
menu_item_subitem_add(
|
||||
state.menu_plugins,
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function(
|
||||
FLIPPER_APPS[i].name, assets_icons_get(A_Infrared_14), handle_menu, ctx));
|
||||
FLIPPER_APPS[i].name,
|
||||
assets_icons_get(FLIPPER_APPS[i].icon),
|
||||
handle_menu,
|
||||
ctx));
|
||||
|
||||
// Add cli command
|
||||
if(cli) {
|
||||
@ -121,30 +128,10 @@ void app_loader(void* p) {
|
||||
string_clear(cli_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
with_value_mutex(
|
||||
menu_mutex, (Menu * menu) {
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function("Sub-1 GHz", assets_icons_get(A_Sub1ghz_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function("125kHz", assets_icons_get(A_125khz_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function("Infrared", assets_icons_get(A_Infrared_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function("iButton", assets_icons_get(A_iButton_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function(
|
||||
"Bluetooth", assets_icons_get(A_Bluetooth_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu, menu_item_alloc_function("GPIO", assets_icons_get(A_GPIO_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu, menu_item_alloc_function("NFC", assets_icons_get(A_NFC_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu, menu_item_alloc_function("U2F", assets_icons_get(A_U2F_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
@ -153,7 +140,6 @@ void app_loader(void* p) {
|
||||
"File Manager", assets_icons_get(A_FileManager_14), NULL, NULL));
|
||||
menu_item_add(
|
||||
menu, menu_item_alloc_function("Games", assets_icons_get(A_Games_14), NULL, NULL));
|
||||
menu_item_add(menu, state.menu_plugins);
|
||||
menu_item_add(
|
||||
menu,
|
||||
menu_item_alloc_function("Passport", assets_icons_get(A_Passport_14), NULL, NULL));
|
||||
@ -162,6 +148,38 @@ void app_loader(void* p) {
|
||||
menu_item_alloc_function("Settings", assets_icons_get(A_Settings_14), NULL, NULL));
|
||||
});
|
||||
|
||||
// plugins
|
||||
with_value_mutex(
|
||||
menu_mutex, (Menu * menu) {
|
||||
MenuItem* menu_plugins =
|
||||
menu_item_alloc_menu("Plugins", assets_icons_get(A_Plugins_14));
|
||||
|
||||
for(size_t i = 0; i < flipper_plugins_count; i++) {
|
||||
AppLoaderContext* ctx = furi_alloc(sizeof(AppLoaderContext));
|
||||
ctx->state = &state;
|
||||
ctx->app = &FLIPPER_PLUGINS[i];
|
||||
|
||||
menu_item_subitem_add(
|
||||
menu_plugins,
|
||||
menu_item_alloc_function(
|
||||
FLIPPER_PLUGINS[i].name,
|
||||
assets_icons_get(FLIPPER_PLUGINS[i].icon),
|
||||
handle_menu,
|
||||
ctx));
|
||||
|
||||
// Add cli command
|
||||
if(cli) {
|
||||
string_t cli_name;
|
||||
string_init_set_str(cli_name, "app_");
|
||||
string_cat_str(cli_name, FLIPPER_PLUGINS[i].name);
|
||||
cli_add_command(cli, string_get_cstr(cli_name), handle_cli, ctx);
|
||||
string_clear(cli_name);
|
||||
}
|
||||
}
|
||||
|
||||
menu_item_add(menu, menu_plugins);
|
||||
});
|
||||
|
||||
printf("[app loader] start\n");
|
||||
|
||||
osThreadSuspend(self_id);
|
||||
|
@ -42,98 +42,146 @@ void floopper_bloopper(void* p);
|
||||
|
||||
const FlipperStartupApp FLIPPER_STARTUP[] = {
|
||||
#ifdef APP_DISPLAY
|
||||
{.app = display_u8g2, .name = "display_u8g2", .libs = {0}},
|
||||
{.app = display_u8g2, .name = "display_u8g2", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_CLI
|
||||
{.app = cli_task, .name = "cli_task", .libs = {0}},
|
||||
{.app = cli_task, .name = "cli_task", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_BLINK
|
||||
{.app = application_blink, .name = "blink", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
{.app = application_blink,
|
||||
.name = "blink",
|
||||
.libs = {1, FURI_LIB{"input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_INPUT
|
||||
{.app = input_task, .name = "input_task", .libs = {0}},
|
||||
{.app = input_task, .name = "input_task", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_INPUT_DUMP
|
||||
{.app = application_input_dump, .name = "input dump", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
{.app = application_input_dump,
|
||||
.name = "input dump",
|
||||
.libs = {1, FURI_LIB{"input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_GUI
|
||||
{.app = backlight_control, .name = "backlight_control", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
{.app = gui_task, .name = "gui_task", .libs = {0}},
|
||||
{.app = backlight_control,
|
||||
.name = "backlight_control",
|
||||
.libs = {1, FURI_LIB{"input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
{.app = gui_task, .name = "gui_task", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_MENU
|
||||
{.app = menu_task, .name = "menu_task", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = app_loader, .name = "app_loader", .libs = {2, FURI_LIB{"menu_task", "cli_task"}}},
|
||||
{.app = menu_task,
|
||||
.name = "menu_task",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
{.app = app_loader,
|
||||
.name = "app_loader",
|
||||
.libs = {2, FURI_LIB{"menu_task", "cli_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_IRUKAGOTCHI
|
||||
{.app = irukagotchi_task, .name = "irukagotchi_task", .libs = {1, FURI_LIB{"menu_task"}}},
|
||||
{.app = irukagotchi_task,
|
||||
.name = "irukagotchi_task",
|
||||
.libs = {1, FURI_LIB{"menu_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_POWER
|
||||
{.app = power_task, .name = "power_task", .libs = {2, FURI_LIB{"cli_task", "gui_task"}}},
|
||||
{.app = power_task,
|
||||
.name = "power_task",
|
||||
.libs = {2, FURI_LIB{"cli_task", "gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_CC1101
|
||||
{.app = cc1101_workaround, .name = "cc1101 workaround", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = cc1101_workaround,
|
||||
.name = "cc1101 workaround",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_LF_RFID
|
||||
{.app = lf_rfid_workaround, .name = "lf rfid workaround", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = lf_rfid_workaround,
|
||||
.name = "lf rfid workaround",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_IRDA
|
||||
{.app = irda, .name = "irda", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = irda, .name = "irda", .libs = {1, FURI_LIB{"gui_task"}}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_NFC
|
||||
{.app = nfc_task, .name = "nfc_task", .libs = {1, FURI_LIB{"menu_task"}}},
|
||||
{.app = nfc_task, .name = "nfc_task", .libs = {1, FURI_LIB{"menu_task"}}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_TEST
|
||||
{.app = flipper_test_app, .name = "test app", .libs = {0}},
|
||||
{.app = flipper_test_app, .name = "test app", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_IPC
|
||||
{.app = application_ipc_display, .name = "ipc display", .libs = {0}},
|
||||
{.app = application_ipc_widget, .name = "ipc widget", .libs = {0}},
|
||||
{.app = application_ipc_display, .name = "ipc display", .libs = {0}, .icon = A_Plugins_14},
|
||||
{.app = application_ipc_widget, .name = "ipc widget", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_QRCODE
|
||||
{.app = u8g2_qrcode, .name = "u8g2_qrcode", .libs = {1, FURI_LIB{"display_u8g2"}}},
|
||||
{.app = u8g2_qrcode,
|
||||
.name = "u8g2_qrcode",
|
||||
.libs = {1, FURI_LIB{"display_u8g2"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_FATFS
|
||||
{.app = fatfs_list, .name = "fatfs_list", .libs = {2, FURI_LIB{"display_u8g2", "input_task"}}},
|
||||
{.app = fatfs_list,
|
||||
.name = "fatfs_list",
|
||||
.libs = {2, FURI_LIB{"display_u8g2", "input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_DISPLAY
|
||||
{.app = u8g2_example, .name = "u8g2_example", .libs = {1, FURI_LIB{"display_u8g2"}}},
|
||||
{.app = u8g2_example,
|
||||
.name = "u8g2_example",
|
||||
.libs = {1, FURI_LIB{"display_u8g2"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_SPEAKER_DEMO
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = {0}},
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_SD_TEST
|
||||
{.app = sd_card_test, .name = "sd_card_test", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = sd_card_test,
|
||||
.name = "sd_card_test",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_MUSIC_PLAYER
|
||||
{.app = music_player, .name = "music player", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = music_player,
|
||||
.name = "music player",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_IBUTTON
|
||||
{.app = app_ibutton, .name = "ibutton", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = app_ibutton,
|
||||
.name = "ibutton",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_GPIO_DEMO
|
||||
{.app = app_gpio_test, .name = "gpio test", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = app_gpio_test,
|
||||
.name = "gpio test",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef APP_FLOOPPER_BLOOPPER
|
||||
@ -141,53 +189,79 @@ const FlipperStartupApp FLIPPER_STARTUP[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
// Main menu APP
|
||||
const FlipperStartupApp FLIPPER_APPS[] = {
|
||||
#ifdef BUILD_EXAMPLE_BLINK
|
||||
{.app = application_blink, .name = "blink", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_EXAMPLE_UART_WRITE
|
||||
{.app = application_uart_write, .name = "uart write", .libs = {0}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_EXAMPLE_INPUT_DUMP
|
||||
{.app = application_input_dump, .name = "input dump", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_CC1101
|
||||
{.app = cc1101_workaround, .name = "cc1101 workaround", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = cc1101_workaround,
|
||||
.name = "Sub-1 GHz",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Sub1ghz_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_LF_RFID
|
||||
{.app = lf_rfid_workaround, .name = "lf rfid workaround", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = lf_rfid_workaround,
|
||||
.name = "125 kHz RFID",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_125khz_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_IRDA
|
||||
{.app = irda, .name = "irda", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_SPEAKER_DEMO
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = {0}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_SD_TEST
|
||||
{.app = sd_card_test, .name = "sd_card_test", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_VIBRO_DEMO
|
||||
{.app = application_vibro, .name = "application_vibro", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_GPIO_DEMO
|
||||
{.app = app_gpio_test, .name = "gpio test", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = irda, .name = "Infrared", .libs = {1, FURI_LIB{"gui_task"}}, .icon = A_Infrared_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_IBUTTON
|
||||
{.app = app_ibutton, .name = "ibutton", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = app_ibutton,
|
||||
.name = "iButton",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_iButton_14},
|
||||
#endif
|
||||
|
||||
{.app = NULL, .name = "Bluetooth", .libs = {0}, .icon = A_Bluetooth_14},
|
||||
|
||||
#ifdef BUILD_GPIO_DEMO
|
||||
{.app = app_gpio_test, .name = "GPIO", .libs = {1, FURI_LIB{"gui_task"}}, .icon = A_GPIO_14},
|
||||
#endif
|
||||
};
|
||||
|
||||
// Plugin menu
|
||||
const FlipperStartupApp FLIPPER_PLUGINS[] = {
|
||||
#ifdef BUILD_EXAMPLE_BLINK
|
||||
{.app = application_blink,
|
||||
.name = "blink",
|
||||
.libs = {1, FURI_LIB{"input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_EXAMPLE_INPUT_DUMP
|
||||
{.app = application_input_dump,
|
||||
.name = "input dump",
|
||||
.libs = {1, FURI_LIB{"input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_SPEAKER_DEMO
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = {0}, .icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_SD_TEST
|
||||
{.app = sd_card_test,
|
||||
.name = "sd_card_test",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_VIBRO_DEMO
|
||||
{.app = application_vibro,
|
||||
.name = "application_vibro",
|
||||
.libs = {1, FURI_LIB{"input_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_MUSIC_PLAYER
|
||||
{.app = music_player, .name = "music player", .libs = {1, FURI_LIB{"gui_task"}}},
|
||||
{.app = music_player,
|
||||
.name = "music player",
|
||||
.libs = {1, FURI_LIB{"gui_task"}},
|
||||
.icon = A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_FLOOPPER_BLOOPPER
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "assets_icons.h"
|
||||
|
||||
#define MAX_TASK_RECORDS 8
|
||||
#define MAX_RECORD_SUBSCRIBERS 8
|
||||
|
||||
@ -85,6 +87,7 @@ typedef struct {
|
||||
FlipperApplication app;
|
||||
const char* name;
|
||||
FlipperAppLibrary libs;
|
||||
IconName icon;
|
||||
} FlipperStartupApp;
|
||||
|
||||
// Init core
|
||||
|
Loading…
Reference in New Issue
Block a user