From 7907cb232bda5af7c30c79c67ab353b2cefe57c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Sat, 7 Aug 2021 19:54:42 +0300 Subject: [PATCH] Applications: unified entry point naming scheme, drop dead code, cleanup. (#628) --- applications/accessor/accessor.cpp | 2 +- applications/applications.c | 276 +++++++----------- applications/applications.h | 2 +- applications/applications.mk | 168 ++++------- applications/archive/archive.c | 2 +- applications/bt/bt.c | 2 +- applications/cli/cli.c | 2 +- .../coreglitch_demo_0/coreglitch_demo_0.c | 92 ------ .../blink.c => debug_tools/blink_test.c} | 14 +- applications/debug_tools/keypad_test.c | 225 ++++++++++++++ .../vibro.c => debug_tools/vibro_test.c} | 10 +- applications/dialogs/dialogs.c | 2 +- applications/dolphin/dolphin.c | 2 +- applications/dolphin/passport/passport.c | 2 +- applications/examples/input_dump.c | 100 ------- applications/examples/keypad_test.c | 189 ------------ applications/examples/u8g2_example.c | 14 - applications/examples/u8g2_qrcode.c | 76 ----- applications/examples/uart_write.c | 35 --- applications/examples/vertical_submenu.c | 103 ------- applications/gpio-tester/gpio-tester.c | 4 +- applications/gui-test/gui-test.c | 239 --------------- applications/gui/gui.c | 2 +- applications/ibutton/ibutton.cpp | 2 +- applications/input/input.c | 2 +- applications/irda/irda-runner.cpp | 2 +- applications/loader/loader.c | 2 +- applications/menu/menu.c | 2 +- applications/music-player/music-player.c | 2 +- applications/nfc/nfc.c | 28 +- applications/notification/notification-app.c | 2 +- ...settings.c => notification-settings-app.c} | 2 +- applications/power-observer/power-observer.c | 2 +- applications/power/power.c | 2 +- .../storage-settings/storage-settings.c | 2 +- applications/storage/storage-test-app.c | 2 +- applications/storage/storage.c | 2 +- 37 files changed, 442 insertions(+), 1175 deletions(-) delete mode 100644 applications/coreglitch_demo_0/coreglitch_demo_0.c rename applications/{examples/blink.c => debug_tools/blink_test.c} (83%) create mode 100644 applications/debug_tools/keypad_test.c rename applications/{examples/vibro.c => debug_tools/vibro_test.c} (87%) delete mode 100644 applications/examples/input_dump.c delete mode 100644 applications/examples/keypad_test.c delete mode 100644 applications/examples/u8g2_example.c delete mode 100644 applications/examples/u8g2_qrcode.c delete mode 100644 applications/examples/uart_write.c delete mode 100644 applications/examples/vertical_submenu.c delete mode 100644 applications/gui-test/gui-test.c rename applications/notification/{notification-app-settings.c => notification-settings-app.c} (99%) diff --git a/applications/accessor/accessor.cpp b/applications/accessor/accessor.cpp index 25215827..8a3d839b 100644 --- a/applications/accessor/accessor.cpp +++ b/applications/accessor/accessor.cpp @@ -1,7 +1,7 @@ #include "accessor-app.h" // app enter function -extern "C" int32_t app_accessor(void* p) { +extern "C" int32_t accessor_app(void* p) { AccessorApp* app = new AccessorApp(); app->run(); delete app; diff --git a/applications/applications.c b/applications/applications.c index d6ea88fa..b4c24037 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -1,103 +1,106 @@ #include "applications.h" +#include -// Services and apps decalartion -int32_t application_vertical_screen(void* p); -int32_t irda_monitor_app(void* p); -int32_t flipper_test_app(void* p); -int32_t application_blink(void* p); -int32_t application_uart_write(void* p); -int32_t application_input_dump(void* p); -int32_t u8g2_example(void* p); -int32_t input_task(void* p); -int32_t menu_task(void* p); -int32_t coreglitch_demo_0(void* p); -int32_t u8g2_qrcode(void* p); -int32_t gui_task(void* p); -int32_t irda(void* p); -int32_t loader(void* p); -int32_t nfc_task(void* p); -int32_t dolphin_task(void* p); -int32_t power_task(void* p); -int32_t bt_task(void* p); -int32_t application_vibro(void* p); -int32_t app_gpio_test(void* p); -int32_t app_ibutton(void* p); -int32_t cli_task(void* p); -int32_t music_player(void* p); -int32_t sdnfc(void* p); -int32_t subghz_app(void* p); -int32_t gui_test(void* p); -int32_t keypad_test(void* p); -int32_t scene_app(void* p); -int32_t passport(void* p); -int32_t app_accessor(void* p); -int32_t app_archive(void* p); -int32_t notification_app(void* p); -int32_t scened_app(void* p); -int32_t lfrfid_app(void* p); -int32_t lfrfid_debug_app(void* p); -int32_t storage_app(void* p); -int32_t storage_app_test(void* p); -int32_t dialogs_app(void* p); -int32_t power_observer(void* p); +// Services +extern int32_t bt_srv(void* p); +extern int32_t cli_srv(void* p); +extern int32_t dialogs_srv(void* p); +extern int32_t dolphin_srv(void* p); +extern int32_t gui_srv(void* p); +extern int32_t input_srv(void* p); +extern int32_t loader_srv(void* p); +extern int32_t menu_srv(void* p); +extern int32_t notification_srv(void* p); +extern int32_t power_observer_srv(void* p); +extern int32_t power_srv(void* p); +extern int32_t storage_srv(void* p); + +// Apps +extern int32_t accessor_app(void* p); +extern int32_t archive_app(void* p); +extern int32_t blink_test_app(void* p); +extern int32_t flipper_test_app(void* p); +extern int32_t gpio_test_app(void* p); +extern int32_t ibutton_app(void* p); +extern int32_t irda_app(void* p); +extern int32_t irda_monitor_app(void* p); +extern int32_t keypad_test_app(void* p); +extern int32_t lfrfid_app(void* p); +extern int32_t lfrfid_debug_app(void* p); +extern int32_t nfc_app(void* p); +extern int32_t passport_app(void* p); +extern int32_t scene_app(void* p); +extern int32_t scened_app(void* p); +extern int32_t storage_test_app(void* p); +extern int32_t subghz_app(void* p); +extern int32_t vibro_test_app(void* p); + +// Plugins +extern int32_t music_player_app(void* p); // On system start hooks declaration -void irda_cli_init(); -void nfc_cli_init(); -void subghz_cli_init(); -void bt_cli_init(); -void lfrfid_cli_init(); -void ibutton_cli_init(); -void storage_cli_init(); +extern void bt_cli_init(); +extern void ibutton_cli_init(); +extern void irda_cli_init(); +extern void lfrfid_cli_init(); +extern void nfc_cli_init(); +extern void storage_cli_init(); +extern void subghz_cli_init(); // Settings -int32_t notification_app_settings(void* p); -int32_t storage_settings(void* p); +extern int32_t notification_settings_app(void* p); +extern int32_t storage_settings_app(void* p); const FlipperApplication FLIPPER_SERVICES[] = { +/* Services */ +#ifdef SRV_BT + {.app = bt_srv, .name = "BT", .stack_size = 1024, .icon = NULL}, +#endif + #ifdef SRV_CLI - {.app = cli_task, .name = "cli_task", .stack_size = 4096, .icon = &A_Plugins_14}, + {.app = cli_srv, .name = "Cli", .stack_size = 4096, .icon = NULL}, #endif -#ifdef SRV_EXAMPLE_BLINK - {.app = application_blink, .name = "blink", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_INPUT - {.app = input_task, .name = "input_task", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_EXAMPLE_INPUT_DUMP - {.app = application_input_dump, - .name = "input dump", - .stack_size = 1024, - .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_GUI - // TODO: fix stack size when sd api will be in separate thread - {.app = gui_task, .name = "gui_task", .stack_size = 8192, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_MENU - {.app = menu_task, .name = "menu_task", .stack_size = 1024, .icon = &A_Plugins_14}, - {.app = loader, .name = "loader", .stack_size = 1024, .icon = &A_Plugins_14}, +#ifdef SRV_DIALOGS + {.app = dialogs_srv, .name = "Dialogs", .stack_size = 1024, .icon = NULL}, #endif #ifdef SRV_DOLPHIN - {.app = dolphin_task, .name = "dolphin_task", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = dolphin_srv, .name = "Dolphin", .stack_size = 1024, .icon = NULL}, +#endif + +#ifdef SRV_GUI + {.app = gui_srv, .name = "Gui", .stack_size = 8192, .icon = NULL}, +#endif + +#ifdef SRV_INPUT + {.app = input_srv, .name = "Input", .stack_size = 1024, .icon = NULL}, +#endif + +#ifdef SRV_MENU + {.app = menu_srv, .name = "Menu", .stack_size = 1024, .icon = NULL}, + {.app = loader_srv, .name = "Loader", .stack_size = 1024, .icon = NULL}, +#endif + +#ifdef SRV_NOTIFICATION + {.app = notification_srv, .name = "Notification", .stack_size = 1024, .icon = NULL}, #endif #ifdef SRV_POWER - {.app = power_task, .name = "power_task", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = power_srv, .name = "Power", .stack_size = 1024, .icon = NULL}, #endif #ifdef SRV_POWER_OBSERVER - {.app = power_observer, .name = "power_observer", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = power_observer_srv, .name = "PowerObserver", .stack_size = 1024, .icon = NULL}, #endif -#ifdef SRV_BT - {.app = bt_task, .name = "bt_task", .stack_size = 1024, .icon = &A_Plugins_14}, +#ifdef SRV_STORAGE + {.app = storage_srv, .name = "Storage", .stack_size = 4096, .icon = NULL}, +#endif + +/* Fake services (autorun) */ +#ifdef SRV_BLINK + {.app = blink_test_app, .name = "Blink", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef SRV_LF_RFID @@ -105,66 +108,31 @@ const FlipperApplication FLIPPER_SERVICES[] = { #endif #ifdef SRV_IRDA - {.app = irda, .name = "irda", .stack_size = 1024 * 3, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_EXAMPLE_QRCODE - {.app = u8g2_qrcode, .name = "u8g2_qrcode", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_EXAMPLE_DISPLAY - {.app = u8g2_example, .name = "u8g2_example", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_SPEAKER_DEMO - {.app = coreglitch_demo_0, - .name = "coreglitch_demo_0", - .stack_size = 1024, - .icon = &A_Plugins_14}, + {.app = irda_app, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Plugins_14}, #endif #ifdef SRV_MUSIC_PLAYER - {.app = music_player, .name = "music player", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = music_player_app, .name = "Music Player", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef SRV_IBUTTON - {.app = app_ibutton, .name = "ibutton", .stack_size = 2048, .icon = &A_Plugins_14}, + {.app = ibutton_app, .name = "iButton", .stack_size = 2048, .icon = &A_Plugins_14}, #endif -#ifdef SRV_GPIO_DEMO - {.app = app_gpio_test, .name = "gpio test", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_SDNFC - {.app = sdnfc, .name = "sdnfc", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_GUI_TEST - {.app = gui_test, .name = "gui_test", .stack_size = 1024, .icon = &A_Plugins_14}, +#ifdef SRV_GPIO_TEST + {.app = gpio_test_app, .name = "GPIO Test", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef SRV_KEYPAD_TEST - {.app = keypad_test, .name = "keypad_test", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = keypad_test_app, .name = "Keypad Test", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef SRV_ACCESSOR - {.app = app_accessor, .name = "accessor", .stack_size = 4096, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_NOTIFICATION - {.app = notification_app, .name = "notification", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_STORAGE - {.app = storage_app, .name = "storage", .stack_size = 4096, .icon = &A_Plugins_14}, + {.app = accessor_app, .name = "Accessor", .stack_size = 4096, .icon = &A_Plugins_14}, #endif #ifdef SRV_STORAGE_TEST - {.app = storage_app_test, .name = "storage test", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef SRV_DIALOGS - {.app = dialogs_app, .name = "dialogs", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = storage_test_app, .name = "Storage Test", .stack_size = 1024, .icon = &A_Plugins_14}, #endif }; @@ -174,29 +142,27 @@ const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(FlipperA const FlipperApplication FLIPPER_APPS[] = { #ifdef APP_IBUTTON - {.app = app_ibutton, .name = "iButton", .stack_size = 2048, .icon = &A_iButton_14}, + {.app = ibutton_app, .name = "iButton", .stack_size = 2048, .icon = &A_iButton_14}, #endif #ifdef APP_NFC - {.app = nfc_task, .name = "NFC", .stack_size = 4096, .icon = &A_NFC_14}, + {.app = nfc_app, .name = "NFC", .stack_size = 4096, .icon = &A_NFC_14}, #endif #ifdef APP_SUBGHZ - // TODO: decrease stack after SD API refactoring - {.app = subghz_app, .name = "Sub-1 GHz", .stack_size = 4096, .icon = &A_Sub1ghz_14}, + {.app = subghz_app, .name = "Sub-1 GHz", .stack_size = 2048, .icon = &A_Sub1ghz_14}, #endif #ifdef APP_LF_RFID - // TODO: fix stack size when sd api will be in separate thread {.app = lfrfid_app, .name = "125 kHz RFID", .stack_size = 2048, .icon = &A_125khz_14}, #endif #ifdef APP_IRDA - {.app = irda, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Infrared_14}, + {.app = irda_app, .name = "Infrared", .stack_size = 1024 * 3, .icon = &A_Infrared_14}, #endif -#ifdef APP_GPIO_DEMO - {.app = app_gpio_test, .name = "GPIO", .stack_size = 1024, .icon = &A_GPIO_14}, +#ifdef APP_GPIO_TEST + {.app = gpio_test_app, .name = "GPIO", .stack_size = 1024, .icon = &A_GPIO_14}, #endif }; @@ -233,51 +199,28 @@ const size_t FLIPPER_ON_SYSTEM_START_COUNT = const FlipperApplication FLIPPER_PLUGINS[] = { #ifdef APP_MUSIC_PLAYER - {.app = music_player, .name = "music player", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = music_player_app, .name = "Music Player", .stack_size = 1024, .icon = &A_Plugins_14}, #endif - -#ifdef APP_SPEAKER_DEMO - {.app = coreglitch_demo_0, - .name = "coreglitch_demo_0", - .stack_size = 1024, - .icon = &A_Plugins_14}, -#endif - }; const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApplication); // Plugin menu const FlipperApplication FLIPPER_DEBUG_APPS[] = { -#ifdef APP_EXAMPLE_BLINK - {.app = application_blink, .name = "blink", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef APP_EXAMPLE_INPUT_DUMP - {.app = application_input_dump, - .name = "input dump", - .stack_size = 1024, - .icon = &A_Plugins_14}, +#ifdef APP_BLINK + {.app = blink_test_app, .name = "Blink Test", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef APP_VIBRO_DEMO - {.app = application_vibro, .name = "vibro", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef APP_SDNFC - {.app = sdnfc, .name = "sdnfc", .stack_size = 1024, .icon = &A_Plugins_14}, -#endif - -#ifdef APP_GUI_TEST - {.app = gui_test, .name = "gui_test", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = vibro_test_app, .name = "Vibro Test", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef APP_KEYPAD_TEST - {.app = keypad_test, .name = "keypad_test", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = keypad_test_app, .name = "Keypad Test", .stack_size = 1024, .icon = &A_Plugins_14}, #endif #ifdef APP_ACCESSOR - {.app = app_accessor, .name = "accessor", .stack_size = 4096, .icon = &A_Plugins_14}, + {.app = accessor_app, .name = "Accessor", .stack_size = 4096, .icon = &A_Plugins_14}, #endif #ifdef APP_UNIT_TESTS @@ -288,13 +231,6 @@ const FlipperApplication FLIPPER_DEBUG_APPS[] = { {.app = irda_monitor_app, .name = "Irda Monitor", .stack_size = 1024, .icon = &A_Plugins_14}, #endif -#ifdef APP_VERTICAL_SCREEN - {.app = application_vertical_screen, - .name = "Vertical Screen", - .stack_size = 1024, - .icon = &A_Plugins_14}, -#endif - #ifdef APP_SCENED {.app = scened_app, .name = "Templated Scene", .stack_size = 1024, .icon = &A_Plugins_14}, #endif @@ -308,7 +244,7 @@ const size_t FLIPPER_DEBUG_APPS_COUNT = sizeof(FLIPPER_DEBUG_APPS) / sizeof(Flip #ifdef APP_ARCHIVE const FlipperApplication FLIPPER_ARCHIVE = - {.app = app_archive, .name = "Archive", .stack_size = 4096, .icon = &A_FileManager_14}; + {.app = archive_app, .name = "Archive", .stack_size = 4096, .icon = &A_FileManager_14}; #endif #ifdef SRV_DOLPHIN @@ -316,8 +252,8 @@ const FlipperApplication FLIPPER_SCENE = {.app = scene_app, .name = "Scenes", .stack_size = 1024, .icon = &A_Games_14}; const FlipperApplication FLIPPER_SCENE_APPS[] = { - {.app = passport, .name = "Passport", .stack_size = 1024, .icon = &A_Games_14}, - {.app = music_player, .name = "Music player", .stack_size = 1024, .icon = &A_Plugins_14}, + {.app = passport_app, .name = "Passport", .stack_size = 1024, .icon = &A_Games_14}, + {.app = music_player_app, .name = "Music player", .stack_size = 1024, .icon = &A_Plugins_14}, }; const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(FlipperApplication); @@ -327,11 +263,11 @@ const size_t FLIPPER_SCENE_APPS_COUNT = sizeof(FLIPPER_SCENE_APPS) / sizeof(Flip // Settings menu const FlipperApplication FLIPPER_SETTINGS_APPS[] = { #ifdef SRV_NOTIFICATION - {.app = notification_app_settings, .name = "Notification", .stack_size = 1024, .icon = NULL}, + {.app = notification_settings_app, .name = "Notification", .stack_size = 1024, .icon = NULL}, #endif #ifdef SRV_STORAGE - {.app = storage_settings, .name = "Storage", .stack_size = 2048, .icon = NULL}, + {.app = storage_settings_app, .name = "Storage", .stack_size = 2048, .icon = NULL}, #endif }; diff --git a/applications/applications.h b/applications/applications.h index b2e29324..962eaa77 100644 --- a/applications/applications.h +++ b/applications/applications.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include typedef struct { const FuriThreadCallback app; diff --git a/applications/applications.mk b/applications/applications.mk index c19015f9..5e3263a6 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -11,40 +11,46 @@ CPP_SOURCES += $(shell find $(APP_DIR) -name *.cpp) APP_RELEASE ?= 1 ifeq ($(APP_RELEASE), 1) -# Main services -SRV_MENU = 1 -SRV_POWER = 1 +# Services SRV_BT = 1 SRV_CLI = 1 -SRV_DOLPHIN = 1 -SRV_NOTIFICATION = 1 -SRV_STORAGE = 1 SRV_DIALOGS = 1 +SRV_DOLPHIN = 1 +SRV_GUI = 1 +SRV_INPUT = 1 +SRV_MENU = 1 +SRV_NOTIFICATION = 1 +SRV_POWER = 1 SRV_POWER_OBSERVER = 1 +SRV_STORAGE = 1 -# Main Apps +# Apps +APP_ARCHIVE = 1 +APP_GPIO_TEST = 1 +APP_IBUTTON = 1 APP_IRDA = 1 -APP_SUBGHZ = 1 APP_LF_RFID = 1 APP_NFC = 1 -APP_GPIO_DEMO = 1 -APP_MUSIC_PLAYER = 1 -APP_IBUTTON = 1 -APP_ARCHIVE = 1 +APP_SUBGHZ = 1 -# Debug and misc -APP_GUI_TEST = 1 -APP_KEYPAD_TEST = 1 +# Plugins +APP_MUSIC_PLAYER = 1 + +# Debug APP_ACCESSOR = 1 -APP_SD_TEST = 1 -APP_VIBRO_DEMO = 1 -APP_SPEAKER_DEMO = 1 -APP_EXAMPLE_BLINK = 1 -APP_EXAMPLE_UART_WRITE = 1 -APP_EXAMPLE_INPUT_DUMP = 1 -APP_UNIT_TESTS = 0 +APP_BLINK = 1 APP_IRDA_MONITOR = 1 -APP_VERTICAL_SCREEN = 1 +APP_KEYPAD_TEST = 1 +APP_SD_TEST = 1 +APP_UNIT_TESTS = 0 +APP_VIBRO_DEMO = 1 +endif + + +SRV_BT ?= 0 +ifeq ($(SRV_BT), 1) +SRV_CLI = 1 +CFLAGS += -DSRV_BT endif SRV_DOLPHIN ?= 0 @@ -66,12 +72,6 @@ SRV_POWER = 1 CFLAGS += -DSRV_POWER_OBSERVER endif -SRV_BT ?= 0 -ifeq ($(SRV_BT), 1) -SRV_CLI = 1 -CFLAGS += -DSRV_BT -endif - SRV_MENU ?= 0 ifeq ($(SRV_MENU), 1) CFLAGS += -DSRV_MENU @@ -84,11 +84,6 @@ SRV_GUI = 1 CFLAGS += -DAPP_MENU endif -APP_VERTICAL_SCREEN ?= 0 -ifeq ($(APP_VERTICAL_SCREEN), 1) -CFLAGS += -DAPP_VERTICAL_SCREEN -endif - APP_IRDA_MONITOR ?= 0 ifeq ($(APP_IRDA_MONITOR), 1) CFLAGS += -DAPP_IRDA_MONITOR @@ -105,56 +100,35 @@ CFLAGS += -DAPP_ARCHIVE APP_ARCHIVE = 1 endif -SRV_EXAMPLE_BLINK ?= 0 -ifeq ($(SRV_EXAMPLE_BLINK), 1) -CFLAGS += -DSRV_EXAMPLE_BLINK -APP_EXAMPLE_BLINK = 1 +SRV_BLINK ?= 0 +ifeq ($(SRV_BLINK), 1) +CFLAGS += -DSRV_BLINK +APP_BLINK = 1 endif -APP_EXAMPLE_BLINK ?= 0 -ifeq ($(APP_EXAMPLE_BLINK), 1) -CFLAGS += -DAPP_EXAMPLE_BLINK +APP_BLINK ?= 0 +ifeq ($(APP_BLINK), 1) +CFLAGS += -DAPP_BLINK SRV_INPUT = 1 endif -SRV_EXAMPLE_UART_WRITE ?= 0 -ifeq ($(SRV_EXAMPLE_UART_WRITE), 1) -CFLAGS += -DSRV_EXAMPLE_UART_WRITE -APP_EXAMPLE_UART_WRITE = 1 +SRV_UART_WRITE ?= 0 +ifeq ($(SRV_UART_WRITE), 1) +CFLAGS += -DSRV_UART_WRITE +APP_UART_WRITE = 1 endif -APP_EXAMPLE_UART_WRITE ?= 0 -ifeq ($(APP_EXAMPLE_UART_WRITE), 1) -CFLAGS += -DAPP_EXAMPLE_UART_WRITE +APP_UART_WRITE ?= 0 +ifeq ($(APP_UART_WRITE), 1) +CFLAGS += -DAPP_UART_WRITE endif -SRV_EXAMPLE_IPC ?= 0 -ifeq ($(SRV_EXAMPLE_IPC), 1) -CFLAGS += -DSRV_EXAMPLE_IPC -APP_EXAMPLE_IPC = 1 +SRV_IPC ?= 0 +ifeq ($(SRV_IPC), 1) +CFLAGS += -DSRV_IPC +APP_IPC = 1 endif -APP_EXAMPLE_IPC ?= 0 -ifeq ($(APP_EXAMPLE_IPC), 1) -CFLAGS += -DAPP_EXAMPLE_IPC -endif - -SRV_EXAMPLE_INPUT_DUMP ?= 0 -ifeq ($(SRV_EXAMPLE_INPUT_DUMP), 1) -CFLAGS += -DSRV_EXAMPLE_INPUT_DUMP -APP_EXAMPLE_INPUT_DUMP = 1 -endif -APP_EXAMPLE_INPUT_DUMP ?= 0 -ifeq ($(APP_EXAMPLE_INPUT_DUMP), 1) -CFLAGS += -DAPP_EXAMPLE_INPUT_DUMP -SRV_INPUT = 1 -endif - -SRV_EXAMPLE_QRCODE ?= 0 -ifeq ($(SRV_EXAMPLE_QRCODE), 1) -CFLAGS += -DSRV_EXAMPLE_QRCODE -APP_EXAMPLE_QRCODE = 1 -endif -APP_EXAMPLE_QRCODE ?= 0 -ifeq ($(APP_EXAMPLE_QRCODE), 1) -CFLAGS += -DAPP_EXAMPLE_QRCODE +APP_IPC ?= 0 +ifeq ($(APP_IPC), 1) +CFLAGS += -DAPP_IPC endif ifeq ($(APP_SUBGHZ), 1) @@ -196,18 +170,6 @@ SRV_INPUT = 1 SRV_GUI = 1 endif -SRV_SPEAKER_DEMO ?= 0 -ifeq ($(SRV_SPEAKER_DEMO), 1) -CFLAGS += -DSRV_SPEAKER_DEMO -APP_SPEAKER_DEMO = 1 -endif -APP_SPEAKER_DEMO ?= 0 -ifeq ($(APP_SPEAKER_DEMO), 1) -CFLAGS += -DAPP_SPEAKER_DEMO -SRV_INPUT = 1 -SRV_GUI = 1 -endif - APP_VIBRO_DEMO ?= 0 ifeq ($(APP_VIBRO_DEMO), 1) CFLAGS += -DAPP_VIBRO_DEMO @@ -236,14 +198,14 @@ CFLAGS += -DAPP_ACCESSOR APP_ACCESSOR = 1 endif -SRV_GPIO_DEMO ?= 0 -ifeq ($(SRV_GPIO_DEMO), 1) -CFLAGS += -DSRV_GPIO_DEMO -APP_GPIO_DEMO = 1 +SRV_GPIO_TEST ?= 0 +ifeq ($(SRV_GPIO_TEST), 1) +CFLAGS += -DSRV_GPIO_TEST +APP_GPIO_TEST = 1 endif -APP_GPIO_DEMO ?= 0 -ifeq ($(APP_GPIO_DEMO), 1) -CFLAGS += -DAPP_GPIO_DEMO +APP_GPIO_TEST ?= 0 +ifeq ($(APP_GPIO_TEST), 1) +CFLAGS += -DAPP_GPIO_TEST endif SRV_MUSIC_PLAYER ?= 0 @@ -266,17 +228,9 @@ ifeq ($(APP_IBUTTON), 1) CFLAGS += -DAPP_IBUTTON endif -SRV_GUI_TEST ?= 0 -ifeq ($(SRV_GUI_TEST), 1) -CFLAGS += -DSRV_GUI_TEST -APP_GUI_TEST = 1 -endif -APP_GUI_TEST ?= 0 -ifeq ($(APP_GUI_TEST), 1) -CFLAGS += -DAPP_GUI_TEST -endif - -# device drivers +# +# Essential services +# SRV_GUI ?= 0 ifeq ($(SRV_GUI), 1) @@ -307,4 +261,4 @@ endif SRV_DIALOGS ?= 0 ifeq ($(SRV_DIALOGS), 1) CFLAGS += -DSRV_DIALOGS -endif \ No newline at end of file +endif diff --git a/applications/archive/archive.c b/applications/archive/archive.c index f6c0dc1f..265ae02c 100644 --- a/applications/archive/archive.c +++ b/applications/archive/archive.c @@ -629,7 +629,7 @@ ArchiveApp* archive_alloc() { return archive; } -int32_t app_archive(void* p) { +int32_t archive_app(void* p) { ArchiveApp* archive = archive_alloc(); // default tab diff --git a/applications/bt/bt.c b/applications/bt/bt.c index 5a27b31c..7b8bbdc6 100644 --- a/applications/bt/bt.c +++ b/applications/bt/bt.c @@ -148,7 +148,7 @@ void bt_menu_start_app(void* context) { furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK); } -int32_t bt_task() { +int32_t bt_srv() { Bt* bt = bt_alloc(); furi_record_create("bt", bt); diff --git a/applications/cli/cli.c b/applications/cli/cli.c index 213bef90..e8567087 100644 --- a/applications/cli/cli.c +++ b/applications/cli/cli.c @@ -383,7 +383,7 @@ void cli_delete_command(Cli* cli, const char* name) { string_clear(name_str); } -int32_t cli_task(void* p) { +int32_t cli_srv(void* p) { Cli* cli = cli_alloc(); // Init basic cli commands diff --git a/applications/coreglitch_demo_0/coreglitch_demo_0.c b/applications/coreglitch_demo_0/coreglitch_demo_0.c deleted file mode 100644 index 0bf93d79..00000000 --- a/applications/coreglitch_demo_0/coreglitch_demo_0.c +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include -#include -#include - -#include "u8g2/u8g2.h" - -extern TIM_HandleTypeDef SPEAKER_TIM; - -bool exit_app; - -static void event_cb(const void* value, void* ctx) { - furi_assert(value); - const InputEvent* event = value; - if(event->key == InputKeyBack && event->type == InputTypeShort) { - exit_app = true; - } -} - -void coreglitch_draw_callback(Canvas* canvas, void* ctx) { - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 2, 10, "Coreglitch demo application"); -} - -int32_t coreglitch_demo_0(void* p) { - printf("coreglitch demo!\r\n"); - - exit_app = false; - PubSub* event_record = furi_record_open("input_events"); - PubSubItem* event_pubsub = subscribe_pubsub(event_record, event_cb, NULL); - - // Configure view port - ViewPort* view_port = view_port_alloc(); - furi_check(view_port); - view_port_draw_callback_set(view_port, coreglitch_draw_callback, NULL); - - // Register view port in GUI - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - float notes[] = { - 0.0, - 330.0, - 220.0, - 0.0, - 110.0 + 55.0, - 440.0, - 330.0, - 55.0, - }; - - float scales[] = { - 1.0, - 1.5, - 0.75, - 0.8, - }; - - uint8_t cnt = 0; - - while(1) { - for(size_t note_idx = 0; (note_idx < 400) && (!exit_app); note_idx++) { - float scale = scales[((cnt + note_idx) / 16) % 4]; - - float freq = notes[(note_idx + cnt / 2) % 8] * scale; - float width = 0.001 + 0.05 * (note_idx % (cnt / 7 + 5)); - - if(note_idx % 8 == 0) { - freq = 0; - } - - // TODO get sound from FURI - hal_pwm_set(width, freq, &SPEAKER_TIM, SPEAKER_CH); - - // delay(1); - - cnt++; - delay(100); - } - if(exit_app) { - break; - } - } - hal_pwm_stop(&SPEAKER_TIM, SPEAKER_CH); - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - unsubscribe_pubsub(event_pubsub); - - return 0; -} diff --git a/applications/examples/blink.c b/applications/debug_tools/blink_test.c similarity index 83% rename from applications/examples/blink.c rename to applications/debug_tools/blink_test.c index f146e490..26f4c6d4 100644 --- a/applications/examples/blink.c +++ b/applications/debug_tools/blink_test.c @@ -18,7 +18,7 @@ typedef struct { InputEvent input; } BlinkEvent; -void blink_update(void* ctx) { +static void blink_test_update(void* ctx) { furi_assert(ctx); osMessageQueueId_t event_queue = ctx; @@ -26,13 +26,13 @@ void blink_update(void* ctx) { osMessageQueuePut(event_queue, &event, 0, 0); } -void blink_draw_callback(Canvas* canvas, void* ctx) { +static void blink_test_draw_callback(Canvas* canvas, void* ctx) { canvas_clear(canvas); canvas_set_font(canvas, FontPrimary); canvas_draw_str(canvas, 2, 10, "Blink application"); } -void blink_input_callback(InputEvent* input_event, void* ctx) { +static void blink_test_input_callback(InputEvent* input_event, void* ctx) { furi_assert(ctx); osMessageQueueId_t event_queue = ctx; @@ -40,15 +40,15 @@ void blink_input_callback(InputEvent* input_event, void* ctx) { osMessageQueuePut(event_queue, &event, 0, 0); } -int32_t application_blink(void* p) { +int32_t blink_test_app(void* p) { osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(BlinkEvent), NULL); // Configure view port ViewPort* view_port = view_port_alloc(); furi_check(view_port); - view_port_draw_callback_set(view_port, blink_draw_callback, NULL); - view_port_input_callback_set(view_port, blink_input_callback, event_queue); - osTimerId_t timer = osTimerNew(blink_update, osTimerPeriodic, event_queue, NULL); + view_port_draw_callback_set(view_port, blink_test_draw_callback, NULL); + view_port_input_callback_set(view_port, blink_test_input_callback, event_queue); + osTimerId_t timer = osTimerNew(blink_test_update, osTimerPeriodic, event_queue, NULL); osTimerStart(timer, 1000); // Register view port in GUI diff --git a/applications/debug_tools/keypad_test.c b/applications/debug_tools/keypad_test.c new file mode 100644 index 00000000..1323e95e --- /dev/null +++ b/applications/debug_tools/keypad_test.c @@ -0,0 +1,225 @@ +#include +#include +#include + +typedef struct { + bool press[5]; + uint16_t up; + uint16_t down; + uint16_t left; + uint16_t right; + uint16_t ok; +} KeypadTestState; + +typedef enum { + EventTypeInput, +} EventType; + +typedef struct { + union { + InputEvent input; + }; + EventType type; +} KeypadTestEvent; + +static const char* keypad_test_get_key_name(InputKey key) { + switch(key) { + case InputKeyOk: + return "Ok"; + case InputKeyBack: + return "Back"; + case InputKeyLeft: + return "Left"; + case InputKeyRight: + return "Right"; + case InputKeyUp: + return "Up"; + case InputKeyDown: + return "Down"; + default: + return "Unknown"; + } +} + +static const char* keypad_test_get_type_name(InputType type) { + switch(type) { + case InputTypePress: + return "Press"; + case InputTypeRelease: + return "Release"; + case InputTypeShort: + return "Short"; + case InputTypeLong: + return "Long"; + case InputTypeRepeat: + return "Repeat"; + default: + return "Unknown"; + } +} + +static void keypad_test_reset_state(KeypadTestState* state) { + state->left = 0; + state->right = 0; + state->up = 0; + state->down = 0; + state->ok = 0; +} + +static void keypad_test_render_callback(Canvas* canvas, void* ctx) { + KeypadTestState* state = (KeypadTestState*)acquire_mutex((ValueMutex*)ctx, 25); + canvas_clear(canvas); + char strings[5][20]; + + sprintf(strings[0], "Ok: %d", state->ok); + sprintf(strings[1], "L: %d", state->left); + sprintf(strings[2], "R: %d", state->right); + sprintf(strings[3], "U: %d", state->up); + sprintf(strings[4], "D: %d", state->down); + + canvas_set_font(canvas, FontPrimary); + canvas_draw_str(canvas, 0, 10, "Keypad test"); + + canvas_set_font(canvas, FontSecondary); + canvas_draw_str(canvas, 0, 24, strings[1]); + canvas_draw_str(canvas, 35, 24, strings[2]); + canvas_draw_str(canvas, 0, 36, strings[3]); + canvas_draw_str(canvas, 35, 36, strings[4]); + canvas_draw_str(canvas, 0, 48, strings[0]); + canvas_draw_circle(canvas, 100, 26, 25); + + if(state->press[0]) canvas_draw_disc(canvas, 118, 26, 5); + if(state->press[1]) canvas_draw_disc(canvas, 82, 26, 5); + if(state->press[2]) canvas_draw_disc(canvas, 100, 8, 5); + if(state->press[3]) canvas_draw_disc(canvas, 100, 44, 5); + if(state->press[4]) canvas_draw_disc(canvas, 100, 26, 5); + + canvas_draw_str(canvas, 10, 63, "[back] - reset, hold to exit"); + + release_mutex((ValueMutex*)ctx, state); +} + +static void keypad_test_input_callback(InputEvent* input_event, void* ctx) { + osMessageQueueId_t event_queue = ctx; + + KeypadTestEvent event; + event.type = EventTypeInput; + event.input = *input_event; + osMessageQueuePut(event_queue, &event, 0, osWaitForever); +} + +int32_t keypad_test_app(void* p) { + osMessageQueueId_t event_queue = osMessageQueueNew(32, sizeof(KeypadTestEvent), NULL); + furi_check(event_queue); + + KeypadTestState _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0}; + + ValueMutex state_mutex; + if(!init_mutex(&state_mutex, &_state, sizeof(KeypadTestState))) { + FURI_LOG_E("KeypadTest", "cannot create mutex"); + return 0; + } + + ViewPort* view_port = view_port_alloc(); + + view_port_draw_callback_set(view_port, keypad_test_render_callback, &state_mutex); + view_port_input_callback_set(view_port, keypad_test_input_callback, event_queue); + + // Open GUI and register view_port + Gui* gui = furi_record_open("gui"); + gui_add_view_port(gui, view_port, GuiLayerFullscreen); + + KeypadTestEvent event; + while(1) { + osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever); + KeypadTestState* state = (KeypadTestState*)acquire_mutex_block(&state_mutex); + + if(event_status == osOK) { + if(event.type == EventTypeInput) { + FURI_LOG_I( + "KeypadTest", + "key: %s type: %s", + keypad_test_get_key_name(event.input.key), + keypad_test_get_type_name(event.input.type)); + + if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) { + release_mutex(&state_mutex, state); + break; + } + + if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) { + keypad_test_reset_state(state); + } + + if(event.input.key == InputKeyRight) { + if(event.input.type == InputTypePress) { + state->press[0] = true; + } else if(event.input.type == InputTypeRelease) { + state->press[0] = false; + } + + if(event.input.type == InputTypeShort) { + ++state->right; + } + } + + if(event.input.key == InputKeyLeft) { + if(event.input.type == InputTypePress) { + state->press[1] = true; + } else if(event.input.type == InputTypeRelease) { + state->press[1] = false; + } + + if(event.input.type == InputTypeShort) { + ++state->left; + } + } + + if(event.input.key == InputKeyUp) { + if(event.input.type == InputTypePress) { + state->press[2] = true; + } else if(event.input.type == InputTypeRelease) { + state->press[2] = false; + } + + if(event.input.type == InputTypeShort) { + ++state->up; + } + } + + if(event.input.key == InputKeyDown) { + if(event.input.type == InputTypePress) { + state->press[3] = true; + } else if(event.input.type == InputTypeRelease) { + state->press[3] = false; + } + + if(event.input.type == InputTypeShort) { + ++state->down; + } + } + + if(event.input.key == InputKeyOk) { + if(event.input.type == InputTypePress) { + state->press[4] = true; + } else if(event.input.type == InputTypeRelease) { + state->press[4] = false; + } + + if(event.input.type == InputTypeShort) { + ++state->ok; + } + } + } + } + view_port_update(view_port); + release_mutex(&state_mutex, state); + } + // remove & free all stuff created by app + gui_remove_view_port(gui, view_port); + view_port_free(view_port); + osMessageQueueDelete(event_queue); + delete_mutex(&state_mutex); + + return 0; +} diff --git a/applications/examples/vibro.c b/applications/debug_tools/vibro_test.c similarity index 87% rename from applications/examples/vibro.c rename to applications/debug_tools/vibro_test.c index 9c4edf30..e756be24 100644 --- a/applications/examples/vibro.c +++ b/applications/debug_tools/vibro_test.c @@ -9,7 +9,7 @@ typedef struct { InputEvent input; } VibroEvent; -void vibro_draw_callback(Canvas* canvas, void* ctx) { +void vibro_test_draw_callback(Canvas* canvas, void* ctx) { canvas_clear(canvas); canvas_set_font(canvas, FontPrimary); canvas_draw_str(canvas, 2, 10, "Vibro application"); @@ -19,7 +19,7 @@ void vibro_draw_callback(Canvas* canvas, void* ctx) { canvas_draw_str(canvas, 2, 34, "Release OK turns off vibro"); } -void vibro_input_callback(InputEvent* input_event, void* ctx) { +void vibro_test_input_callback(InputEvent* input_event, void* ctx) { furi_assert(ctx); osMessageQueueId_t event_queue = ctx; @@ -27,14 +27,14 @@ void vibro_input_callback(InputEvent* input_event, void* ctx) { osMessageQueuePut(event_queue, &event, 0, 0); } -int32_t application_vibro(void* p) { +int32_t vibro_test_app(void* p) { osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(VibroEvent), NULL); // Configure view port ViewPort* view_port = view_port_alloc(); furi_check(view_port); - view_port_draw_callback_set(view_port, vibro_draw_callback, NULL); - view_port_input_callback_set(view_port, vibro_input_callback, event_queue); + view_port_draw_callback_set(view_port, vibro_test_draw_callback, NULL); + view_port_input_callback_set(view_port, vibro_test_input_callback, event_queue); // Register view port in GUI Gui* gui = furi_record_open("gui"); diff --git a/applications/dialogs/dialogs.c b/applications/dialogs/dialogs.c index 41c607da..8395e852 100644 --- a/applications/dialogs/dialogs.c +++ b/applications/dialogs/dialogs.c @@ -24,7 +24,7 @@ static void dialogs_app_process_message(DialogsApp* app, DialogsAppMessage* mess API_LOCK_UNLOCK(message->semaphore); } -int32_t dialogs_app(void* p) { +int32_t dialogs_srv(void* p) { DialogsApp* app = dialogs_app_alloc(); furi_record_create("dialogs", app); diff --git a/applications/dolphin/dolphin.c b/applications/dolphin/dolphin.c index 3ccbab82..2dcd13ef 100644 --- a/applications/dolphin/dolphin.c +++ b/applications/dolphin/dolphin.c @@ -393,7 +393,7 @@ void dolphin_deed(Dolphin* dolphin, DolphinDeed deed) { furi_check(osMessageQueuePut(dolphin->event_queue, &event, 0, osWaitForever) == osOK); } -int32_t dolphin_task() { +int32_t dolphin_srv() { Dolphin* dolphin = dolphin_alloc(); if(dolphin_state_load(dolphin->state)) { diff --git a/applications/dolphin/passport/passport.c b/applications/dolphin/passport/passport.c index 53b97ba0..9b1cae04 100644 --- a/applications/dolphin/passport/passport.c +++ b/applications/dolphin/passport/passport.c @@ -97,7 +97,7 @@ static void render_callback(Canvas* canvas, void* ctx) { release_mutex((ValueMutex*)ctx, state); } -int32_t passport(void* p) { +int32_t passport_app(void* p) { DolphinState* dolphin_state = dolphin_state_alloc(); ValueMutex state_mutex; dolphin_state_load(dolphin_state); diff --git a/applications/examples/input_dump.c b/applications/examples/input_dump.c deleted file mode 100644 index 4959ca9f..00000000 --- a/applications/examples/input_dump.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include - -typedef struct { - InputEvent input; -} InputDumpEvent; - -void input_dump_draw_callback(Canvas* canvas, void* ctx) { - canvas_clear(canvas); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 2, 10, "Input dump application"); - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 2, 22, "Press long back to exit"); -} - -void input_dump_input_callback(InputEvent* input_event, void* ctx) { - furi_assert(ctx); - osMessageQueueId_t event_queue = ctx; - InputDumpEvent event = {.input = *input_event}; - osMessageQueuePut(event_queue, &event, 0, 0); -} - -static const char* input_dump_get_key_name(InputKey key) { - switch(key) { - case InputKeyOk: - return "Ok"; - case InputKeyBack: - return "Back"; - case InputKeyLeft: - return "Left"; - case InputKeyRight: - return "Right"; - case InputKeyUp: - return "Up"; - case InputKeyDown: - return "Down"; - default: - return "Unknown"; - } -} - -static const char* input_dump_get_type_name(InputType type) { - switch(type) { - case InputTypePress: - return "Press"; - case InputTypeRelease: - return "Release"; - case InputTypeShort: - return "Short"; - case InputTypeLong: - return "Long"; - case InputTypeRepeat: - return "Repeat"; - default: - return "Unknown"; - } -} - -int32_t application_input_dump(void* p) { - osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(InputDumpEvent), NULL); - - // Configure view port - ViewPort* view_port = view_port_alloc(); - furi_check(view_port); - view_port_draw_callback_set(view_port, input_dump_draw_callback, NULL); - view_port_input_callback_set(view_port, input_dump_input_callback, event_queue); - - // Register view port in GUI - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - FURI_LOG_I("INPUT DUMP", "waiting for input events"); - InputDumpEvent event; - - while(1) { - furi_check(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK); - - FURI_LOG_I( - "INPUT DUMP", - "key: %s type: %s", - input_dump_get_key_name(event.input.key), - input_dump_get_type_name(event.input.type)); - - if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) { - break; - } - } - - FURI_LOG_I("INPUT DUMP", "shutting down, byebye!"); - - view_port_enabled_set(view_port, false); - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - osMessageQueueDelete(event_queue); - - return 0; -} diff --git a/applications/examples/keypad_test.c b/applications/examples/keypad_test.c deleted file mode 100644 index 01fd6070..00000000 --- a/applications/examples/keypad_test.c +++ /dev/null @@ -1,189 +0,0 @@ -#include -#include -#include - -extern TIM_HandleTypeDef SPEAKER_TIM; - -typedef struct { - bool press[5]; - uint16_t up; - uint16_t down; - uint16_t left; - uint16_t right; - uint16_t ok; -} State; - -typedef enum { - EventTypeTick, - EventTypeKey, -} EventType; - -typedef struct { - union { - InputEvent input; - } value; - EventType type; -} AppEvent; - -static void reset_state(State* state) { - state->left = 0; - state->right = 0; - state->up = 0; - state->down = 0; - state->ok = 0; -} - -static void render_callback(Canvas* canvas, void* ctx) { - State* state = (State*)acquire_mutex((ValueMutex*)ctx, 25); - canvas_clear(canvas); - char strings[5][20]; - - sprintf(strings[0], "Ok: %d", state->ok); - sprintf(strings[1], "L: %d", state->left); - sprintf(strings[2], "R: %d", state->right); - sprintf(strings[3], "U: %d", state->up); - sprintf(strings[4], "D: %d", state->down); - - canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 0, 10, "Keypad test"); - - canvas_set_font(canvas, FontSecondary); - canvas_draw_str(canvas, 0, 24, strings[1]); - canvas_draw_str(canvas, 35, 24, strings[2]); - canvas_draw_str(canvas, 0, 36, strings[3]); - canvas_draw_str(canvas, 35, 36, strings[4]); - canvas_draw_str(canvas, 0, 48, strings[0]); - canvas_draw_circle(canvas, 100, 26, 25); - - if(state->press[0]) canvas_draw_disc(canvas, 118, 26, 5); - if(state->press[1]) canvas_draw_disc(canvas, 82, 26, 5); - if(state->press[2]) canvas_draw_disc(canvas, 100, 8, 5); - if(state->press[3]) canvas_draw_disc(canvas, 100, 44, 5); - if(state->press[4]) canvas_draw_disc(canvas, 100, 26, 5); - - canvas_draw_str(canvas, 10, 63, "[back] - reset, hold to exit"); - - release_mutex((ValueMutex*)ctx, state); -} - -static void input_callback(InputEvent* input_event, void* ctx) { - osMessageQueueId_t event_queue = ctx; - - AppEvent event; - event.type = EventTypeKey; - event.value.input = *input_event; - osMessageQueuePut(event_queue, &event, 0, 0); -} - -int32_t keypad_test(void* p) { - osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL); - furi_check(event_queue); - - State _state = {{false, false, false, false, false}, 0, 0, 0, 0, 0}; - - ValueMutex state_mutex; - if(!init_mutex(&state_mutex, &_state, sizeof(State))) { - printf("[keypad_test] cannot create mutex\r\n"); - return 0; - } - - ViewPort* view_port = view_port_alloc(); - - view_port_draw_callback_set(view_port, render_callback, &state_mutex); - view_port_input_callback_set(view_port, input_callback, event_queue); - - // Open GUI and register view_port - Gui* gui = furi_record_open("gui"); - gui_add_view_port(gui, view_port, GuiLayerFullscreen); - - AppEvent event; - while(1) { - osStatus_t event_status = osMessageQueueGet(event_queue, &event, NULL, osWaitForever); - State* state = (State*)acquire_mutex_block(&state_mutex); - - if(event_status == osOK) { - if(event.type == EventTypeKey) { - if(event.value.input.type == InputTypeLong && - event.value.input.key == InputKeyBack) { - printf("[keypad test] bye!\r\n"); - release_mutex(&state_mutex, state); - break; - } - - if(event.value.input.type == InputTypeShort && - event.value.input.key == InputKeyBack) { - reset_state(state); - } - - if(event.value.input.key == InputKeyRight) { - if(event.value.input.type == InputTypePress) { - state->press[0] = true; - } else if(event.value.input.type == InputTypeRelease) { - state->press[0] = false; - } - - if(event.value.input.type == InputTypeShort) { - ++state->right; - } - } - - if(event.value.input.key == InputKeyLeft) { - if(event.value.input.type == InputTypePress) { - state->press[1] = true; - } else if(event.value.input.type == InputTypeRelease) { - state->press[1] = false; - } - - if(event.value.input.type == InputTypeShort) { - ++state->left; - } - } - - if(event.value.input.key == InputKeyUp) { - if(event.value.input.type == InputTypePress) { - state->press[2] = true; - } else if(event.value.input.type == InputTypeRelease) { - state->press[2] = false; - } - - if(event.value.input.type == InputTypeShort) { - ++state->up; - } - } - - if(event.value.input.key == InputKeyDown) { - if(event.value.input.type == InputTypePress) { - state->press[3] = true; - } else if(event.value.input.type == InputTypeRelease) { - state->press[3] = false; - } - - if(event.value.input.type == InputTypeShort) { - ++state->down; - } - } - - if(event.value.input.key == InputKeyOk) { - if(event.value.input.type == InputTypePress) { - state->press[4] = true; - } else if(event.value.input.type == InputTypeRelease) { - state->press[4] = false; - } - - if(event.value.input.type == InputTypeShort) { - ++state->ok; - } - } - } - } - view_port_update(view_port); - release_mutex(&state_mutex, state); - } - // remove & free all stuff created by app - gui_remove_view_port(gui, view_port); - view_port_free(view_port); - osMessageQueueDelete(event_queue); - delete_mutex(&state_mutex); - - return 0; -} \ No newline at end of file diff --git a/applications/examples/u8g2_example.c b/applications/examples/u8g2_example.c deleted file mode 100644 index e5370309..00000000 --- a/applications/examples/u8g2_example.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "u8g2/u8g2.h" -#include - -int32_t u8g2_example(void* p) { - // open record - u8g2_t* fb = furi_record_open("u8g2_fb"); - u8g2_SetFont(fb, u8g2_font_6x10_mf); - u8g2_SetDrawColor(fb, 1); - u8g2_SetFontMode(fb, 1); - u8g2_DrawStr(fb, 2, 12, "hello world!"); - furi_record_close("u8g2_fb"); - - return 0; -} \ No newline at end of file diff --git a/applications/examples/u8g2_qrcode.c b/applications/examples/u8g2_qrcode.c deleted file mode 100644 index f71a0ca3..00000000 --- a/applications/examples/u8g2_qrcode.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "u8g2/u8g2.h" -#include "qrcode/qrcode.h" -#include - -/* -TODO: rework with new app api - -void u8g2_DrawPixelSize(u8g2_t* u8g2, uint8_t x, uint8_t y, uint8_t size) { - for(uint8_t px = 0; px < size; px++) { - for(uint8_t py = 0; py < size; py++) { - u8g2_DrawPixel(u8g2, x + px, y + py); - } - } -} - -int32_t u8g2_qrcode(void* p) { - // open record - FuriRecordSubscriber* fb_record = - furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL); - - // Allocate a chunk of memory to store the QR code - // https://github.com/ricmoo/QRCode - // we init version 1, 21x21 px, 16 alphanumeric chars with - // QUARTILE error correction - const uint8_t qr_version = 1; - const uint8_t qr_error_correction = ECC_QUARTILE; - - const uint8_t qr_x = 32; - const uint8_t qr_y = 0; - const uint8_t qr_size = 3; - - // The structure to manage the QR code - QRCode qrcode; - - // QR Code init - uint8_t qrcodeBytes[qrcode_getBufferSize(qr_version)]; - qrcode_initText(&qrcode, qrcodeBytes, qr_version, qr_error_correction, "HELLO FLIPPER"); - - if(fb_record == NULL) { - printf("[view_port] cannot create fb record\r\n"); - return 255; - } - - u8g2_t* fb = furi_take(fb_record); - - // clear display - if(fb != NULL) { - u8g2_ClearBuffer(fb); - } - - while(1) { - if(fb != NULL) { - // draw qr code - for(uint8_t y = 0; y < qrcode.size; y++) { - for(uint8_t x = 0; x < qrcode.size; x++) { - if(qrcode_getModule(&qrcode, x, y)) { - u8g2_SetDrawColor(fb, 1); - u8g2_DrawPixelSize(fb, qr_x + x * qr_size, qr_y + y * qr_size, qr_size); - } else { - u8g2_SetDrawColor(fb, 0); - u8g2_DrawPixelSize(fb, qr_x + x * qr_size, qr_y + y * qr_size, qr_size); - } - } - } - } else { - return 255; - } - - furi_commit(fb_record); - - delay(1); - } - - return 0; -} -*/ \ No newline at end of file diff --git a/applications/examples/uart_write.c b/applications/examples/uart_write.c deleted file mode 100644 index 9c3b339b..00000000 --- a/applications/examples/uart_write.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -int32_t application_uart_write(void* p) { - // Red led for showing progress - GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA}; - // TODO open record - GpioPin* led_record = &led; - - hal_gpio_init(led_record, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); - - // create buffer - const char test_string[] = "test\n"; - printf(test_string); - - // for example, create counter and show its value - uint8_t counter = 0; - - while(1) { - // continously write it to UART - printf("counter: %d\n", counter); - counter++; - - // flash at every send - hal_gpio_write(led_record, false); - delay(50); - hal_gpio_write(led_record, true); - - // delay with overall perion of 1s - delay(950); - } - - return 0; -} \ No newline at end of file diff --git a/applications/examples/vertical_submenu.c b/applications/examples/vertical_submenu.c deleted file mode 100644 index 94e3710d..00000000 --- a/applications/examples/vertical_submenu.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include -#include -#include - -static ViewDispatcher* view_dispatcher; -static osMessageQueueId_t event_queue; - -typedef enum { - EventTypeGoAway, - EventTypeGoToMainMenu, - EventTypeSwitchToVertical, - EventTypeSwitchToHorizontal, -} EventType; - -// Nothing dangerous in settings some vars and flags inside callback -static void submenu_callback(void* context, uint32_t index) { - EventType event = EventTypeGoAway; - switch(index) { - case 1: - event = EventTypeSwitchToVertical; - break; - case 2: - event = EventTypeSwitchToHorizontal; - break; - default: - break; - } - - osMessageQueuePut(event_queue, &event, 0, 0); -} - -uint32_t previous_exit_callback(void* context) { - EventType event = EventTypeGoAway; - osMessageQueuePut(event_queue, &event, 0, 0); - return VIEW_IGNORE; -} - -uint32_t previous_callback(void* context) { - EventType event = EventTypeGoToMainMenu; - osMessageQueuePut(event_queue, &event, 0, 0); - return VIEW_IGNORE; -} - -int32_t application_vertical_screen(void* p) { - event_queue = osMessageQueueNew(8, sizeof(EventType), NULL); - - view_dispatcher = view_dispatcher_alloc(); - Gui* gui = furi_record_open("gui"); - view_dispatcher_attach_to_gui(view_dispatcher, gui, ViewDispatcherTypeFullscreen); - - Submenu* submenu = submenu_alloc(); - View* submenu_view = submenu_get_view(submenu); - view_set_previous_callback(submenu_view, previous_exit_callback); - view_set_orientation(submenu_view, ViewOrientationVertical); - submenu_add_item(submenu, "VerSubm", 1, submenu_callback, view_dispatcher); - submenu_add_item(submenu, "HorSubm", 2, submenu_callback, view_dispatcher); - view_dispatcher_add_view(view_dispatcher, 1, submenu_view); - - Submenu* submenu_vertical = submenu_alloc(); - View* submenu_vertical_view = submenu_get_view(submenu_vertical); - view_set_previous_callback(submenu_vertical_view, previous_callback); - view_set_orientation(submenu_vertical_view, ViewOrientationVertical); - submenu_add_item(submenu_vertical, "Vert1", 1, NULL, view_dispatcher); - submenu_add_item(submenu_vertical, "Vert2", 2, NULL, view_dispatcher); - view_dispatcher_add_view(view_dispatcher, 2, submenu_vertical_view); - - Submenu* submenu_horizontal = submenu_alloc(); - View* submenu_horizontal_view = submenu_get_view(submenu_horizontal); - view_set_previous_callback(submenu_horizontal_view, previous_callback); - view_set_orientation(submenu_horizontal_view, ViewOrientationHorizontal); - submenu_add_item(submenu_horizontal, "Horiz1", 1, NULL, view_dispatcher); - submenu_add_item(submenu_horizontal, "Horiz2", 2, NULL, view_dispatcher); - view_dispatcher_add_view(view_dispatcher, 3, submenu_horizontal_view); - - view_dispatcher_switch_to_view(view_dispatcher, 1); - - while(1) { - EventType event; - furi_check(osMessageQueueGet(event_queue, &event, NULL, osWaitForever) == osOK); - if(event == EventTypeGoAway) { - break; - } else if(event == EventTypeGoToMainMenu) { - view_dispatcher_switch_to_view(view_dispatcher, 1); - } else if(event == EventTypeSwitchToVertical) { - view_dispatcher_switch_to_view(view_dispatcher, 2); - } else if(event == EventTypeSwitchToHorizontal) { - view_dispatcher_switch_to_view(view_dispatcher, 3); - } - } - - view_dispatcher_remove_view(view_dispatcher, 1); - view_dispatcher_remove_view(view_dispatcher, 2); - view_dispatcher_remove_view(view_dispatcher, 3); - submenu_free(submenu); - submenu_free(submenu_vertical); - submenu_free(submenu_horizontal); - view_dispatcher_free(view_dispatcher); - osMessageQueueDelete(event_queue); - furi_record_close("gui"); - - return 0; -} diff --git a/applications/gpio-tester/gpio-tester.c b/applications/gpio-tester/gpio-tester.c index a61cc0ce..2ac741cc 100644 --- a/applications/gpio-tester/gpio-tester.c +++ b/applications/gpio-tester/gpio-tester.c @@ -44,7 +44,7 @@ static void render_callback(Canvas* canvas, void* ctx) { canvas_clear(canvas); canvas_set_color(canvas, ColorBlack); canvas_set_font(canvas, FontPrimary); - canvas_draw_str(canvas, 2, 10, "GPIO demo"); + canvas_draw_str(canvas, 2, 10, "GPIO Control"); canvas_set_font(canvas, FontSecondary); canvas_draw_str(canvas, 2, 25, GPIO_PINS[state->gpio_index].name); @@ -60,7 +60,7 @@ static void input_callback(InputEvent* input_event, void* ctx) { osMessageQueuePut(event_queue, &event, 0, 0); } -int32_t app_gpio_test(void* p) { +int32_t gpio_test_app(void* p) { osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(AppEvent), NULL); furi_check(event_queue); diff --git a/applications/gui-test/gui-test.c b/applications/gui-test/gui-test.c deleted file mode 100644 index 19addf2f..00000000 --- a/applications/gui-test/gui-test.c +++ /dev/null @@ -1,239 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define GUI_TEST_FLAG_EXIT 0x00000001U - -typedef enum { - GuiTesterViewTextInput = 0, - GuiTesterViewSubmenu, - GuiTesterViewDialog, - GuiTesterViewDialogEx, - GuiTesterViewPopup, - GuiTesterViewByteInput, - GuiTesterViewLast -} GuiTesterView; - -typedef struct { - ViewDispatcher* view_dispatcher; - Dialog* dialog; - DialogEx* dialog_ex; - Submenu* submenu; - TextInput* text_input; - Popup* popup; - ByteInput* byte_input; - GuiTesterView view_index; -} GuiTester; - -static GuiTester* gui_test_alloc(void) { - GuiTester* gui_tester = furi_alloc(sizeof(GuiTester)); - gui_tester->view_dispatcher = view_dispatcher_alloc(); - gui_tester->view_index = GuiTesterViewByteInput; - - gui_tester->dialog = dialog_alloc(); - view_dispatcher_add_view( - gui_tester->view_dispatcher, GuiTesterViewDialog, dialog_get_view(gui_tester->dialog)); - - gui_tester->dialog_ex = dialog_ex_alloc(); - view_dispatcher_add_view( - gui_tester->view_dispatcher, - GuiTesterViewDialogEx, - dialog_ex_get_view(gui_tester->dialog_ex)); - - gui_tester->submenu = submenu_alloc(); - view_dispatcher_add_view( - gui_tester->view_dispatcher, GuiTesterViewSubmenu, submenu_get_view(gui_tester->submenu)); - - gui_tester->text_input = text_input_alloc(); - view_dispatcher_add_view( - gui_tester->view_dispatcher, - GuiTesterViewTextInput, - text_input_get_view(gui_tester->text_input)); - - gui_tester->popup = popup_alloc(); - view_dispatcher_add_view( - gui_tester->view_dispatcher, GuiTesterViewPopup, popup_get_view(gui_tester->popup)); - - gui_tester->byte_input = byte_input_alloc(); - view_dispatcher_add_view( - gui_tester->view_dispatcher, - GuiTesterViewByteInput, - byte_input_get_view(gui_tester->byte_input)); - - return gui_tester; -} - -static void gui_test_free(GuiTester* gui_tester) { - furi_assert(gui_tester); - view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewDialog); - dialog_free(gui_tester->dialog); - view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewDialogEx); - dialog_ex_free(gui_tester->dialog_ex); - view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewSubmenu); - submenu_free(gui_tester->submenu); - view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewTextInput); - text_input_free(gui_tester->text_input); - view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewPopup); - popup_free(gui_tester->popup); - view_dispatcher_remove_view(gui_tester->view_dispatcher, GuiTesterViewByteInput); - byte_input_free(gui_tester->byte_input); - - view_dispatcher_free(gui_tester->view_dispatcher); - free(gui_tester); -} - -static void next_view(void* context) { - furi_assert(context); - GuiTester* gui_tester = context; - - gui_tester->view_index++; - if(gui_tester->view_index >= GuiTesterViewLast) { - gui_tester->view_index = 0; - } - - view_dispatcher_switch_to_view(gui_tester->view_dispatcher, gui_tester->view_index); -} - -static void popup_callback(void* context) { - next_view(context); -} - -static void submenu_callback(void* context, uint32_t index) { - next_view(context); -} - -static void dialog_callback(DialogResult result, void* context) { - next_view(context); -} - -static void dialog_ex_callback(DialogExResult result, void* context) { - next_view(context); -} - -static void text_input_callback(void* context) { - next_view(context); -} - -static void byte_input_callback(void* context) { - next_view(context); -} - -static void event_cb(const void* value, void* ctx) { - furi_assert(value); - furi_assert(ctx); - const InputEvent* event = value; - if(event->key == InputKeyBack && event->type == InputTypeLong) { - osThreadFlagsSet((osThreadId_t)ctx, GUI_TEST_FLAG_EXIT); - } -} - -int32_t gui_test(void* param) { - (void)param; - PubSub* event_record = furi_record_open("input_events"); - PubSubItem* event_pubsub = subscribe_pubsub(event_record, event_cb, (void*)osThreadGetId()); - GuiTester* gui_tester = gui_test_alloc(); - - Gui* gui = furi_record_open("gui"); - view_dispatcher_attach_to_gui(gui_tester->view_dispatcher, gui, ViewDispatcherTypeFullscreen); - - // Submenu - submenu_add_item(gui_tester->submenu, "Read", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Saved", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Emulate", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Enter manually", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Blah blah", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Set time", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Gender-bender", 0, submenu_callback, gui_tester); - submenu_add_item( - gui_tester->submenu, "Hack American Elections", 0, submenu_callback, gui_tester); - submenu_add_item(gui_tester->submenu, "Hack the White House", 0, submenu_callback, gui_tester); - - // Dialog - dialog_set_result_callback(gui_tester->dialog, dialog_callback); - dialog_set_context(gui_tester->dialog, gui_tester); - dialog_set_header_text(gui_tester->dialog, "Delete Abc123?"); - dialog_set_text(gui_tester->dialog, "ID: F0 00 01 02 03 04\nAre you shure?"); - dialog_set_left_button_text(gui_tester->dialog, "Yes"); - dialog_set_right_button_text(gui_tester->dialog, "No"); - - // Dialog extended - dialog_ex_set_result_callback(gui_tester->dialog_ex, dialog_ex_callback); - dialog_ex_set_context(gui_tester->dialog_ex, gui_tester); - dialog_ex_set_header(gui_tester->dialog_ex, "Dallas", 95, 12, AlignCenter, AlignCenter); - dialog_ex_set_text( - gui_tester->dialog_ex, "F6 E5 D4\nC3 B2 A1", 95, 32, AlignCenter, AlignCenter); - dialog_ex_set_icon(gui_tester->dialog_ex, 0, 1, &I_DolphinExcited_64x63); - dialog_ex_set_left_button_text(gui_tester->dialog_ex, "More"); - dialog_ex_set_right_button_text(gui_tester->dialog_ex, "Save"); - - // Popup - popup_set_callback(gui_tester->popup, popup_callback); - popup_set_context(gui_tester->popup, gui_tester); - popup_set_icon(gui_tester->popup, 0, 2, &I_DolphinMafia_115x62); - popup_set_text(gui_tester->popup, "Deleted", 83, 19, AlignLeft, AlignBottom); - popup_set_timeout(gui_tester->popup, 5000); - popup_enable_timeout(gui_tester->popup); - - // Text input - const uint8_t text_input_text_len = 64; - char* text_input_text = calloc(text_input_text_len + 1, 1); - memcpy(text_input_text, "New_ke", strlen("New_ke")); - - text_input_set_result_callback( - gui_tester->text_input, - text_input_callback, - gui_tester, - text_input_text, - text_input_text_len, - false); - text_input_set_header_text(gui_tester->text_input, "Name the key"); - - const uint8_t byte_input_bytes_len = 16; - uint8_t byte_input_bytes[16] = { - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - 0x06, - 0x07, - 0x08, - 0x09, - 0x0A, - 0x0B, - 0x0C, - 0x0D, - 0x0E, - 0x0F}; - - byte_input_set_result_callback( - gui_tester->byte_input, - byte_input_callback, - NULL, - gui_tester, - byte_input_bytes, - byte_input_bytes_len); - byte_input_set_header_text(gui_tester->byte_input, "Enter the key"); - - view_dispatcher_switch_to_view(gui_tester->view_dispatcher, gui_tester->view_index); - - while(1) { - if(osThreadFlagsWait(GUI_TEST_FLAG_EXIT, osFlagsWaitAny, osWaitForever)) { - break; - } - } - unsubscribe_pubsub(event_pubsub); - free(text_input_text); - gui_test_free(gui_tester); - - return 0; -} \ No newline at end of file diff --git a/applications/gui/gui.c b/applications/gui/gui.c index efad82ed..8ad45499 100644 --- a/applications/gui/gui.c +++ b/applications/gui/gui.c @@ -420,7 +420,7 @@ Gui* gui_alloc() { return gui; } -int32_t gui_task(void* p) { +int32_t gui_srv(void* p) { Gui* gui = gui_alloc(); furi_record_create("gui", gui); diff --git a/applications/ibutton/ibutton.cpp b/applications/ibutton/ibutton.cpp index 806f3ed0..f6bc9275 100644 --- a/applications/ibutton/ibutton.cpp +++ b/applications/ibutton/ibutton.cpp @@ -1,7 +1,7 @@ #include "ibutton-app.h" // app enter function -extern "C" int32_t app_ibutton(void* p) { +extern "C" int32_t ibutton_app(void* p) { iButtonApp* app = new iButtonApp(); app->run(p); delete app; diff --git a/applications/input/input.c b/applications/input/input.c index 0a4a3990..32a35597 100644 --- a/applications/input/input.c +++ b/applications/input/input.c @@ -91,7 +91,7 @@ void input_cli_send(Cli* cli, string_t args, void* context) { notify_pubsub(&input->event_pubsub, &event); } -int32_t input_task() { +int32_t input_srv() { input = furi_alloc(sizeof(Input)); input->thread = osThreadGetId(); init_pubsub(&input->event_pubsub); diff --git a/applications/irda/irda-runner.cpp b/applications/irda/irda-runner.cpp index 9753466b..bf9f51bc 100644 --- a/applications/irda/irda-runner.cpp +++ b/applications/irda/irda-runner.cpp @@ -1,6 +1,6 @@ #include "irda-app.hpp" -extern "C" int32_t irda(void* p) { +extern "C" int32_t irda_app(void* p) { IrdaApp* app = new IrdaApp(); int32_t result = app->run(p); delete app; diff --git a/applications/loader/loader.c b/applications/loader/loader.c index 85649264..97079bf5 100644 --- a/applications/loader/loader.c +++ b/applications/loader/loader.c @@ -291,7 +291,7 @@ static void loader_build_menu() { }); } -int32_t loader(void* p) { +int32_t loader_srv(void* p) { FURI_LOG_I(LOADER_LOG_TAG, "Starting"); loader_instance = loader_alloc(); diff --git a/applications/menu/menu.c b/applications/menu/menu.c index 7fc39aaa..ea7157d4 100644 --- a/applications/menu/menu.c +++ b/applications/menu/menu.c @@ -292,7 +292,7 @@ void menu_exit(Menu* menu) { menu_update(menu); } -int32_t menu_task(void* p) { +int32_t menu_srv(void* p) { ValueMutex* menu_mutex = menu_init(); MenuEvent* menu_event = NULL; diff --git a/applications/music-player/music-player.c b/applications/music-player/music-player.c index 7e065b1f..57713ada 100644 --- a/applications/music-player/music-player.c +++ b/applications/music-player/music-player.c @@ -358,7 +358,7 @@ void music_player_thread(void* p) { } } -int32_t music_player(void* p) { +int32_t music_player_app(void* p) { osMessageQueueId_t event_queue = osMessageQueueNew(8, sizeof(MusicDemoEvent), NULL); State _state; diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c index 734dade2..2e37a566 100755 --- a/applications/nfc/nfc.c +++ b/applications/nfc/nfc.c @@ -136,7 +136,20 @@ void nfc_free(Nfc* nfc) { free(nfc); } -int32_t nfc_task(void* p) { +void nfc_text_store_set(Nfc* nfc, const char* text, ...) { + va_list args; + va_start(args, text); + + vsnprintf(nfc->text_store, sizeof(nfc->text_store), text, args); + + va_end(args); +} + +void nfc_text_store_clear(Nfc* nfc) { + memset(nfc->text_store, 0, sizeof(nfc->text_store)); +} + +int32_t nfc_app(void* p) { Nfc* nfc = nfc_alloc(); // Check argument and run corresponding scene @@ -152,16 +165,3 @@ int32_t nfc_task(void* p) { return 0; } - -void nfc_text_store_set(Nfc* nfc, const char* text, ...) { - va_list args; - va_start(args, text); - - vsnprintf(nfc->text_store, sizeof(nfc->text_store), text, args); - - va_end(args); -} - -void nfc_text_store_clear(Nfc* nfc) { - memset(nfc->text_store, 0, sizeof(nfc->text_store)); -} diff --git a/applications/notification/notification-app.c b/applications/notification/notification-app.c index ffc90487..6e8f045a 100644 --- a/applications/notification/notification-app.c +++ b/applications/notification/notification-app.c @@ -434,7 +434,7 @@ static NotificationApp* notification_app_alloc() { }; // App -int32_t notification_app(void* p) { +int32_t notification_srv(void* p) { NotificationApp* app = notification_app_alloc(); if(!notification_load_settings(app)) { diff --git a/applications/notification/notification-app-settings.c b/applications/notification/notification-settings-app.c similarity index 99% rename from applications/notification/notification-app-settings.c rename to applications/notification/notification-settings-app.c index 3bcf084b..78d7c65e 100644 --- a/applications/notification/notification-app-settings.c +++ b/applications/notification/notification-settings-app.c @@ -222,7 +222,7 @@ static void free_settings(NotificationAppSettings* app) { free(app); } -int32_t notification_app_settings(void* p) { +int32_t notification_settings_app(void* p) { NotificationAppSettings* app = alloc_settings(); view_dispatcher_run(app->view_dispatcher); notification_message_save_settings(app->notification); diff --git a/applications/power-observer/power-observer.c b/applications/power-observer/power-observer.c index 5a411eca..d7b9b2f7 100644 --- a/applications/power-observer/power-observer.c +++ b/applications/power-observer/power-observer.c @@ -14,7 +14,7 @@ static const NotificationSequence sequence_overconsumption = { NULL, }; -int32_t power_observer(void* p) { +int32_t power_observer_srv(void* p) { NotificationApp* notifications = furi_record_open("notification"); const float overconsumption_limit = 0.03f; diff --git a/applications/power/power.c b/applications/power/power.c index 22bc5db4..1ab852fc 100644 --- a/applications/power/power.c +++ b/applications/power/power.c @@ -193,7 +193,7 @@ static void power_charging_indication_handler(Power* power, NotificationApp* not } } -int32_t power_task(void* p) { +int32_t power_srv(void* p) { (void)p; Power* power = power_alloc(); diff --git a/applications/storage-settings/storage-settings.c b/applications/storage-settings/storage-settings.c index 49da39a2..8e18071b 100644 --- a/applications/storage-settings/storage-settings.c +++ b/applications/storage-settings/storage-settings.c @@ -65,7 +65,7 @@ static void storage_settings_free(StorageSettings* app) { free(app); } -int32_t storage_settings(void* p) { +int32_t storage_settings_app(void* p) { StorageSettings* app = storage_settings_alloc(); view_dispatcher_run(app->view_dispatcher); diff --git a/applications/storage/storage-test-app.c b/applications/storage/storage-test-app.c index bfc8216f..7e3f0a58 100644 --- a/applications/storage/storage-test-app.c +++ b/applications/storage/storage-test-app.c @@ -315,7 +315,7 @@ static void do_test_end(Storage* api, const char* path) { string_clear(str_path_2); } -int32_t storage_app_test(void* p) { +int32_t storage_test_app(void* p) { Storage* api = furi_record_open("storage"); do_test_start(api, "/int"); do_test_start(api, "/any"); diff --git a/applications/storage/storage.c b/applications/storage/storage.c index 601ac441..ef229db0 100644 --- a/applications/storage/storage.c +++ b/applications/storage/storage.c @@ -79,7 +79,7 @@ void storage_tick(Storage* app) { } } -int32_t storage_app(void* p) { +int32_t storage_srv(void* p) { Storage* app = storage_app_alloc(); furi_record_create("storage", app);