Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrZlo13 <who.just.the.doctor@gmail.com>2021-01-20 19:09:26 +0300
committerGitHub <noreply@github.com>2021-01-20 19:09:26 +0300
commit8f9b2513ffdda4afd9a3bce1906183bf8c5a8622 (patch)
treed6d47f17d0717e1db436ab6c7ef16fcfa9913132 /applications
parent6c4983c6b6a03c025c39cdd5d7100a4c955b6cf6 (diff)
[FL-140] Core api dynamic records (#296)
* SYSTEM: tickless mode with deep sleep. * Move FreeRTOS ticks to lptim2 * API: move all sumbodules init routines to one place. Timebase: working lptim2 at tick source. * API Timebase: lp-timer routines, timer access safe zones prediction and synchronization. FreeRTOS: adjust configuration for tickless mode. * NFC: support for tickless mode. * API Timebase: improve tick error handling in IRQ. Apploader: use insomnia mode to run applications. * BLE: prevent sleep while core2 starting * HAL: nap while in insomnia mode * init records work * try to implement record delete * tests and flapp * flapp subsystem * new core functions to get app stat, simplify core code * fix thread termination * add strdup to core * fix tests * Refactoring: remove all unusued parts, update API usage, aggreagate API sources and headers, new record storage * Refactoring: update furi record api usage, cleanup code * Fix broken merge for freertos apps * Core, Target: fix compilation warnings * Drop firmware target local * HAL Timebase, Power, Clock: semaphore guarded access to clock and power modes, better sleep mode. * SD-Filesystem: wait for all deps to arrive before adding widget. Core, BLE: disable debug dump to serial. * delete old app example-ipc * delete old app fatfs list * fix strobe app, add input header * delete old display driver * comment old app qr-code * fix sd-card test, add forced widget update * remove unused new core test * increase heap to 128k * comment and assert old core tests * fix syntax Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
Diffstat (limited to 'applications')
-rw-r--r--applications/app-loader/app-loader.c87
-rw-r--r--applications/applications.c220
-rw-r--r--applications/applications.h303
-rw-r--r--applications/applications.mk1
-rw-r--r--applications/backlight-control/backlight-control.c23
-rw-r--r--applications/bt/bt.c27
-rw-r--r--applications/bt/bt_i.h11
-rw-r--r--applications/cc1101-workaround/cc1101-workaround.cpp11
-rw-r--r--applications/cc1101-workaround/cc1101.cpp2
-rw-r--r--applications/cc1101-workaround/cc1101.h2
-rw-r--r--applications/cli/cli.c9
-rw-r--r--applications/cli/cli_i.h3
-rw-r--r--applications/coreglitch_demo_0/coreglitch_demo_0.c6
-rw-r--r--applications/display-u8g2/display-u8g2.c195
-rw-r--r--applications/dolphin/dolphin.c12
-rw-r--r--applications/dolphin/dolphin_i.h2
-rw-r--r--applications/dolphin/dolphin_state.c3
-rw-r--r--applications/dolphin/dolphin_views.h3
-rw-r--r--applications/examples/blink.c2
-rw-r--r--applications/examples/fatfs_list.c155
-rw-r--r--applications/examples/input_dump.c9
-rw-r--r--applications/examples/ipc.c155
-rw-r--r--applications/examples/strobe.c6
-rw-r--r--applications/examples/u8g2_example.c36
-rw-r--r--applications/examples/u8g2_qrcode.c12
-rw-r--r--applications/examples/uart_write.c9
-rw-r--r--applications/examples/vibro.c5
m---------applications/floopper-bloopper0
-rw-r--r--applications/gpio-tester/gpio-tester.c12
-rw-r--r--applications/gui/canvas.c3
-rw-r--r--applications/gui/canvas.h8
-rw-r--r--applications/gui/elements.h8
-rw-r--r--applications/gui/gui.c11
-rw-r--r--applications/gui/gui.h8
-rw-r--r--applications/gui/gui_event.c4
-rw-r--r--applications/gui/gui_event.h8
-rw-r--r--applications/gui/icon.c4
-rw-r--r--applications/gui/icon.h8
-rw-r--r--applications/gui/u8g2_periphery.c18
-rw-r--r--applications/gui/view.h8
-rw-r--r--applications/gui/view_dispatcher.h8
-rw-r--r--applications/gui/view_dispatcher_i.h2
-rw-r--r--applications/gui/view_i.h2
-rw-r--r--applications/gui/widget.c6
-rw-r--r--applications/gui/widget.h8
-rw-r--r--applications/ibutton/ibutton.cpp2
-rw-r--r--applications/input/input.c14
-rw-r--r--applications/irda/irda-decoder/irda-decoder.h3
-rw-r--r--applications/irda/irda.c14
-rw-r--r--applications/irda/irda_nec.c2
-rw-r--r--applications/irda/irda_nec.h2
-rw-r--r--applications/irda/irda_samsung.c2
-rw-r--r--applications/irda/irda_samsung.h2
-rw-r--r--applications/lf-rfid/em4100.c2
-rw-r--r--applications/lf-rfid/lf-rfid.c13
-rw-r--r--applications/menu/menu.c13
-rw-r--r--applications/menu/menu_event.c4
-rw-r--r--applications/menu/menu_item.c3
-rw-r--r--applications/music-player/music-player.c14
-rw-r--r--applications/nfc/nfc.c12
-rw-r--r--applications/nfc/nfc_i.h2
-rw-r--r--applications/nfc/nfc_views.h2
-rw-r--r--applications/nfc/nfc_worker_i.h3
-rw-r--r--applications/power/power.c22
-rw-r--r--applications/power/power_views.h6
-rw-r--r--applications/sd-card-test/sd-card-test.cpp17
-rw-r--r--applications/sd-filesystem/sd-filesystem.c25
-rw-r--r--applications/sd-filesystem/sd-filesystem.h6
-rw-r--r--applications/template/template.c.example4
-rw-r--r--applications/tests/furi_event_test.c8
-rw-r--r--applications/tests/furi_pubsub_test.c4
-rw-r--r--applications/tests/furi_record_test.c8
-rw-r--r--applications/tests/furi_value_expanders_test.c2
-rw-r--r--applications/tests/furi_valuemutex_test.c6
-rw-r--r--applications/tests/furiac_test.c6
-rw-r--r--applications/tests/minunit_test.c3
-rw-r--r--applications/tests/test_index.c4
77 files changed, 535 insertions, 1130 deletions
diff --git a/applications/app-loader/app-loader.c b/applications/app-loader/app-loader.c
index d86d2fb6..6100a162 100644
--- a/applications/app-loader/app-loader.c
+++ b/applications/app-loader/app-loader.c
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
#include <cli/cli.h>
#include <gui/gui.h>
#include "menu/menu.h"
@@ -8,14 +8,15 @@
#include <api-hal.h>
typedef struct {
- FuriApp* handler;
+ osThreadAttr_t app_thread_attr;
+ osThreadId_t app_thread_id;
Widget* widget;
- const FlipperStartupApp* current_app;
+ const FuriApplication* current_app;
} AppLoaderState;
typedef struct {
AppLoaderState* state;
- const FlipperStartupApp* app;
+ const FuriApplication* app;
} AppLoaderContext;
// TODO add mutex for contex
@@ -36,7 +37,7 @@ static void input_callback(InputEvent* input_event, void* _ctx) {
AppLoaderState* ctx = (AppLoaderState*)_ctx;
if(input_event->state && input_event->input == InputBack) {
- furiac_kill(ctx->handler);
+ osThreadTerminate(ctx->app_thread_id);
widget_enabled_set(ctx->widget, false);
api_hal_timebase_insomnia_exit();
}
@@ -54,7 +55,16 @@ static void handle_menu(void* _ctx) {
api_hal_timebase_insomnia_enter();
ctx->state->current_app = ctx->app;
- ctx->state->handler = furiac_start(ctx->app->app, ctx->app->name, NULL);
+ ctx->state->app_thread_attr.name = ctx->app->name;
+ ctx->state->app_thread_attr.attr_bits = osThreadDetached;
+ ctx->state->app_thread_attr.cb_mem = NULL;
+ ctx->state->app_thread_attr.cb_size = 0;
+ ctx->state->app_thread_attr.stack_mem = NULL;
+ ctx->state->app_thread_attr.stack_size = 1024;
+ ctx->state->app_thread_attr.priority = osPriorityNormal;
+ ctx->state->app_thread_attr.tz_module = 0;
+ ctx->state->app_thread_attr.reserved = 0;
+ ctx->state->app_thread_id = osThreadNew(ctx->app->app, NULL, &ctx->state->app_thread_attr);
}
static void handle_cli(string_t args, void* _ctx) {
@@ -65,13 +75,22 @@ static void handle_cli(string_t args, void* _ctx) {
cli_print("Starting furi application\r\n");
ctx->state->current_app = ctx->app;
- ctx->state->handler = furiac_start(ctx->app->app, ctx->app->name, NULL);
+ ctx->state->app_thread_attr.name = ctx->app->name;
+ ctx->state->app_thread_attr.attr_bits = osThreadDetached;
+ ctx->state->app_thread_attr.cb_mem = NULL;
+ ctx->state->app_thread_attr.cb_size = 0;
+ ctx->state->app_thread_attr.stack_mem = NULL;
+ ctx->state->app_thread_attr.stack_size = 1024;
+ ctx->state->app_thread_attr.priority = osPriorityNormal;
+ ctx->state->app_thread_attr.tz_module = 0;
+ ctx->state->app_thread_attr.reserved = 0;
+ ctx->state->app_thread_id = osThreadNew(ctx->app->app, NULL, &ctx->state->app_thread_attr);
cli_print("Press any key to kill application");
char c;
cli_read(&c, 1);
- furiac_kill(ctx->state->handler);
+ osThreadTerminate(ctx->state->app_thread_id);
}
void app_loader(void* p) {
@@ -79,37 +98,23 @@ void app_loader(void* p) {
furi_check(self_id);
AppLoaderState state;
- state.handler = NULL;
+ state.app_thread_id = NULL;
state.widget = widget_alloc();
widget_enabled_set(state.widget, false);
widget_draw_callback_set(state.widget, render_callback, &state);
widget_input_callback_set(state.widget, input_callback, &state);
- ValueMutex* menu_mutex = furi_open("menu");
- if(menu_mutex == NULL) {
- printf("menu is not available\n");
- furiac_exit(NULL);
- }
-
- Cli* cli = furi_open("cli");
+ ValueMutex* menu_mutex = furi_record_open("menu");
+ Cli* cli = furi_record_open("cli");
+ Gui* gui = furi_record_open("gui");
- // Open GUI and register widget
- Gui* gui = furi_open("gui");
- if(gui == NULL) {
- printf("gui is not available\n");
- furiac_exit(NULL);
- }
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++) {
+ for(size_t i = 0; i < FLIPPER_APPS_size(); i++) {
AppLoaderContext* ctx = furi_alloc(sizeof(AppLoaderContext));
ctx->state = &state;
ctx->app = &FLIPPER_APPS[i];
@@ -123,13 +128,11 @@ void app_loader(void* p) {
ctx));
// Add cli command
- if(cli) {
- string_t cli_name;
- string_init_set_str(cli_name, "app_");
- string_cat_str(cli_name, FLIPPER_APPS[i].name);
- cli_add_command(cli, string_get_cstr(cli_name), handle_cli, ctx);
- string_clear(cli_name);
- }
+ string_t cli_name;
+ string_init_set_str(cli_name, "app_");
+ string_cat_str(cli_name, FLIPPER_APPS[i].name);
+ cli_add_command(cli, string_get_cstr(cli_name), handle_cli, ctx);
+ string_clear(cli_name);
}
});
@@ -157,7 +160,7 @@ void app_loader(void* p) {
MenuItem* menu_plugins =
menu_item_alloc_menu("Plugins", assets_icons_get(A_Plugins_14));
- for(size_t i = 0; i < flipper_plugins_count; i++) {
+ for(size_t i = 0; i < FLIPPER_PLUGINS_size(); i++) {
AppLoaderContext* ctx = furi_alloc(sizeof(AppLoaderContext));
ctx->state = &state;
ctx->app = &FLIPPER_PLUGINS[i];
@@ -171,13 +174,11 @@ void app_loader(void* p) {
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);
- }
+ 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);
@@ -186,4 +187,4 @@ void app_loader(void* p) {
printf("[app loader] start\n");
osThreadSuspend(self_id);
-} \ No newline at end of file
+}
diff --git a/applications/applications.c b/applications/applications.c
new file mode 100644
index 00000000..fa552e09
--- /dev/null
+++ b/applications/applications.c
@@ -0,0 +1,220 @@
+#include "applications.h"
+
+#ifdef APP_TEST
+void flipper_test_app(void* p);
+#endif
+
+void application_blink(void* p);
+void application_uart_write(void* p);
+void application_ipc_display(void* p);
+void application_ipc_widget(void* p);
+void application_input_dump(void* p);
+void display_u8g2(void* p);
+void u8g2_example(void* p);
+void input_task(void* p);
+void menu_task(void* p);
+void coreglitch_demo_0(void* p);
+void u8g2_qrcode(void* p);
+void fatfs_list(void* p);
+void gui_task(void* p);
+void backlight_control(void* p);
+void irda(void* p);
+void app_loader(void* p);
+void cc1101_workaround(void* p);
+void lf_rfid_workaround(void* p);
+void nfc_task(void* p);
+void dolphin_task(void* p);
+void power_task(void* p);
+void bt_task(void* p);
+void sd_card_test(void* p);
+void application_vibro(void* p);
+void app_gpio_test(void* p);
+void app_ibutton(void* p);
+void cli_task(void* p);
+void music_player(void* p);
+void sdnfc(void* p);
+void floopper_bloopper(void* p);
+void sd_filesystem(void* p);
+
+const FuriApplication FLIPPER_SERVICES[] = {
+#ifdef APP_DISPLAY
+ {.app = display_u8g2, .name = "display_u8g2", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_CLI
+ {.app = cli_task, .name = "cli_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_EXAMPLE_BLINK
+ {.app = application_blink, .name = "blink", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_INPUT
+ {.app = input_task, .name = "input_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_EXAMPLE_INPUT_DUMP
+ {.app = application_input_dump, .name = "input dump", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_GUI
+ {.app = backlight_control, .name = "backlight_control", .icon = A_Plugins_14},
+ {.app = gui_task, .name = "gui_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_MENU
+ {.app = menu_task, .name = "menu_task", .icon = A_Plugins_14},
+ {.app = app_loader, .name = "app_loader", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_SD_FILESYSTEM
+ {.app = sd_filesystem, .name = "sd_filesystem", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_DOLPHIN
+ {.app = dolphin_task, .name = "dolphin_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_POWER
+ {.app = power_task, .name = "power_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_BT
+ {.app = bt_task, .name = "bt_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_CC1101
+ {.app = cc1101_workaround, .name = "cc1101 workaround", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_LF_RFID
+ {.app = lf_rfid_workaround, .name = "lf rfid workaround", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_IRDA
+ {.app = irda, .name = "irda", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_NFC
+ {.app = nfc_task, .name = "nfc_task", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_TEST
+ {.app = flipper_test_app, .name = "test app", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_EXAMPLE_IPC
+ {.app = application_ipc_display, .name = "ipc display", .icon = A_Plugins_14},
+ {.app = application_ipc_widget, .name = "ipc widget", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_EXAMPLE_QRCODE
+ {.app = u8g2_qrcode, .name = "u8g2_qrcode", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_EXAMPLE_FATFS
+ {.app = fatfs_list, .name = "fatfs_list", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_EXAMPLE_DISPLAY
+ {.app = u8g2_example, .name = "u8g2_example", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_SPEAKER_DEMO
+ {.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_SD_TEST
+ {.app = sd_card_test, .name = "sd_card_test", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_MUSIC_PLAYER
+ {.app = music_player, .name = "music player", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_IBUTTON
+ {.app = app_ibutton, .name = "ibutton", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_GPIO_DEMO
+ {.app = app_gpio_test, .name = "gpio test", .icon = A_Plugins_14},
+#endif
+
+#ifdef APP_FLOOPPER_BLOOPPER
+ {.app = floopper_bloopper, .name = "Floopper Bloopper", .icon = A_Games_14},
+#endif
+
+#ifdef APP_SDNFC
+ {.app = sdnfc, .name = "sdnfc", .icon = A_Plugins_14},
+#endif
+};
+
+size_t FLIPPER_SERVICES_size() {
+ return sizeof(FLIPPER_SERVICES) / sizeof(FuriApplication);
+}
+
+// Main menu APP
+const FuriApplication FLIPPER_APPS[] = {
+#ifdef BUILD_CC1101
+ {.app = cc1101_workaround, .name = "Sub-1 GHz", .icon = A_Sub1ghz_14},
+#endif
+
+#ifdef BUILD_LF_RFID
+ {.app = lf_rfid_workaround, .name = "125 kHz RFID", .icon = A_125khz_14},
+#endif
+
+#ifdef BUILD_IRDA
+ {.app = irda, .name = "Infrared", .icon = A_Infrared_14},
+#endif
+
+#ifdef BUILD_IBUTTON
+ {.app = app_ibutton, .name = "iButton", .icon = A_iButton_14},
+#endif
+
+#ifdef BUILD_GPIO_DEMO
+ {.app = app_gpio_test, .name = "GPIO", .icon = A_GPIO_14},
+#endif
+};
+
+size_t FLIPPER_APPS_size() {
+ return sizeof(FLIPPER_APPS) / sizeof(FuriApplication);
+}
+
+// Plugin menu
+const FuriApplication FLIPPER_PLUGINS[] = {
+#ifdef BUILD_EXAMPLE_BLINK
+ {.app = application_blink, .name = "blink", .icon = A_Plugins_14},
+#endif
+
+#ifdef BUILD_EXAMPLE_INPUT_DUMP
+ {.app = application_input_dump, .name = "input dump", .icon = A_Plugins_14},
+#endif
+
+#ifdef BUILD_SPEAKER_DEMO
+ {.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .icon = A_Plugins_14},
+#endif
+
+#ifdef BUILD_SD_TEST
+ {.app = sd_card_test, .name = "sd_card_test", .icon = A_Plugins_14},
+#endif
+
+#ifdef BUILD_VIBRO_DEMO
+ {.app = application_vibro, .name = "application_vibro", .icon = A_Plugins_14},
+#endif
+
+#ifdef BUILD_MUSIC_PLAYER
+ {.app = music_player, .name = "music player", .icon = A_Plugins_14},
+#endif
+
+#ifdef BUILD_FLOOPPER_BLOOPPER
+ {.app = floopper_bloopper, .name = "Floopper Bloopper", .icon = A_Games_14},
+#endif
+
+#ifdef BUILD_SDNFC
+ {.app = sdnfc, .name = "sdnfc", .icon = A_Plugins_14},
+#endif
+};
+
+size_t FLIPPER_PLUGINS_size() {
+ return sizeof(FLIPPER_PLUGINS) / sizeof(FuriApplication);
+}
diff --git a/applications/applications.h b/applications/applications.h
index 1b80891f..44c25acd 100644
--- a/applications/applications.h
+++ b/applications/applications.h
@@ -1,296 +1,21 @@
#pragma once
-#include "flipper.h"
+#include <furi.h>
+#include <assets_icons.h>
-#ifdef APP_TEST
-void flipper_test_app(void* p);
-#endif
+typedef void (*FlipperApplication)(void*);
-void application_blink(void* p);
-void application_uart_write(void* p);
-void application_ipc_display(void* p);
-void application_ipc_widget(void* p);
-void application_input_dump(void* p);
+typedef struct {
+ const FlipperApplication app;
+ const char* name;
+ const IconName icon;
+} FuriApplication;
-void display_u8g2(void* p);
+extern const FuriApplication FLIPPER_SERVICES[];
+size_t FLIPPER_SERVICES_size();
-void u8g2_example(void* p);
+extern const FuriApplication FLIPPER_APPS[];
+size_t FLIPPER_APPS_size();
-void input_task(void* p);
-void menu_task(void* p);
-
-void coreglitch_demo_0(void* p);
-
-void u8g2_qrcode(void* p);
-void fatfs_list(void* p);
-void gui_task(void* p);
-void backlight_control(void* p);
-void irda(void* p);
-void app_loader(void* p);
-void cc1101_workaround(void* p);
-void lf_rfid_workaround(void* p);
-void nfc_task(void* p);
-void dolphin_task(void* p);
-void power_task(void* p);
-void bt_task(void* p);
-void sd_card_test(void* p);
-void application_vibro(void* p);
-void app_gpio_test(void* p);
-void app_ibutton(void* p);
-void cli_task(void* p);
-void music_player(void* p);
-void sdnfc(void* p);
-void floopper_bloopper(void* p);
-void sd_filesystem(void* p);
-
-const FlipperStartupApp FLIPPER_STARTUP[] = {
-#ifdef APP_DISPLAY
- {.app = display_u8g2, .name = "display_u8g2", .libs = {0}, .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_CLI
- {.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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_INPUT
- {.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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_GUI
- {.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"}},
- .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_SD_FILESYSTEM
- {.app = sd_filesystem,
- .name = "sd_filesystem",
- .libs = {1, FURI_LIB{"menu_task"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_DOLPHIN
- {.app = dolphin_task,
- .name = "dolphin_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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_BT
- {.app = bt_task, .name = "bt_task", .libs = {1, FURI_LIB{"cli_task"}}, .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_CC1101
- {.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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_IRDA
- {.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"}}, .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_TEST
- {.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}, .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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_EXAMPLE_FATFS
- {.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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_SPEAKER_DEMO
- {.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 = {2, FURI_LIB{"gui_task", "sd_filesystem"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_MUSIC_PLAYER
- {.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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_GPIO_DEMO
- {.app = app_gpio_test,
- .name = "gpio test",
- .libs = {1, FURI_LIB{"gui_task"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef APP_FLOOPPER_BLOOPPER
- {.app = floopper_bloopper,
- .name = "Floopper Bloopper",
- .libs = {1, FURI_LIB{"gui_task"}},
- .icon = A_Games_14},
-#endif
-
-#ifdef APP_SDNFC
- {.app = sdnfc, .name = "sdnfc", .libs = {1, FURI_LIB{"gui_task"}}, .icon = A_Plugins_14},
-#endif
-};
-
-// Main menu APP
-const FlipperStartupApp FLIPPER_APPS[] = {
-#ifdef BUILD_CC1101
- {.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 = "125 kHz RFID",
- .libs = {1, FURI_LIB{"gui_task"}},
- .icon = A_125khz_14},
-#endif
-
-#ifdef BUILD_IRDA
- {.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"}},
- .icon = A_iButton_14},
-#endif
-
-#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 = {2, FURI_LIB{"gui_task", "sd_filesystem"}},
- .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"}},
- .icon = A_Plugins_14},
-#endif
-
-#ifdef BUILD_FLOOPPER_BLOOPPER
- {.app = floopper_bloopper,
- .name = "Floopper Bloopper",
- .libs = {1, FURI_LIB{"gui_task"}},
- .icon = A_Games_14},
-#endif
-
-#ifdef BUILD_SDNFC
- {.app = sdnfc, .name = "sdnfc", .libs = {1, FURI_LIB{"gui_task"}}, .icon = A_Plugins_14},
-#endif
-}; \ No newline at end of file
+extern const FuriApplication FLIPPER_PLUGINS[];
+size_t FLIPPER_PLUGINS_size();
diff --git a/applications/applications.mk b/applications/applications.mk
index e27f6146..d79926c0 100644
--- a/applications/applications.mk
+++ b/applications/applications.mk
@@ -2,6 +2,7 @@ APP_DIR = $(PROJECT_ROOT)/applications
LIB_DIR = $(PROJECT_ROOT)/lib
CFLAGS += -I$(APP_DIR)
+C_SOURCES += $(APP_DIR)/applications.c
# Use APP_* for autostart app
# Use BUILD_* for add app to build
diff --git a/applications/backlight-control/backlight-control.c b/applications/backlight-control/backlight-control.c
index a640b5aa..ed412f91 100644
--- a/applications/backlight-control/backlight-control.c
+++ b/applications/backlight-control/backlight-control.c
@@ -1,11 +1,12 @@
-#include "flipper_v2.h"
+#include <furi.h>
+
+#define BACKLIGHT_TIME 10000
+#define BACKLIGHT_FLAG_ACTIVITY 0x00000001U
static void event_cb(const void* value, void* ctx) {
- xSemaphoreGive((SemaphoreHandle_t*)ctx);
+ osThreadFlagsSet((osThreadId_t)ctx, BACKLIGHT_FLAG_ACTIVITY);
}
-const uint32_t BACKLIGHT_TIME = 10000;
-
void backlight_control(void* p) {
// TODO open record
const GpioPin* backlight_record = &backlight_gpio;
@@ -14,20 +15,14 @@ void backlight_control(void* p) {
gpio_init(backlight_record, GpioModeOutputPushPull);
gpio_write(backlight_record, true);
- StaticSemaphore_t event_descriptor;
- SemaphoreHandle_t update = xSemaphoreCreateCountingStatic(255, 0, &event_descriptor);
-
// open record
- PubSub* event_record = furi_open("input_events");
- furi_check(event_record);
- subscribe_pubsub(event_record, event_cb, (void*)update);
-
- // we ready to work
- furiac_ready();
+ PubSub* event_record = furi_record_open("input_events");
+ subscribe_pubsub(event_record, event_cb, (void*)osThreadGetId());
while(1) {
// wait for event
- if(xSemaphoreTake(update, BACKLIGHT_TIME) == pdTRUE) {
+ if(osThreadFlagsWait(BACKLIGHT_FLAG_ACTIVITY, osFlagsWaitAny, BACKLIGHT_TIME) ==
+ BACKLIGHT_FLAG_ACTIVITY) {
gpio_write(backlight_record, true);
} else {
gpio_write(backlight_record, false);
diff --git a/applications/bt/bt.c b/applications/bt/bt.c
index d77293e2..bc2a4cb0 100644
--- a/applications/bt/bt.c
+++ b/applications/bt/bt.c
@@ -2,16 +2,23 @@
Bt* bt_alloc() {
Bt* bt = furi_alloc(sizeof(Bt));
- bt->cli = furi_open("cli");
+
+ bt->cli = furi_record_open("cli");
+ cli_add_command(bt->cli, "bt_info", bt_cli_info, bt);
+ bt->gui = furi_record_open("gui");
+ bt->menu = furi_record_open("menu");
bt->statusbar_icon = assets_icons_get(I_Bluetooth_5x8);
bt->statusbar_widget = widget_alloc();
widget_set_width(bt->statusbar_widget, icon_get_width(bt->statusbar_icon));
widget_draw_callback_set(bt->statusbar_widget, bt_draw_statusbar_callback, bt);
widget_enabled_set(bt->statusbar_widget, false);
+ gui_add_widget(bt->gui, bt->statusbar_widget, GuiLayerStatusBarLeft);
bt->menu_icon = assets_icons_get(A_Bluetooth_14);
bt->menu_item = menu_item_alloc_menu("Bluetooth", bt->menu_icon);
+ with_value_mutex(
+ bt->menu, (Menu * menu) { menu_item_add(menu, bt->menu_item); });
return bt;
}
@@ -33,23 +40,7 @@ void bt_cli_info(string_t args, void* context) {
void bt_task() {
Bt* bt = bt_alloc();
- if(bt->cli) {
- cli_add_command(bt->cli, "bt_info", bt_cli_info, bt);
- }
-
- // TODO: add ValueMutex(bt) to "bt" record
- if(!furi_create("bt", bt)) {
- printf("[bt_task] unable to create bt record\n");
- furiac_exit(NULL);
- }
-
- Gui* gui = furi_open("gui");
- gui_add_widget(gui, bt->statusbar_widget, GuiLayerStatusBarLeft);
-
- with_value_mutex(
- furi_open("menu"), (Menu * menu) { menu_item_add(menu, bt->menu_item); });
-
- furiac_ready();
+ furi_record_create("bt", bt);
api_hal_bt_init();
diff --git a/applications/bt/bt_i.h b/applications/bt/bt_i.h
index a6eec8ff..01acfca8 100644
--- a/applications/bt/bt_i.h
+++ b/applications/bt/bt_i.h
@@ -2,10 +2,9 @@
#include "bt.h"
-#include <cli/cli.h>
+#include <furi.h>
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <cli/cli.h>
#include <gui/gui.h>
#include <gui/widget.h>
@@ -15,6 +14,8 @@
typedef struct {
Cli* cli;
+ Gui* gui;
+ ValueMutex* menu;
// Status bar
Icon* statusbar_icon;
Widget* statusbar_widget;
@@ -26,3 +27,7 @@ typedef struct {
Bt* bt_alloc();
void bt_draw_statusbar_callback(Canvas* canvas, void* context);
+
+void bt_cli_info(string_t args, void* context);
+
+void bt_draw_statusbar_callback(Canvas* canvas, void* context);
diff --git a/applications/cc1101-workaround/cc1101-workaround.cpp b/applications/cc1101-workaround/cc1101-workaround.cpp
index 57405ed7..d6140c22 100644
--- a/applications/cc1101-workaround/cc1101-workaround.cpp
+++ b/applications/cc1101-workaround/cc1101-workaround.cpp
@@ -1,6 +1,7 @@
-#include "flipper.h"
-
-#include "cc1101-workaround/cc1101.h"
+#include "cc1101.h"
+#include <furi.h>
+#include <gui/gui.h>
+#include <input/input.h>
extern "C" void cli_print(const char* str);
@@ -335,7 +336,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
}
static void input_callback(InputEvent* input_event, void* ctx) {
- osMessageQueueId_t event_queue = (QueueHandle_t)ctx;
+ osMessageQueueId_t event_queue = ctx;
AppEvent event;
event.type = EventTypeKey;
@@ -370,7 +371,7 @@ extern "C" void cc1101_workaround(void* p) {
widget_input_callback_set(widget, input_callback, event_queue);
// Open GUI and register widget
- Gui* gui = (Gui*)furi_open("gui");
+ Gui* gui = (Gui*)furi_record_open("gui");
if(gui == NULL) {
printf("[cc1101] gui is not available\n");
furiac_exit(NULL);
diff --git a/applications/cc1101-workaround/cc1101.cpp b/applications/cc1101-workaround/cc1101.cpp
index 620902d0..2ef2930e 100644
--- a/applications/cc1101-workaround/cc1101.cpp
+++ b/applications/cc1101-workaround/cc1101.cpp
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
#include "cc1101-workaround/cc1101.h"
#include "spi.h"
#include <math.h>
diff --git a/applications/cc1101-workaround/cc1101.h b/applications/cc1101-workaround/cc1101.h
index aa36e279..236b899d 100644
--- a/applications/cc1101-workaround/cc1101.h
+++ b/applications/cc1101-workaround/cc1101.h
@@ -1,6 +1,6 @@
#pragma once
-#include "flipper_v2.h"
+#include <furi.h>
#define F_OSC 26e6
diff --git a/applications/cli/cli.c b/applications/cli/cli.c
index befebf08..3d587dfe 100644
--- a/applications/cli/cli.c
+++ b/applications/cli/cli.c
@@ -1,8 +1,6 @@
#include "cli_i.h"
#include "cli_commands.h"
-#include <api-hal-vcp.h>
-
Cli* cli_alloc() {
Cli* cli = furi_alloc(sizeof(Cli));
CliCommandDict_init(cli->commands);
@@ -175,12 +173,7 @@ void cli_task(void* p) {
// Init basic cli commands
cli_commands_init(cli);
- if(!furi_create("cli", cli)) {
- printf("[cli_task] cannot create the cli record\n");
- furiac_exit(NULL);
- }
-
- furiac_ready();
+ furi_record_create("cli", cli);
while(1) {
cli_process_input(cli);
diff --git a/applications/cli/cli_i.h b/applications/cli/cli_i.h
index e8a8363d..9873c398 100644
--- a/applications/cli/cli_i.h
+++ b/applications/cli/cli_i.h
@@ -2,8 +2,7 @@
#include "cli.h"
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
#include <m-dict.h>
diff --git a/applications/coreglitch_demo_0/coreglitch_demo_0.c b/applications/coreglitch_demo_0/coreglitch_demo_0.c
index 12e1ebd1..3e9debc1 100644
--- a/applications/coreglitch_demo_0/coreglitch_demo_0.c
+++ b/applications/coreglitch_demo_0/coreglitch_demo_0.c
@@ -1,12 +1,10 @@
-#include "flipper.h"
+#include <furi.h>
#include "u8g2/u8g2.h"
extern TIM_HandleTypeDef SPEAKER_TIM;
void coreglitch_demo_0(void* p) {
- FuriRecordSubscriber* log = get_default_log();
-
- fuprintf(log, "coreglitch demo!\n");
+ printf("coreglitch demo!\n");
float notes[] = {
0.0,
diff --git a/applications/display-u8g2/display-u8g2.c b/applications/display-u8g2/display-u8g2.c
deleted file mode 100644
index c51cb1ca..00000000
--- a/applications/display-u8g2/display-u8g2.c
+++ /dev/null
@@ -1,195 +0,0 @@
-#include "u8g2/u8g2.h"
-#include "flipper.h"
-#include "main.h"
-
-extern SPI_HandleTypeDef SPI_D;
-
-// TODO: fix log
-#ifdef DEBUG
-#undef DEBUG
-#endif
-
-// TODO rewrite u8g2 to pass thread-local context in this handlers
-
-static uint8_t
-u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
- switch(msg) {
- //Initialize SPI peripheral
- case U8X8_MSG_GPIO_AND_DELAY_INIT:
- /* HAL initialization contains all what we need so we can skip this part. */
- break;
-
- //Function which implements a delay, arg_int contains the amount of ms
- case U8X8_MSG_DELAY_MILLI:
- osDelay(arg_int);
- break;
-
- //Function which delays 10us
- case U8X8_MSG_DELAY_10MICRO:
- delay_us(10);
- break;
-
- //Function which delays 100ns
- case U8X8_MSG_DELAY_100NANO:
- asm("nop");
- break;
-
- // Function to define the logic level of the RESET line
- case U8X8_MSG_GPIO_RESET:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] rst %d\n", arg_int);
-#endif
-
- // TODO change it to FuriRecord pin
- HAL_GPIO_WritePin(
- DISPLAY_RST_GPIO_Port, DISPLAY_RST_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET);
- break;
-
- default:
-#ifdef DEBUG
- fufuprintf(log, "[u8g2] unknown io %d\n", msg);
-#endif
-
- return 0; //A message was received which is not implemented, return 0 to indicate an error
- }
-
- return 1; // command processed successfully.
-}
-
-static uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr) {
- switch(msg) {
- case U8X8_MSG_BYTE_SEND:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]);
-#endif
-
- // TODO change it to FuriRecord SPI
- HAL_SPI_Transmit(&SPI_D, (uint8_t*)arg_ptr, arg_int, 10000);
- break;
-
- case U8X8_MSG_BYTE_SET_DC:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] dc %d\n", arg_int);
-#endif
-
- // TODO change it to FuriRecord pin
- HAL_GPIO_WritePin(
- DISPLAY_DI_GPIO_Port, DISPLAY_DI_Pin, arg_int ? GPIO_PIN_SET : GPIO_PIN_RESET);
- break;
-
- case U8X8_MSG_BYTE_INIT:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] init\n");
-#endif
-
- // TODO change it to FuriRecord pin
- HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET);
- break;
-
- case U8X8_MSG_BYTE_START_TRANSFER:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] start\n");
-#endif
-
- // TODO change it to FuriRecord pin
- HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_RESET);
- asm("nop");
- break;
-
- case U8X8_MSG_BYTE_END_TRANSFER:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] end\n");
-#endif
-
- asm("nop");
- // TODO change it to FuriRecord pin
- HAL_GPIO_WritePin(DISPLAY_CS_GPIO_Port, DISPLAY_CS_Pin, GPIO_PIN_SET);
- break;
-
- default:
-#ifdef DEBUG
- fuprintf(log, "[u8g2] unknown xfer %d\n", msg);
-#endif
-
- return 0;
- }
-
- return 1;
-}
-
-typedef struct {
- SemaphoreHandle_t update; // queue to pass events from callback to app thread
- FuriRecordSubscriber* log; // app logger
-} DisplayCtx;
-
-static void handle_fb_change(const void* fb, size_t fb_size, void* raw_ctx) {
- DisplayCtx* ctx = (DisplayCtx*)raw_ctx; // make right type
-
- // fuprintf(ctx->log, "[display_u8g2] change fb\n");
-
- // send update to app thread
- xSemaphoreGive(ctx->update);
-}
-
-void display_u8g2(void* p) {
- FuriRecordSubscriber* log = get_default_log();
-
- // TODO we need different app to contol backlight
- HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET);
-
- u8g2_t _u8g2;
- u8g2_Setup_st7565_erc12864_alt_f(
- &_u8g2, U8G2_R0, u8x8_hw_spi_stm32, u8g2_gpio_and_delay_stm32);
- u8g2_InitDisplay(
- &_u8g2); // send init sequence to the display, display is in sleep mode after this
- u8g2_SetContrast(&_u8g2, 36);
-
- if(!furi_create_deprecated("u8g2_fb", (void*)&_u8g2, sizeof(_u8g2))) {
- fuprintf(log, "[display_u8g2] cannot create fb record\n");
- furiac_exit(NULL);
- }
-
- StaticSemaphore_t event_descriptor;
- // create stack-based counting semaphore
- SemaphoreHandle_t update = xSemaphoreCreateCountingStatic(255, 0, &event_descriptor);
-
- if(update == NULL) {
- fuprintf(log, "[display_u8g2] cannot create update semaphore\n");
- furiac_exit(NULL);
- }
-
- // save log and event queue in context structure
- DisplayCtx ctx = {.update = update, .log = log};
-
- // subscribe to record. ctx will be passed to handle_fb_change
- FuriRecordSubscriber* fb_record =
- furi_open_deprecated("u8g2_fb", false, false, handle_fb_change, NULL, &ctx);
-
- if(fb_record == NULL) {
- fuprintf(log, "[display] cannot open fb record\n");
- furiac_exit(NULL);
- }
-
- u8g2_t* u8g2 = (u8g2_t*)furi_take(fb_record);
- u8g2_SetPowerSave(u8g2, 0); // wake up display
- u8g2_SendBuffer(u8g2);
- furi_give(fb_record);
-
- // we ready to work
- furiac_ready();
-
- while(1) {
- // wait for event
- if(xSemaphoreTake(update, 10000) == pdTRUE) {
- HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET);
-
- u8g2_t* u8g2 = (u8g2_t*)furi_take(fb_record);
- u8g2_SetPowerSave(u8g2, 0); // wake up display
- u8g2_SendBuffer(u8g2);
- furi_give(fb_record);
- } else {
- // TODO we need different app to contol backlight
- HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET);
- }
- }
-} \ No newline at end of file
diff --git a/applications/dolphin/dolphin.c b/applications/dolphin/dolphin.c
index 619c5fc2..cae109c3 100644
--- a/applications/dolphin/dolphin.c
+++ b/applications/dolphin/dolphin.c
@@ -67,8 +67,7 @@ Dolphin* dolphin_alloc() {
// State
dolphin->state = dolphin_state_alloc();
// Menu
- dolphin->menu_vm = furi_open("menu");
- furi_check(dolphin->menu_vm);
+ dolphin->menu_vm = furi_record_open("menu");
// GUI
dolphin->idle_view_dispatcher = view_dispatcher_alloc();
// First start View
@@ -125,7 +124,7 @@ void dolphin_deed(Dolphin* dolphin, DolphinDeed deed) {
void dolphin_task() {
Dolphin* dolphin = dolphin_alloc();
- Gui* gui = furi_open("gui");
+ Gui* gui = furi_record_open("gui");
view_dispatcher_attach_to_gui(dolphin->idle_view_dispatcher, gui, ViewDispatcherTypeWindow);
if(dolphin_state_load(dolphin->state)) {
view_dispatcher_switch_to_view(dolphin->idle_view_dispatcher, DolphinViewIdleMain);
@@ -138,12 +137,7 @@ void dolphin_task() {
model->butthurt = dolphin_state_get_butthurt(dolphin->state);
});
- if(!furi_create("dolphin", dolphin)) {
- printf("[dolphin_task] cannot create the dolphin record\n");
- furiac_exit(NULL);
- }
-
- furiac_ready();
+ furi_record_create("dolphin", dolphin);
DolphinEvent event;
while(1) {
diff --git a/applications/dolphin/dolphin_i.h b/applications/dolphin/dolphin_i.h
index 79a2b2fa..3d67f98c 100644
--- a/applications/dolphin/dolphin_i.h
+++ b/applications/dolphin/dolphin_i.h
@@ -4,7 +4,7 @@
#include "dolphin_state.h"
#include "dolphin_views.h"
-#include <flipper_v2.h>
+#include <furi.h>
#include <gui/gui.h>
#include <gui/view_dispatcher.h>
diff --git a/applications/dolphin/dolphin_state.c b/applications/dolphin/dolphin_state.c
index afe007bb..77344c65 100644
--- a/applications/dolphin/dolphin_state.c
+++ b/applications/dolphin/dolphin_state.c
@@ -1,6 +1,5 @@
#include "dolphin_state.h"
-#include <api-hal-flash.h>
-#include <flipper_v2.h>
+#include <furi.h>
typedef struct {
uint8_t magic;
diff --git a/applications/dolphin/dolphin_views.h b/applications/dolphin/dolphin_views.h
index 8c353e5d..212b57b1 100644
--- a/applications/dolphin/dolphin_views.h
+++ b/applications/dolphin/dolphin_views.h
@@ -3,7 +3,8 @@
#include <stdint.h>
#include <stdbool.h>
#include <gui/canvas.h>
-#include <flipper_v2.h>
+#include <input/input.h>
+#include <furi.h>
// Idle scree
typedef enum {
diff --git a/applications/examples/blink.c b/applications/examples/blink.c
index cf5718ce..1362f7d3 100644
--- a/applications/examples/blink.c
+++ b/applications/examples/blink.c
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
void rgb_set(
bool r,
diff --git a/applications/examples/fatfs_list.c b/applications/examples/fatfs_list.c
deleted file mode 100644
index 60361f51..00000000
--- a/applications/examples/fatfs_list.c
+++ /dev/null
@@ -1,155 +0,0 @@
-#include "u8g2/u8g2.h"
-#include "fatfs/ff.h"
-#include "flipper_v2.h"
-#include <stdio.h>
-
-extern uint8_t BSP_SD_Init();
-
-// TODO currently we have small stack, so it will be static
-FuriRecordSubscriber* furi_log;
-#define STR_BUFFER_SIZE 128
-char str_buffer[STR_BUFFER_SIZE];
-uint8_t line_current = 0;
-uint16_t line_position = 0;
-
-// TODO this should be in the target driver
-FATFS SD_FatFs;
-char SD_Path[4];
-
-typedef enum {
- EventTypeStart,
- EventTypeKey,
-} AppEventType;
-
-typedef struct {
- union {
- InputEvent input;
- } value;
- AppEventType type;
-} AppEvent;
-
-static void event_cb(const void* value, void* ctx) {
- QueueHandle_t event_queue = (QueueHandle_t)ctx;
-
- AppEvent event;
- event.type = EventTypeKey;
- event.value.input = *(InputEvent*)value;
- xQueueSend(event_queue, (void*)&event, 0);
-}
-
-void fatfs_list(void* p) {
- const uint8_t line_size = 10;
- const uint8_t lines_on_display = 6;
-
- uint8_t bsp_result;
- FRESULT result;
- DIR dir;
- FILINFO fno;
- AppEvent event;
-
- QueueHandle_t event_queue = xQueueCreate(2, sizeof(AppEvent));
-
- furi_log = get_default_log();
- fuprintf(furi_log, "[fatfs_list] app start\n");
- fuprintf(furi_log, "[fatfs_list] wait for sd insert\n");
-
- while(!hal_gpio_read_sd_detect()) {
- delay(100);
- }
-
- fuprintf(furi_log, "[fatfs_list] sd inserted\n");
-
- FuriRecordSubscriber* fb_record =
- furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL);
- if(fb_record == NULL) {
- fuprintf(furi_log, "[fatfs_list] cannot create fb record\n");
- furiac_exit(NULL);
- }
-
- PubSub* event_record = furi_open("input_events");
- if(event_record == NULL) {
- fuprintf(furi_log, "[fatfs_list] cannot open input_events record\n");
- furiac_exit(NULL);
- }
- PubSubItem* subscription = subscribe_pubsub(event_record, event_cb, event_queue);
- if(subscription == NULL) {
- fuprintf(furi_log, "[fatfs_list] cannot register input_events callback\n");
- furiac_exit(NULL);
- }
-
- bsp_result = BSP_SD_Init();
-
- if(bsp_result != 0) {
- fuprintf(furi_log, "[fatfs_list] SD card init error\n");
- furiac_exit(NULL);
- }
-
- result = f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 1);
-
- if(result != FR_OK) {
- fuprintf(furi_log, "[fatfs_list] SD card mount error\n");
- furiac_exit(NULL);
- }
-
- // ok, now we can work with sd card
-
- // send start event
- event.type = EventTypeStart;
- xQueueSend(event_queue, (void*)&event, 0);
-
- while(1) {
- if(xQueueReceive(event_queue, (void*)&event, portMAX_DELAY)) {
- // process buttons event
- if(event.type == EventTypeKey) {
- // button pressed
- if(event.value.input.state == true) {
- if(event.value.input.input == InputUp && line_position > 0) {
- line_position--;
- }
- if(event.value.input.input == InputDown) {
- line_position++;
- }
- }
- }
-
- line_current = 1;
-
- // open root dir
- result = f_opendir(&dir, "");
-
- while(1) {
- // read a directory item
- result = f_readdir(&dir, &fno);
-
- if(result != FR_OK) {
- // cannot read dir
- break;
- }
-
- if(fno.fname[0] == 0) {
- // Break on end of dir
- break;
- }
-
- // draw files on display
- if(line_current > line_position &&
- line_current <= (line_position + lines_on_display)) {
- if(fno.fattrib & AM_DIR) {
- snprintf(str_buffer, STR_BUFFER_SIZE, "DIR %s\n", fno.fname);
- } else {
- snprintf(str_buffer, STR_BUFFER_SIZE, "FIL %s\n", fno.fname);
- }
- fuprintf(furi_log, str_buffer);
- }
-
- line_current++;
- }
-
- result = f_closedir(&dir);
-
- furi_commit(fb_record);
- }
- }
-
- furiac_exit(NULL);
-}
diff --git a/applications/examples/input_dump.c b/applications/examples/input_dump.c
index caaeca0c..a1482d74 100644
--- a/applications/examples/input_dump.c
+++ b/applications/examples/input_dump.c
@@ -1,5 +1,6 @@
-#include "flipper_v2.h"
+#include <furi.h>
#include <stdio.h>
+#include <input/input.h>
typedef union {
unsigned int packed;
@@ -21,12 +22,10 @@ static void event_cb(const void* value, void* ctx) {
void application_input_dump(void* p) {
// open record
- ValueManager* state_record = furi_open("input_state");
- furi_check(state_record);
+ ValueManager* state_record = furi_record_open("input_state");
subscribe_pubsub(&state_record->pubsub, state_cb, NULL);
- PubSub* event_record = furi_open("input_events");
- furi_check(event_record);
+ PubSub* event_record = furi_record_open("input_events");
subscribe_pubsub(event_record, event_cb, NULL);
printf("Example app [input dump]\n");
diff --git a/applications/examples/ipc.c b/applications/examples/ipc.c
deleted file mode 100644
index a965db98..00000000
--- a/applications/examples/ipc.c
+++ /dev/null
@@ -1,155 +0,0 @@
-#include "flipper.h"
-#include <string.h>
-
-#define FB_WIDTH 10
-#define FB_HEIGHT 3
-#define FB_SIZE (FB_WIDTH * FB_HEIGHT)
-
-// context structure used for pass some object from app thread to callback
-typedef struct {
- SemaphoreHandle_t events; // queue to pass events from callback to app thread
- FuriRecordSubscriber* log; // app logger
-} IpcCtx;
-
-static void handle_fb_change(const void* fb, size_t fb_size, void* raw_ctx) {
- IpcCtx* ctx = (IpcCtx*)raw_ctx; // make right type
-
- fuprintf(ctx->log, "[cb] framebuffer updated\n");
-
- // send event to app thread
- xSemaphoreGive(ctx->events);
-
- // Attention! Please, do not make blocking operation like IO and waits inside callback
- // Remember that callback execute in calling thread/context
-}
-
-static void print_fb(char* fb, FuriRecordSubscriber* log) {
- if(fb == NULL) return;
-
- /* draw framebuffer like this:
- +==========+
- | |
- | |
- | |
- +==========+
- */
-
- char row_buffer[FB_WIDTH + 1];
- row_buffer[FB_WIDTH] = '\0';
-
- // FB layout is hardcoded here
- fuprintf(log, "+==========+\n");
- for(uint8_t i = 0; i < FB_HEIGHT; i++) {
- strncpy(row_buffer, &fb[FB_WIDTH * i], FB_WIDTH);
- fuprintf(log, "|%s|\n", row_buffer);
- }
- fuprintf(log, "+==========+\n");
-}
-
-void application_ipc_display(void* p) {
- // get logger
- FuriRecordSubscriber* log = get_default_log();
-
- // create ASCII "framebuffer"
- // FB_WIDTH x FB_HEIGHT char buffer
- char _framebuffer[FB_SIZE];
-
- // init framebuffer by spaces
- for(size_t i = 0; i < FB_SIZE; i++) {
- _framebuffer[i] = ' ';
- }
-
- // create record
- if(!furi_create_deprecated("test_fb", (void*)_framebuffer, FB_SIZE)) {
- fuprintf(log, "[display] cannot create fb record\n");
- furiac_exit(NULL);
- }
-
- StaticSemaphore_t event_descriptor;
- // create stack-based counting semaphore
- SemaphoreHandle_t events = xSemaphoreCreateCountingStatic(255, 0, &event_descriptor);
-
- if(events == NULL) {
- fuprintf(log, "[display] cannot create event semaphore\n");
- furiac_exit(NULL);
- }
-
- // save log and event queue in context structure
- IpcCtx ctx = {.events = events, .log = log};
-
- // subscribe to record. ctx will be passed to handle_fb_change
- FuriRecordSubscriber* fb_record =
- furi_open_deprecated("test_fb", false, false, handle_fb_change, NULL, &ctx);
-
- if(fb_record == NULL) {
- fuprintf(log, "[display] cannot open fb record\n");
- furiac_exit(NULL);
- }
-
-#ifdef HW_DISPLAY
- // on Flipper target -- open screen
-
- // draw border
-
-#else
- // on Local target -- print "blank screen"
- {
- void* fb = furi_take(fb_record);
- print_fb((char*)fb, log);
- furi_give(fb_record);
- }
-#endif
-
- while(1) {
- // wait for event
- if(xSemaphoreTake(events, portMAX_DELAY) == pdTRUE) {
- fuprintf(log, "[display] get fb update\n\n");
-
-#ifdef HW_DISPLAY
-// on Flipper target draw the screen
-#else
- // on local target just print
- {
- void* fb = furi_take(fb_record);
- print_fb((char*)fb, log);
- furi_give(fb_record);
- }
-#endif
- }
- }
-}
-
-// Widget application
-void application_ipc_widget(void* p) {
- FuriRecordSubscriber* log = get_default_log();
-
- // open record
- FuriRecordSubscriber* fb_record =
- furi_open_deprecated("test_fb", false, false, NULL, NULL, NULL);
-
- if(fb_record == NULL) {
- fuprintf(log, "[widget] cannot create fb record\n");
- furiac_exit(NULL);
- }
-
- uint8_t counter = 0;
-
- while(1) {
- delay(120);
-
- // write some ascii demo here: '#'' symbol run on overall screen
- char* fb = (char*)furi_take(fb_record);
-
- if(fb == NULL) furiac_exit(NULL);
-
- for(size_t i = 0; i < FB_SIZE; i++) {
- fb[i] = ' ';
- }
-
- fb[counter % FB_SIZE] = '#';
-
- furi_commit(fb_record);
-
- counter++;
- }
-} \ No newline at end of file
diff --git a/applications/examples/strobe.c b/applications/examples/strobe.c
index fad250e9..ea922196 100644
--- a/applications/examples/strobe.c
+++ b/applications/examples/strobe.c
@@ -1,4 +1,5 @@
-#include "flipper_v2.h"
+#include <furi.h>
+#include <input.h>
static void event_cb(const void* value, void* ctx) {
const InputEvent* event = value;
@@ -38,8 +39,7 @@ void application_strobe(void* p) {
ValueMutex delay_mutex;
init_mutex(&delay_mutex, &delay_time_holder, sizeof(delay_time_holder));
- PubSub* event_record = furi_open("input_events");
- furi_check(event_record);
+ PubSub* event_record = furi_record_open("input_events");
subscribe_pubsub(event_record, event_cb, &delay_mutex);
while(1) {
diff --git a/applications/examples/u8g2_example.c b/applications/examples/u8g2_example.c
index e77012d4..8f745a87 100644
--- a/applications/examples/u8g2_example.c
+++ b/applications/examples/u8g2_example.c
@@ -1,32 +1,14 @@
#include "u8g2/u8g2.h"
-#include "flipper.h"
+#include <furi.h>
void u8g2_example(void* p) {
- FuriRecordSubscriber* log = get_default_log();
-
// open record
- FuriRecordSubscriber* fb_record =
- furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL);
-
- if(fb_record == NULL) {
- fuprintf(log, "[widget] cannot create fb record\n");
- furiac_exit(NULL);
- }
-
- while(1) {
- u8g2_t* fb = furi_take(fb_record);
- if(fb != NULL) {
- u8g2_SetFont(fb, u8g2_font_6x10_mf);
- u8g2_SetDrawColor(fb, 1);
- u8g2_SetFontMode(fb, 1);
- u8g2_DrawStr(fb, 2, 12, "hello world!");
- }
- furi_commit(fb_record);
-
- if(fb != NULL) {
- furiac_exit(NULL);
- }
-
- delay(1);
- }
+ 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");
+
+ furiac_exit(NULL);
} \ No newline at end of file
diff --git a/applications/examples/u8g2_qrcode.c b/applications/examples/u8g2_qrcode.c
index 2799df33..92f5a359 100644
--- a/applications/examples/u8g2_qrcode.c
+++ b/applications/examples/u8g2_qrcode.c
@@ -1,6 +1,9 @@
#include "u8g2/u8g2.h"
#include "qrcode/qrcode.h"
-#include "flipper.h"
+#include <furi.h>
+
+/*
+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++) {
@@ -11,8 +14,6 @@ void u8g2_DrawPixelSize(u8g2_t* u8g2, uint8_t x, uint8_t y, uint8_t size) {
}
void u8g2_qrcode(void* p) {
- FuriRecordSubscriber* log = get_default_log();
-
// open record
FuriRecordSubscriber* fb_record =
furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL);
@@ -36,7 +37,7 @@ void u8g2_qrcode(void* p) {
qrcode_initText(&qrcode, qrcodeBytes, qr_version, qr_error_correction, "HELLO FLIPPER");
if(fb_record == NULL) {
- fuprintf(log, "[widget] cannot create fb record\n");
+ printf("[widget] cannot create fb record\n");
furiac_exit(NULL);
}
@@ -69,4 +70,5 @@ void u8g2_qrcode(void* p) {
delay(1);
}
-} \ No newline at end of file
+}
+*/ \ No newline at end of file
diff --git a/applications/examples/uart_write.c b/applications/examples/uart_write.c
index 217b1563..7b6697ed 100644
--- a/applications/examples/uart_write.c
+++ b/applications/examples/uart_write.c
@@ -1,7 +1,5 @@
-#include "flipper.h"
+#include <furi.h>
#include <string.h>
-#include "log.h"
-#include "flipper_v2.h"
void application_uart_write(void* p) {
// Red led for showing progress
@@ -11,12 +9,9 @@ void application_uart_write(void* p) {
gpio_init(led_record, GpioModeOutputOpenDrain);
- // get_default_log open "tty" record
- FuriRecordSubscriber* log = get_default_log();
-
// create buffer
const char test_string[] = "test\n";
- furi_write(log, test_string, strlen(test_string));
+ printf(test_string);
// for example, create counter and show its value
uint8_t counter = 0;
diff --git a/applications/examples/vibro.c b/applications/examples/vibro.c
index 51b9fae3..4189910d 100644
--- a/applications/examples/vibro.c
+++ b/applications/examples/vibro.c
@@ -1,4 +1,5 @@
-#include "flipper_v2.h"
+#include <furi.h>
+#include <input/input.h>
typedef struct {
GpioPin* led;
@@ -24,7 +25,7 @@ void application_vibro(void* p) {
gpio_write(ctx.vibro, false);
// subscribe on buttons
- PubSub* event_record = furi_open("input_events");
+ PubSub* event_record = furi_record_open("input_events");
furi_check(event_record);
subscribe_pubsub(event_record, button_handler, &ctx);
diff --git a/applications/floopper-bloopper b/applications/floopper-bloopper
-Subproject 25a2cc076c3162aad721e0d92009cfa7b9100c7
+Subproject 621044255a8be4d2c3f342e2b22178a342ccbfe
diff --git a/applications/gpio-tester/gpio-tester.c b/applications/gpio-tester/gpio-tester.c
index ab971e4c..695fbdf9 100644
--- a/applications/gpio-tester/gpio-tester.c
+++ b/applications/gpio-tester/gpio-tester.c
@@ -1,4 +1,6 @@
-#include "flipper_v2.h"
+#include <furi.h>
+#include <gui/gui.h>
+#include <input/input.h>
typedef struct {
const char* name;
@@ -47,7 +49,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
}
static void input_callback(InputEvent* input_event, void* ctx) {
- osMessageQueueId_t event_queue = (QueueHandle_t)ctx;
+ osMessageQueueId_t event_queue = ctx;
AppEvent event;
event.type = EventTypeKey;
@@ -74,11 +76,7 @@ void app_gpio_test(void* p) {
widget_input_callback_set(widget, input_callback, event_queue);
// Open GUI and register widget
- Gui* gui = (Gui*)furi_open("gui");
- if(gui == NULL) {
- printf("[gpio-tester] gui is not available\n");
- furiac_exit(NULL);
- }
+ Gui* gui = furi_record_open("gui");
gui_add_widget(gui, widget, GuiLayerFullscreen);
// configure pin
diff --git a/applications/gui/canvas.c b/applications/gui/canvas.c
index 7d4f8261..a8ea67eb 100644
--- a/applications/gui/canvas.c
+++ b/applications/gui/canvas.c
@@ -1,8 +1,7 @@
#include "canvas_i.h"
#include "icon_i.h"
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
struct Canvas {
u8g2_t fb;
diff --git a/applications/gui/canvas.h b/applications/gui/canvas.h
index 2ce6b309..7bc04066 100644
--- a/applications/gui/canvas.h
+++ b/applications/gui/canvas.h
@@ -5,6 +5,10 @@
#include <gui/icon.h>
#include <assets_icons_i.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum {
ColorWhite = 0x00,
ColorBlack = 0x01,
@@ -91,3 +95,7 @@ void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_
* Draw glyph
*/
void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/elements.h b/applications/gui/elements.h
index d2bec004..bbdbe0fa 100644
--- a/applications/gui/elements.h
+++ b/applications/gui/elements.h
@@ -3,6 +3,10 @@
#include <stdint.h>
#include "canvas.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Draw scrollbar on canvas.
* width 3px, height equal to canvas height
@@ -17,3 +21,7 @@ void elements_scrollbar(Canvas* canvas, uint8_t pos, uint8_t total);
* @param width, height - frame width and height
*/
void elements_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/gui.c b/applications/gui/gui.c
index fdce8eab..38584ea1 100644
--- a/applications/gui/gui.c
+++ b/applications/gui/gui.c
@@ -1,8 +1,7 @@
#include "gui.h"
#include "gui_i.h"
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
#include <m-array.h>
#include <stdio.h>
@@ -207,13 +206,9 @@ Gui* gui_alloc() {
void gui_task(void* p) {
Gui* gui = gui_alloc();
- // Create FURI record
- if(!furi_create("gui", gui)) {
- printf("[gui_task] cannot create the gui record\n");
- furiac_exit(NULL);
- }
- furiac_ready();
+ // Create FURI record
+ furi_record_create("gui", gui);
// Forever dispatch
while(1) {
diff --git a/applications/gui/gui.h b/applications/gui/gui.h
index d05de799..a314109d 100644
--- a/applications/gui/gui.h
+++ b/applications/gui/gui.h
@@ -3,6 +3,10 @@
#include "widget.h"
#include "canvas.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define GUI_DISPLAY_WIDTH 128
#define GUI_DISPLAY_HEIGHT 64
@@ -40,3 +44,7 @@ void gui_add_widget(Gui* gui, Widget* widget, GuiLayer layer);
* @remarks thread safe
*/
void gui_remove_widget(Gui* gui, Widget* widget);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/gui_event.c b/applications/gui/gui_event.c
index 57346fdf..eeeb0101 100644
--- a/applications/gui/gui_event.c
+++ b/applications/gui/gui_event.c
@@ -1,6 +1,6 @@
#include "gui_event.h"
-#include <flipper_v2.h>
+#include <furi.h>
#define GUI_EVENT_MQUEUE_SIZE 8
@@ -45,7 +45,7 @@ GuiEvent* gui_event_alloc() {
// osTimerStart(gui_event->timer, 1024 / 4);
// Input
- gui_event->input_event_record = furi_open("input_events");
+ gui_event->input_event_record = furi_record_open("input_events");
furi_check(gui_event->input_event_record != NULL);
subscribe_pubsub(gui_event->input_event_record, gui_event_input_events_callback, gui_event);
diff --git a/applications/gui/gui_event.h b/applications/gui/gui_event.h
index fc2f358f..d9846867 100644
--- a/applications/gui/gui_event.h
+++ b/applications/gui/gui_event.h
@@ -3,6 +3,10 @@
#include <stdint.h>
#include <input/input.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum {
GuiMessageTypeRedraw = 0x00,
GuiMessageTypeInput = 0x01,
@@ -23,3 +27,7 @@ void gui_event_free(GuiEvent* gui_event);
void gui_event_messsage_send(GuiEvent* gui_event, GuiMessage* message);
GuiMessage gui_event_message_next(GuiEvent* gui_event);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/icon.c b/applications/gui/icon.c
index 8f02cf6d..37c6eba0 100644
--- a/applications/gui/icon.c
+++ b/applications/gui/icon.c
@@ -1,8 +1,6 @@
#include "icon_i.h"
-#include <cmsis_os2.h>
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
Icon* icon_alloc(const IconData* data) {
Icon* icon = furi_alloc(sizeof(Icon));
diff --git a/applications/gui/icon.h b/applications/gui/icon.h
index 4df2ed36..72acabd5 100644
--- a/applications/gui/icon.h
+++ b/applications/gui/icon.h
@@ -3,6 +3,10 @@
#include <stdint.h>
#include <stdbool.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct IconData IconData;
typedef struct Icon Icon;
@@ -41,3 +45,7 @@ void icon_start_animation(Icon* icon);
* Stop icon animation
*/
void icon_stop_animation(Icon* icon);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/u8g2_periphery.c b/applications/gui/u8g2_periphery.c
index df6c9b2c..b6739977 100644
--- a/applications/gui/u8g2_periphery.c
+++ b/applications/gui/u8g2_periphery.c
@@ -1,5 +1,5 @@
#include "u8g2/u8g2.h"
-#include "flipper.h"
+#include <furi.h>
#include <main.h>
extern SPI_HandleTypeDef SPI_D;
@@ -34,7 +34,7 @@ uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, vo
// Function to define the logic level of the RESET line
case U8X8_MSG_GPIO_RESET:
#ifdef DEBUG
- fuprintf(log, "[u8g2] rst %d\n", arg_int);
+ printf("[u8g2] rst %d\n", arg_int);
#endif
// TODO change it to FuriRecord pin
@@ -44,7 +44,7 @@ uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, vo
default:
#ifdef DEBUG
- fufuprintf(log, "[u8g2] unknown io %d\n", msg);
+ printf("[u8g2] unknown io %d\n", msg);
#endif
return 0; //A message was received which is not implemented, return 0 to indicate an error
@@ -57,7 +57,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
switch(msg) {
case U8X8_MSG_BYTE_SEND:
#ifdef DEBUG
- fuprintf(log, "[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]);
+ printf("[u8g2] send %d bytes %02X\n", arg_int, ((uint8_t*)arg_ptr)[0]);
#endif
// TODO change it to FuriRecord SPI
@@ -66,7 +66,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
case U8X8_MSG_BYTE_SET_DC:
#ifdef DEBUG
- fuprintf(log, "[u8g2] dc %d\n", arg_int);
+ printf("[u8g2] dc %d\n", arg_int);
#endif
// TODO change it to FuriRecord pin
@@ -76,7 +76,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
case U8X8_MSG_BYTE_INIT:
#ifdef DEBUG
- fuprintf(log, "[u8g2] init\n");
+ printf("[u8g2] init\n");
#endif
// TODO change it to FuriRecord pin
@@ -85,7 +85,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
case U8X8_MSG_BYTE_START_TRANSFER:
#ifdef DEBUG
- fuprintf(log, "[u8g2] start\n");
+ printf("[u8g2] start\n");
#endif
// TODO: SPI manager
@@ -98,7 +98,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
case U8X8_MSG_BYTE_END_TRANSFER:
#ifdef DEBUG
- fuprintf(log, "[u8g2] end\n");
+ printf("[u8g2] end\n");
#endif
asm("nop");
@@ -112,7 +112,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
default:
#ifdef DEBUG
- fuprintf(log, "[u8g2] unknown xfer %d\n", msg);
+ printf("[u8g2] unknown xfer %d\n", msg);
#endif
return 0;
diff --git a/applications/gui/view.h b/applications/gui/view.h
index e22e0715..832a3ef9 100644
--- a/applications/gui/view.h
+++ b/applications/gui/view.h
@@ -3,6 +3,10 @@
#include <input/input.h>
#include "canvas.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Hides drawing widget */
#define VIEW_NONE 0xFFFFFFFF
/* Ignore navigation event */
@@ -127,3 +131,7 @@ void view_commit_model(View* view);
({ void __fn__ function_body __fn__; })(p); \
view_commit_model(view); \
}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/view_dispatcher.h b/applications/gui/view_dispatcher.h
index e87d4b70..27c4abb9 100644
--- a/applications/gui/view_dispatcher.h
+++ b/applications/gui/view_dispatcher.h
@@ -3,6 +3,10 @@
#include "view.h"
#include "gui.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* ViewDispatcher widget placement */
typedef enum {
ViewDispatcherTypeNone, /* Special layer for internal use only */
@@ -43,3 +47,7 @@ void view_dispatcher_attach_to_gui(
ViewDispatcher* view_dispatcher,
Gui* gui,
ViewDispatcherType type);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/gui/view_dispatcher_i.h b/applications/gui/view_dispatcher_i.h
index 57e20200..58f1fd5f 100644
--- a/applications/gui/view_dispatcher_i.h
+++ b/applications/gui/view_dispatcher_i.h
@@ -2,7 +2,7 @@
#include "view_dispatcher.h"
#include "view_i.h"
-#include <flipper_v2.h>
+#include <furi.h>
#include <m-dict.h>
DICT_DEF2(ViewDict, uint32_t, M_DEFAULT_OPLIST, View*, M_PTR_OPLIST)
diff --git a/applications/gui/view_i.h b/applications/gui/view_i.h
index 243fd9e8..572f37f6 100644
--- a/applications/gui/view_i.h
+++ b/applications/gui/view_i.h
@@ -2,7 +2,7 @@
#include "view.h"
#include "view_dispatcher_i.h"
-#include <flipper_v2.h>
+#include <furi.h>
typedef struct {
void* data;
diff --git a/applications/gui/widget.c b/applications/gui/widget.c
index e1470261..d4de1a65 100644
--- a/applications/gui/widget.c
+++ b/applications/gui/widget.c
@@ -1,8 +1,6 @@
#include "widget_i.h"
-#include <cmsis_os.h>
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
#include "gui.h"
#include "gui_i.h"
@@ -73,8 +71,6 @@ void widget_update(Widget* widget) {
void widget_gui_set(Widget* widget, Gui* gui) {
furi_assert(widget);
- furi_assert(gui);
-
widget->gui = gui;
}
diff --git a/applications/gui/widget.h b/applications/gui/widget.h
index 6cf1f9c4..e31bbc88 100644
--- a/applications/gui/widget.h
+++ b/applications/gui/widget.h
@@ -3,6 +3,10 @@
#include <input/input.h>
#include "canvas.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct Widget Widget;
/*
@@ -65,3 +69,7 @@ void widget_input_callback_set(Widget* widget, WidgetInputCallback callback, voi
* Rendering will happen later after GUI system process signal.
*/
void widget_update(Widget* widget);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/applications/ibutton/ibutton.cpp b/applications/ibutton/ibutton.cpp
index e0637f76..a19b6127 100644
--- a/applications/ibutton/ibutton.cpp
+++ b/applications/ibutton/ibutton.cpp
@@ -32,7 +32,7 @@ void AppiButton::run() {
printf("[ibutton] bye!\n");
// TODO remove all widgets create by app
widget_enabled_set(widget, false);
- furiac_exit(NULL);
+ osThreadExit();
}
if(event.value.input.state && event.value.input.input == InputLeft) {
diff --git a/applications/input/input.c b/applications/input/input.c
index cabe655d..8b522d02 100644
--- a/applications/input/input.c
+++ b/applications/input/input.c
@@ -1,6 +1,6 @@
#include <input/input.h>
#include <stdio.h>
-#include <flipper_v2.h>
+#include <furi.h>
#ifdef APP_NFC
void nfc_isr(void);
@@ -35,18 +35,10 @@ void input_task(void* p) {
furiac_exit(NULL);
}
- if(!furi_create("input_state", &input_state_record)) {
- printf("[input_task] cannot create the input_state record\n");
- furiac_exit(NULL);
- }
-
- if(!furi_create("input_events", &input_events_record)) {
- printf("[input_task] cannot create the input_events record\n");
- furiac_exit(NULL);
- }
+ furi_record_create("input_state", &input_state_record);
+ furi_record_create("input_events", &input_events_record);
// we ready to work
- furiac_ready();
initialized = true;
// Force state update
diff --git a/applications/irda/irda-decoder/irda-decoder.h b/applications/irda/irda-decoder/irda-decoder.h
index fd14ebf0..78f4415c 100644
--- a/applications/irda/irda-decoder/irda-decoder.h
+++ b/applications/irda/irda-decoder/irda-decoder.h
@@ -1,6 +1,5 @@
#pragma once
-#include "flipper.h"
-#include "flipper_v2.h"
+#include <furi.h>
#include "irda-decoder-nec.h"
#include "irda-decoder-types.h"
diff --git a/applications/irda/irda.c b/applications/irda/irda.c
index f079e0d4..522a7a50 100644
--- a/applications/irda/irda.c
+++ b/applications/irda/irda.c
@@ -1,5 +1,7 @@
-#include "flipper.h"
-#include "flipper_v2.h"
+#include <furi.h>
+#include <gui/gui.h>
+#include <input/input.h>
+
#include "irda_nec.h"
#include "irda_samsung.h"
#include "irda_protocols.h"
@@ -185,7 +187,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
}
static void input_callback(InputEvent* input_event, void* ctx) {
- osMessageQueueId_t event_queue = (QueueHandle_t)ctx;
+ osMessageQueueId_t event_queue = ctx;
AppEvent event;
event.type = EventTypeKey;
@@ -271,11 +273,7 @@ void irda(void* p) {
widget_input_callback_set(widget, input_callback, event_queue);
// Open GUI and register widget
- Gui* gui = (Gui*)furi_open("gui");
- if(gui == NULL) {
- printf("gui is not available\n");
- furiac_exit(NULL);
- }
+ Gui* gui = furi_record_open("gui");
gui_add_widget(gui, widget, GuiLayerFullscreen);
// Red LED
diff --git a/applications/irda/irda_nec.c b/applications/irda/irda_nec.c
index 9d465e17..8c22cea5 100644
--- a/applications/irda/irda_nec.c
+++ b/applications/irda/irda_nec.c
@@ -1,4 +1,4 @@
-#include "flipper.h"
+#include <furi.h>
#include "irda_nec.h"
#include "irda_protocols.h"
diff --git a/applications/irda/irda_nec.h b/applications/irda/irda_nec.h
index eb5d0975..5506b1e7 100644
--- a/applications/irda/irda_nec.h
+++ b/applications/irda/irda_nec.h
@@ -1,4 +1,4 @@
#pragma once
-#include "flipper.h"
+#include <furi.h>
void ir_nec_send(uint16_t addr, uint8_t data); \ No newline at end of file
diff --git a/applications/irda/irda_samsung.c b/applications/irda/irda_samsung.c
index 9227c77c..e608a7da 100644
--- a/applications/irda/irda_samsung.c
+++ b/applications/irda/irda_samsung.c
@@ -1,4 +1,4 @@
-#include "flipper.h"
+#include <furi.h>
#include "irda_samsung.h"
#include "irda_protocols.h"
diff --git a/applications/irda/irda_samsung.h b/applications/irda/irda_samsung.h
index 21bf4105..85f98abe 100644
--- a/applications/irda/irda_samsung.h
+++ b/applications/irda/irda_samsung.h
@@ -1,4 +1,4 @@
#pragma once
-#include "flipper.h"
+#include <furi.h>
void ir_samsung_send(uint16_t addr, uint16_t data); \ No newline at end of file
diff --git a/applications/lf-rfid/em4100.c b/applications/lf-rfid/em4100.c
index 43b0893d..bd8aa1c5 100644
--- a/applications/lf-rfid/em4100.c
+++ b/applications/lf-rfid/em4100.c
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
void prepare_data(uint32_t ID, uint32_t VENDOR, uint8_t* data) {
uint8_t value[10];
diff --git a/applications/lf-rfid/lf-rfid.c b/applications/lf-rfid/lf-rfid.c
index 4c2c25c0..5731eeba 100644
--- a/applications/lf-rfid/lf-rfid.c
+++ b/applications/lf-rfid/lf-rfid.c
@@ -1,4 +1,5 @@
-#include "flipper_v2.h"
+#include <furi.h>
+#include <gui/gui.h>
typedef enum { EventTypeTick, EventTypeKey, EventTypeRx } EventType;
@@ -45,7 +46,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
}
static void input_callback(InputEvent* input_event, void* ctx) {
- osMessageQueueId_t event_queue = (QueueHandle_t)ctx;
+ osMessageQueueId_t event_queue = ctx;
AppEvent event;
event.type = EventTypeKey;
@@ -67,7 +68,7 @@ void comparator_trigger_callback(void* hcomp, void* comp_ctx) {
// gpio_write(&debug_0, true);
- osMessageQueueId_t event_queue = (QueueHandle_t)comp_ctx;
+ osMessageQueueId_t event_queue = comp_ctx;
AppEvent event;
event.type = EventTypeRx;
@@ -202,11 +203,7 @@ void lf_rfid_workaround(void* p) {
widget_input_callback_set(widget, input_callback, event_queue);
// Open GUI and register widget
- Gui* gui = (Gui*)furi_open("gui");
- if(gui == NULL) {
- printf("gui is not available\n");
- furiac_exit(NULL);
- }
+ Gui* gui = furi_record_open("gui");
gui_add_widget(gui, widget, GuiLayerFullscreen);
AppEvent event;
diff --git a/applications/menu/menu.c b/applications/menu/menu.c
index 67c00c0a..4a0ae266 100644
--- a/applications/menu/menu.c
+++ b/applications/menu/menu.c
@@ -1,9 +1,8 @@
#include "menu.h"
-#include <cmsis_os.h>
#include <stdio.h>
#include <stdbool.h>
-#include <flipper_v2.h>
+#include <furi.h>
#include <gui/gui.h>
#include <gui/elements.h>
@@ -42,8 +41,7 @@ ValueMutex* menu_init() {
menu->widget = widget_alloc();
// Open GUI and register fullscreen widget
- Gui* gui = furi_open("gui");
- furi_check(gui);
+ Gui* gui = furi_record_open("gui");
gui_add_widget(gui, menu->widget, GuiLayerFullscreen);
widget_enabled_set(menu->widget, false);
@@ -237,12 +235,7 @@ void menu_task(void* p) {
release_mutex(menu_mutex, menu);
}
- if(!furi_create("menu", menu_mutex)) {
- printf("[menu_task] cannot create the menu record\n");
- furiac_exit(NULL);
- }
-
- furiac_ready();
+ furi_record_create("menu", menu_mutex);
while(1) {
MenuMessage m = menu_event_next(menu_event);
diff --git a/applications/menu/menu_event.c b/applications/menu/menu_event.c
index e5053af2..eea02905 100644
--- a/applications/menu/menu_event.c
+++ b/applications/menu/menu_event.c
@@ -1,11 +1,9 @@
#include "menu_event.h"
-#include <cmsis_os.h>
#include <string.h>
#include <stdlib.h>
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
#define MENU_MESSAGE_MQUEUE_SIZE 8
diff --git a/applications/menu/menu_item.c b/applications/menu/menu_item.c
index 8c8cb273..8c1a39a1 100644
--- a/applications/menu/menu_item.c
+++ b/applications/menu/menu_item.c
@@ -1,8 +1,7 @@
#include "menu_item.h"
#include <stdlib.h>
#include <string.h>
-#include <flipper.h>
-#include <flipper_v2.h>
+#include <furi.h>
struct MenuItem {
MenuItemType type;
diff --git a/applications/music-player/music-player.c b/applications/music-player/music-player.c
index d6e38e12..3e8b4406 100644
--- a/applications/music-player/music-player.c
+++ b/applications/music-player/music-player.c
@@ -1,4 +1,6 @@
-#include "flipper_v2.h"
+#include <furi.h>
+#include <gui/gui.h>
+#include <input/input.h>
// TODO float note freq
typedef enum {
@@ -302,7 +304,7 @@ static void render_callback(Canvas* canvas, void* ctx) {
}
static void input_callback(InputEvent* input_event, void* ctx) {
- osMessageQueueId_t event_queue = (QueueHandle_t)ctx;
+ osMessageQueueId_t event_queue = ctx;
MusicDemoEvent event;
event.type = EventTypeKey;
@@ -376,15 +378,11 @@ void music_player(void* p) {
widget_input_callback_set(widget, input_callback, event_queue);
// Open GUI and register widget
- Gui* gui = (Gui*)furi_open("gui");
- if(gui == NULL) {
- printf("gui is not available\n");
- furiac_exit(NULL);
- }
+ Gui* gui = furi_record_open("gui");
gui_add_widget(gui, widget, GuiLayerFullscreen);
// open input record
- PubSub* input_events_record = furi_open("input_events");
+ PubSub* input_events_record = furi_record_open("input_events");
// prepare "do nothing" event
InputEvent input_event = {InputRight, true};
diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c
index 854572d7..98abc2ac 100644
--- a/applications/nfc/nfc.c
+++ b/applications/nfc/nfc.c
@@ -16,8 +16,7 @@ Nfc* nfc_alloc() {
nfc->worker = nfc_worker_alloc(nfc->message_queue);
nfc->icon = assets_icons_get(A_NFC_14);
- nfc->menu_vm = furi_open("menu");
- furi_check(nfc->menu_vm);
+ nfc->menu_vm = furi_record_open("menu");
nfc->menu = menu_item_alloc_menu("NFC", nfc->icon);
menu_item_subitem_add(
@@ -102,18 +101,13 @@ void nfc_start(Nfc* nfc, NfcView view_id, NfcWorkerState worker_state) {
void nfc_task(void* p) {
Nfc* nfc = nfc_alloc();
- Gui* gui = furi_open("gui");
+ Gui* gui = furi_record_open("gui");
view_dispatcher_attach_to_gui(nfc->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
with_value_mutex(
nfc->menu_vm, (Menu * menu) { menu_item_add(menu, nfc->menu); });
- if(!furi_create("nfc", nfc)) {
- printf("[nfc_task] cannot create nfc record\n");
- furiac_exit(NULL);
- }
-
- furiac_ready();
+ furi_record_create("nfc", nfc);
NfcMessage message;
while(1) {
diff --git a/applications/nfc/nfc_i.h b/applications/nfc/nfc_i.h
index d86d62b9..1bd985e7 100644
--- a/applications/nfc/nfc_i.h
+++ b/applications/nfc/nfc_i.h
@@ -5,7 +5,7 @@
#include "nfc_views.h"
#include "nfc_worker.h"
-#include <flipper_v2.h>
+#include <furi.h>
#include <gui/gui.h>
#include <gui/view.h>
diff --git a/applications/nfc/nfc_views.h b/applications/nfc/nfc_views.h
index 9f592d9b..70e3fb15 100644
--- a/applications/nfc/nfc_views.h
+++ b/applications/nfc/nfc_views.h
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <gui/canvas.h>
-#include <flipper_v2.h>
+#include <furi.h>
#include "nfc_types.h"
diff --git a/applications/nfc/nfc_worker_i.h b/applications/nfc/nfc_worker_i.h
index c118e1d8..75939879 100644
--- a/applications/nfc/nfc_worker_i.h
+++ b/applications/nfc/nfc_worker_i.h
@@ -3,8 +3,7 @@
#include "nfc_types.h"
#include "nfc_worker.h"
-#include <flipper_v2.h>
-#include <cmsis_os2.h>
+#include <furi.h>
#include <stdbool.h>
#include <rfal_analogConfig.h>
diff --git a/applications/power/power.c b/applications/power/power.c
index acb46c8c..9252d85d 100644
--- a/applications/power/power.c
+++ b/applications/power/power.c
@@ -1,7 +1,7 @@
#include "power.h"
#include "power_views.h"
-#include <flipper_v2.h>
+#include <furi.h>
#include <menu/menu.h>
#include <menu/menu_item.h>
@@ -12,8 +12,8 @@
#include <gui/view_dispatcher.h>
#include <assets_icons.h>
-#include <api-hal-power.h>
#include <cli/cli.h>
+#include <stm32wbxx.h>
struct Power {
ViewDispatcher* view_dispatcher;
@@ -47,6 +47,10 @@ void power_draw_battery_callback(Canvas* canvas, void* context) {
});
}
+uint32_t power_info_back_callback(void* context) {
+ return VIEW_NONE;
+}
+
void power_menu_off_callback(void* context) {
api_hal_power_off();
}
@@ -71,10 +75,9 @@ void power_menu_info_callback(void* context) {
Power* power_alloc() {
Power* power = furi_alloc(sizeof(Power));
- power->menu_vm = furi_open("menu");
- furi_check(power->menu_vm);
+ power->menu_vm = furi_record_open("menu");
- power->cli = furi_open("cli");
+ power->cli = furi_record_open("cli");
power->menu = menu_item_alloc_menu("Power", NULL);
menu_item_subitem_add(
@@ -163,7 +166,7 @@ void power_task(void* p) {
cli_add_command(power->cli, "power_otg_off", power_cli_otg_off, power);
}
- Gui* gui = furi_open("gui");
+ Gui* gui = furi_record_open("gui");
gui_add_widget(gui, power->usb_widget, GuiLayerStatusBarLeft);
gui_add_widget(gui, power->battery_widget, GuiLayerStatusBarRight);
view_dispatcher_attach_to_gui(power->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
@@ -171,14 +174,9 @@ void power_task(void* p) {
with_value_mutex(
power->menu_vm, (Menu * menu) { menu_item_add(menu, power->menu); });
- if(!furi_create("power", power)) {
- printf("[power_task] unable to create power record\n");
- furiac_exit(NULL);
- }
-
api_hal_power_init();
- furiac_ready();
+ furi_record_create("power", power);
while(1) {
with_view_model(
diff --git a/applications/power/power_views.h b/applications/power/power_views.h
index 97931601..3858b70f 100644
--- a/applications/power/power_views.h
+++ b/applications/power/power_views.h
@@ -2,8 +2,8 @@
#include <stdint.h>
#include <stdbool.h>
+#include <furi.h>
#include <gui/canvas.h>
-#include <flipper_v2.h>
#include <gui/view.h>
typedef enum { PowerViewInfo } PowerView;
@@ -24,8 +24,4 @@ typedef struct {
uint8_t charge;
} PowerInfoModel;
-static uint32_t power_info_back_callback(void* context) {
- return VIEW_NONE;
-}
-
void power_info_draw_callback(Canvas* canvas, void* context);
diff --git a/applications/sd-card-test/sd-card-test.cpp b/applications/sd-card-test/sd-card-test.cpp
index 5431a392..28dd5abb 100644
--- a/applications/sd-card-test/sd-card-test.cpp
+++ b/applications/sd-card-test/sd-card-test.cpp
@@ -104,23 +104,21 @@ void SdTest::run() {
app_ready();
- fs_api = static_cast<FS_Api*>(furi_open("sdcard"));
+ fs_api = static_cast<FS_Api*>(furi_record_open("sdcard"));
if(fs_api == NULL) {
set_error({"cannot get sdcard api"});
exit();
}
- Cli* cli = static_cast<Cli*>(furi_open("cli"));
+ Cli* cli = static_cast<Cli*>(furi_record_open("cli"));
- if(cli != NULL) {
- // read_benchmark and write_benchmark signatures are same. so we must use tags
- auto cli_read_cb = cbc::obtain_connector<0>(this, &SdTest::cli_read_benchmark);
- cli_add_command(cli, "sd_read_test", cli_read_cb, this);
+ // read_benchmark and write_benchmark signatures are same. so we must use tags
+ auto cli_read_cb = cbc::obtain_connector<0>(this, &SdTest::cli_read_benchmark);
+ cli_add_command(cli, "sd_read_test", cli_read_cb, this);
- auto cli_write_cb = cbc::obtain_connector<1>(this, &SdTest::cli_write_benchmark);
- cli_add_command(cli, "sd_write_test", cli_write_cb, this);
- }
+ auto cli_write_cb = cbc::obtain_connector<1>(this, &SdTest::cli_write_benchmark);
+ cli_add_command(cli, "sd_write_test", cli_write_cb, this);
detect_sd_card();
get_sd_card_info();
@@ -893,6 +891,7 @@ template <class T> void SdTest::set_text(std::initializer_list<T> list) {
printf("------------------------\n");
release_state();
+ update_gui();
}
// render app
diff --git a/applications/sd-filesystem/sd-filesystem.c b/applications/sd-filesystem/sd-filesystem.c
index cd48ce93..bafa12ee 100644
--- a/applications/sd-filesystem/sd-filesystem.c
+++ b/applications/sd-filesystem/sd-filesystem.c
@@ -480,22 +480,19 @@ void sd_filesystem(void* p) {
SdApp* sd_app = sd_app_alloc();
FS_Api* fs_api = fs_api_alloc();
- Gui* gui = furi_open("gui");
+ Gui* gui = furi_record_open("gui");
+ Cli* cli = furi_record_open("cli");
+ ValueMutex* menu_vm = furi_record_open("menu");
+
gui_add_widget(gui, sd_app->widget, GuiLayerFullscreen);
gui_add_widget(gui, sd_app->icon.widget, GuiLayerStatusBarLeft);
- Cli* cli = furi_open("cli");
-
- if(cli != NULL) {
- cli_add_command(cli, "sd_status", cli_sd_status, sd_app);
- cli_add_command(cli, "sd_format", cli_sd_format, sd_app);
- cli_add_command(cli, "sd_info", cli_sd_info, sd_app);
- }
+ cli_add_command(cli, "sd_status", cli_sd_status, sd_app);
+ cli_add_command(cli, "sd_format", cli_sd_format, sd_app);
+ cli_add_command(cli, "sd_info", cli_sd_info, sd_app);
// add api record
- if(!furi_create("sdcard", fs_api)) {
- furiac_exit(NULL);
- }
+ furi_record_create("sdcard", fs_api);
// init menu
// TODO menu icon
@@ -510,15 +507,15 @@ void sd_filesystem(void* p) {
menu_item, menu_item_alloc_function("Eject", NULL, app_sd_eject_callback, sd_app));
// add item to menu
- ValueMutex* menu_vm = furi_open("menu");
furi_check(menu_vm);
with_value_mutex(
menu_vm, (Menu * menu) { menu_item_add(menu, menu_item); });
- furiac_ready();
-
printf("[sd_filesystem] start\n");
+ // add api record
+ furi_record_create("sdcard", fs_api);
+
// sd card cycle
bool sd_was_present = true;
diff --git a/applications/sd-filesystem/sd-filesystem.h b/applications/sd-filesystem/sd-filesystem.h
index 171de48c..0ca0c321 100644
--- a/applications/sd-filesystem/sd-filesystem.h
+++ b/applications/sd-filesystem/sd-filesystem.h
@@ -1,6 +1,8 @@
#pragma once
-#include "flipper.h"
-#include "flipper_v2.h"
+
+#include <furi.h>
+#include <gui/gui.h>
+#include <input/input.h>
#define SD_FS_MAX_FILES _FS_LOCK
#define SD_STATE_LINES_COUNT 6
diff --git a/applications/template/template.c.example b/applications/template/template.c.example
index fffcb07c..8cbe3255 100644
--- a/applications/template/template.c.example
+++ b/applications/template/template.c.example
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
typedef enum {
EventTypeTick,
@@ -54,7 +54,7 @@ void template_app(void* p) {
widget_input_callback_set(widget, input_callback, event_queue);
// Open GUI and register widget
- Gui* gui = (Gui*)furi_open("gui");
+ Gui* gui = furi_record_open("gui");
if(gui == NULL) {
printf("gui is not available\n");
furiac_exit(NULL);
diff --git a/applications/tests/furi_event_test.c b/applications/tests/furi_event_test.c
index 2edb0af8..90335098 100644
--- a/applications/tests/furi_event_test.c
+++ b/applications/tests/furi_event_test.c
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
#include "minunit.h"
static void furi_concurent_app(void* p) {
@@ -10,7 +10,9 @@ static void furi_concurent_app(void* p) {
}
void test_furi_event() {
- Event event;
+ mu_assert(false, "please reimplement or delete test");
+
+ /*Event event;
mu_check(init_event(&event));
@@ -27,5 +29,5 @@ void test_furi_event() {
// The event should not be signalled once it's processed
mu_check(!wait_event_with_timeout(&event, 100));
- mu_check(delete_event(&event));
+ mu_check(delete_event(&event));*/
}
diff --git a/applications/tests/furi_pubsub_test.c b/applications/tests/furi_pubsub_test.c
index 5d3a0a9e..d52b6bd3 100644
--- a/applications/tests/furi_pubsub_test.c
+++ b/applications/tests/furi_pubsub_test.c
@@ -1,8 +1,6 @@
#include <stdio.h>
#include <string.h>
-#include "flipper_v2.h"
-#include "log.h"
-
+#include <furi.h>
#include "minunit.h"
const uint32_t context_value = 0xdeadbeef;
diff --git a/applications/tests/furi_record_test.c b/applications/tests/furi_record_test.c
index 4481602c..0b4d7a46 100644
--- a/applications/tests/furi_record_test.c
+++ b/applications/tests/furi_record_test.c
@@ -1,16 +1,14 @@
#include <stdio.h>
#include <string.h>
-#include "flipper.h"
-#include "flipper_v2.h"
-#include "log.h"
+#include <furi.h>
#include "minunit.h"
void test_furi_create_open() {
// 1. Create record
uint8_t test_data = 0;
- mu_check(furi_create("test/holding", (void*)&test_data));
+ furi_record_create("test/holding", (void*)&test_data);
// 2. Open it
- void* record = furi_open("test/holding");
+ void* record = furi_record_open("test/holding");
mu_assert_pointers_eq(record, &test_data);
}
diff --git a/applications/tests/furi_value_expanders_test.c b/applications/tests/furi_value_expanders_test.c
index 5d9a965c..361c52cb 100644
--- a/applications/tests/furi_value_expanders_test.c
+++ b/applications/tests/furi_value_expanders_test.c
@@ -1,4 +1,4 @@
-#include "flipper_v2.h"
+#include <furi.h>
#include "minunit.h"
#include <stdint.h>
diff --git a/applications/tests/furi_valuemutex_test.c b/applications/tests/furi_valuemutex_test.c
index 88bd6673..e9258a61 100644
--- a/applications/tests/furi_valuemutex_test.c
+++ b/applications/tests/furi_valuemutex_test.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <string.h>
-#include "flipper_v2.h"
-#include "log.h"
+#include <furi.h>
#include "minunit.h"
@@ -88,6 +87,8 @@ void furi_concurent_app(void* p) {
}
void test_furi_concurrent_access() {
+ mu_assert(false, "please reimplement or delete test");
+ /*
// 1. Create holding record
ConcurrentValue value = {.a = 0, .b = 0};
ValueMutex mutex;
@@ -123,4 +124,5 @@ void test_furi_concurrent_access() {
mu_assert_int_eq(value.a, value.b);
mu_check(delete_mutex(&mutex));
+ */
} \ No newline at end of file
diff --git a/applications/tests/furiac_test.c b/applications/tests/furiac_test.c
index 05eaaeae..c19e629a 100644
--- a/applications/tests/furiac_test.c
+++ b/applications/tests/furiac_test.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <string.h>
-#include "flipper.h"
-#include "log.h"
+#include <furi.h>
/*
Test: creating and killing task
@@ -24,6 +23,8 @@ void create_kill_app(void* p) {
}
bool test_furi_ac_create_kill() {
+ mu_assert(false, "please reimplement or delete test");
+ /*
uint8_t counter = 0;
uint8_t value_a = counter;
@@ -56,6 +57,7 @@ bool test_furi_ac_create_kill() {
}
return true;
+ */
}
/*
diff --git a/applications/tests/minunit_test.c b/applications/tests/minunit_test.c
index 9d6a93f4..0fa28313 100644
--- a/applications/tests/minunit_test.c
+++ b/applications/tests/minunit_test.c
@@ -1,6 +1,5 @@
#include <stdio.h>
-#include "flipper.h"
-#include "log.h"
+#include <furi.h>
#include "minunit_vars.h"
#include "minunit.h"
diff --git a/applications/tests/test_index.c b/applications/tests/test_index.c
index 133259fb..51bff386 100644
--- a/applications/tests/test_index.c
+++ b/applications/tests/test_index.c
@@ -1,7 +1,5 @@
#include <stdio.h>
-#include "flipper.h"
-#include "flipper_v2.h"
-#include "log.h"
+#include <furi.h>
// #include "flipper-core.h" TODO: Rust build disabled