Applications: unified entry point naming scheme, drop dead code, cleanup. (#628)

This commit is contained in:
あく 2021-08-07 19:54:42 +03:00 committed by GitHub
parent eb83395cc3
commit 7907cb232b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 442 additions and 1175 deletions

View File

@ -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;

View File

@ -1,103 +1,106 @@
#include "applications.h"
#include <assets_icons.h>
// 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
};

View File

@ -1,7 +1,7 @@
#pragma once
#include <furi.h>
#include <assets_icons.h>
#include <gui/icon.h>
typedef struct {
const FuriThreadCallback app;

View File

@ -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)

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -1,92 +0,0 @@
#include <furi.h>
#include <input/input.h>
#include <gui/gui.h>
#include <api-hal.h>
#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;
}

View File

@ -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

View File

@ -0,0 +1,225 @@
#include <furi.h>
#include <gui/gui.h>
#include <input/input.h>
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;
}

View File

@ -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");

View File

@ -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);

View File

@ -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)) {

View File

@ -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);

View File

@ -1,100 +0,0 @@
#include <furi.h>
#include <api-hal.h>
#include <stdio.h>
#include <gui/gui.h>
#include <input/input.h>
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;
}

View File

@ -1,189 +0,0 @@
#include <furi.h>
#include <gui/gui.h>
#include <input/input.h>
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;
}

View File

@ -1,14 +0,0 @@
#include "u8g2/u8g2.h"
#include <furi.h>
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;
}

View File

@ -1,76 +0,0 @@
#include "u8g2/u8g2.h"
#include "qrcode/qrcode.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++) {
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;
}
*/

View File

@ -1,35 +0,0 @@
#include <furi.h>
#include <api-hal.h>
#include <string.h>
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;
}

View File

@ -1,103 +0,0 @@
#include <furi.h>
#include <gui/gui.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
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;
}

View File

@ -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);

View File

@ -1,239 +0,0 @@
#include <furi.h>
#include <gui/gui.h>
#include <gui/view_port.h>
#include <gui/view.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/dialog.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/submenu.h>
#include <gui/modules/text_input.h>
#include <gui/modules/byte_input.h>
#include <gui/modules/popup.h>
#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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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;

View File

@ -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));
}

View File

@ -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)) {

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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");

View File

@ -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);