diff --git a/components/board_2432s024/board_2432s024_display.h b/components/board_2432s024/board_2432s024_display.h index 11f5dd2b..fb995bf6 100644 --- a/components/board_2432s024/board_2432s024_display.h +++ b/components/board_2432s024/board_2432s024_display.h @@ -1,6 +1,6 @@ #pragma once -#include "nb_display.h" +#include "display.h" #ifdef __cplusplus extern "C" { diff --git a/components/board_2432s024/board_2432s024_touch.h b/components/board_2432s024/board_2432s024_touch.h index a4df3c3c..7c804b4a 100644 --- a/components/board_2432s024/board_2432s024_touch.h +++ b/components/board_2432s024/board_2432s024_touch.h @@ -1,6 +1,6 @@ #pragma once -#include "nb_touch.h" +#include "touch.h" #ifdef __cplusplus extern "C" { diff --git a/components/nanobake/src/nb_app.c b/components/nanobake/src/app.c similarity index 95% rename from components/nanobake/src/nb_app.c rename to components/nanobake/src/app.c index 91a2f8e2..98692b12 100644 --- a/components/nanobake/src/nb_app.c +++ b/components/nanobake/src/app.c @@ -1,5 +1,5 @@ +#include "app_i.h" #include "check.h" -#include "nb_app_i.h" const char* prv_type_service = "service"; const char* prv_type_system = "system"; diff --git a/components/nanobake/src/nb_app.h b/components/nanobake/src/app.h similarity index 100% rename from components/nanobake/src/nb_app.h rename to components/nanobake/src/app.h diff --git a/components/nanobake/src/nb_app_i.h b/components/nanobake/src/app_i.h similarity index 52% rename from components/nanobake/src/nb_app_i.h rename to components/nanobake/src/app_i.h index afa3106f..7053643a 100644 --- a/components/nanobake/src/nb_app_i.h +++ b/components/nanobake/src/app_i.h @@ -1,12 +1,12 @@ #pragma once -#include "nb_app.h" +#include "app.h" #ifdef __cplusplus extern "C" { #endif -extern const char* nb_app_type_to_string(AppType type); +const char* nb_app_type_to_string(AppType type); #ifdef __cplusplus } diff --git a/components/nanobake/src/applications/applications.c b/components/nanobake/src/applications/applications.c new file mode 100644 index 00000000..3ff2392f --- /dev/null +++ b/components/nanobake/src/applications/applications.c @@ -0,0 +1,28 @@ +#include "applications_i.h" + +// System services +extern const App desktop_app; +extern const App gui_app; +extern const App loader_app; + +// System apps +extern const App system_info_app; + +const App* const NANOBAKE_SERVICES[] = { + &desktop_app, + &gui_app, + &loader_app +}; + +const size_t NANOBAKE_SERVICES_COUNT = sizeof(NANOBAKE_SERVICES) / sizeof(App*); + +const App* const NANOBAKE_SYSTEM_APPS[] = { + &system_info_app +}; + +const size_t NANOBAKE_SYSTEM_APPS_COUNT = sizeof(NANOBAKE_SYSTEM_APPS) / sizeof(App*); + +const OnSystemStart NANOBAKE_ON_SYSTEM_START[] = { +}; + +const size_t NANOBAKE_ON_SYSTEM_START_COUNT = sizeof(NANOBAKE_ON_SYSTEM_START) / sizeof(OnSystemStart); diff --git a/components/nanobake/src/applications/applications_i.h b/components/nanobake/src/applications/applications_i.h new file mode 100644 index 00000000..b97b38cf --- /dev/null +++ b/components/nanobake/src/applications/applications_i.h @@ -0,0 +1,23 @@ +#pragma once + +#include "app.h" +#include "devices.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void (*OnSystemStart)(Devices* hardware); + +extern const App* const NANOBAKE_SERVICES[]; +extern const size_t NANOBAKE_SERVICES_COUNT; + +extern const App* const NANOBAKE_SYSTEM_APPS[]; +extern const size_t NANOBAKE_SYSTEM_APPS_COUNT; + +extern const OnSystemStart NANOBAKE_ON_SYSTEM_START[]; +extern const size_t NANOBAKE_ON_SYSTEM_START_COUNT; + +#ifdef __cplusplus +} +#endif diff --git a/components/nanobake/src/applications/nb_applications.c b/components/nanobake/src/applications/nb_applications.c deleted file mode 100644 index 1e2b77ac..00000000 --- a/components/nanobake/src/applications/nb_applications.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "nb_applications.h" - -// System services -extern const App desktop_app; -extern const App gui_app; -extern const App loader_app; - -// System apps -extern const App system_info_app; - -const App* const FLIPPER_SERVICES[] = { - &desktop_app, - &gui_app, - &loader_app -}; - -const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(App*); - -const App* const FLIPPER_SYSTEM_APPS[] = { - &system_info_app -}; - -const size_t FLIPPER_SYSTEM_APPS_COUNT = sizeof(FLIPPER_SYSTEM_APPS) / sizeof(App*); - -const OnSystemStart FLIPPER_ON_SYSTEM_START[] = { -}; - -const size_t FLIPPER_ON_SYSTEM_START_COUNT = sizeof(FLIPPER_ON_SYSTEM_START) / sizeof(OnSystemStart); diff --git a/components/nanobake/src/applications/nb_applications.h b/components/nanobake/src/applications/nb_applications.h deleted file mode 100644 index 7d50a20c..00000000 --- a/components/nanobake/src/applications/nb_applications.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include "devices.h" -#include "nb_app.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void (*OnSystemStart)(Devices* hardware); - -extern const App* const FLIPPER_SERVICES[]; -extern const size_t FLIPPER_SERVICES_COUNT; - -extern const App* const FLIPPER_SYSTEM_APPS[]; -extern const size_t FLIPPER_SYSTEM_APPS_COUNT; - -extern const OnSystemStart FLIPPER_ON_SYSTEM_START[]; -extern const size_t FLIPPER_ON_SYSTEM_START_COUNT; - -#ifdef __cplusplus -} -#endif diff --git a/components/nanobake/src/applications/services/desktop/desktop.h b/components/nanobake/src/applications/services/desktop/desktop.h index b31e890b..aca20fe2 100644 --- a/components/nanobake/src/applications/services/desktop/desktop.h +++ b/components/nanobake/src/applications/services/desktop/desktop.h @@ -1,6 +1,6 @@ #pragma once -#include "nb_app.h" +#include "app.h" #ifdef __cplusplus extern "C" { diff --git a/components/nanobake/src/applications/services/gui/gui.h b/components/nanobake/src/applications/services/gui/gui.h index 6c026a33..e99864ca 100644 --- a/components/nanobake/src/applications/services/gui/gui.h +++ b/components/nanobake/src/applications/services/gui/gui.h @@ -1,7 +1,7 @@ #pragma once +#include "app.h" #include "lvgl.h" -#include "nb_app.h" #include "view_port.h" #ifdef __cplusplus diff --git a/components/nanobake/src/applications/services/loader/loader.h b/components/nanobake/src/applications/services/loader/loader.h index 06f916f4..3f7dea52 100644 --- a/components/nanobake/src/applications/services/loader/loader.h +++ b/components/nanobake/src/applications/services/loader/loader.h @@ -1,6 +1,6 @@ #pragma once -#include "nb_app.h" +#include "app.h" #ifdef __cplusplus extern "C" { diff --git a/components/nanobake/src/applications/system/system_info/system_info.h b/components/nanobake/src/applications/system/system_info/system_info.h index f83259c7..ac14272c 100644 --- a/components/nanobake/src/applications/system/system_info/system_info.h +++ b/components/nanobake/src/applications/system/system_info/system_info.h @@ -1,6 +1,6 @@ #pragma once -#include "nb_app.h" +#include "app.h" #ifdef __cplusplus extern "C" { diff --git a/components/nanobake/src/devices.c b/components/nanobake/src/devices.c index d1555de2..20623438 100644 --- a/components/nanobake/src/devices.c +++ b/components/nanobake/src/devices.c @@ -1,12 +1,11 @@ #include "check.h" +#include "devices_i.h" #include "esp_check.h" #include "esp_err.h" -#include "nb_hardware_i.h" #define TAG "hardware" -Devices nb_hardware_create(Config _Nonnull* config) { - +Devices nb_devices_create(Config _Nonnull* config) { furi_check(config->display_driver != NULL, "no display driver configured"); DisplayDriver display_driver = config->display_driver(); ESP_LOGI(TAG, "display with driver %s", display_driver.name); diff --git a/components/nanobake/src/devices.h b/components/nanobake/src/devices.h index 96e6681c..798a941d 100644 --- a/components/nanobake/src/devices.h +++ b/components/nanobake/src/devices.h @@ -1,7 +1,7 @@ #pragma once -#include "nb_display.h" -#include "nb_touch.h" +#include "display.h" +#include "touch.h" #ifdef __cplusplus extern "C" { diff --git a/components/nanobake/src/devices_i.h b/components/nanobake/src/devices_i.h new file mode 100644 index 00000000..634d8228 --- /dev/null +++ b/components/nanobake/src/devices_i.h @@ -0,0 +1,13 @@ +#pragma once + +#include "nanobake.h" + +#ifdef __cplusplus +extern "C" { +#endif + +Devices nb_devices_create(Config _Nonnull* config); + +#ifdef __cplusplus +} +#endif diff --git a/components/nanobake/src/nb_display.c b/components/nanobake/src/display.c similarity index 96% rename from components/nanobake/src/nb_display.c rename to components/nanobake/src/display.c index c5d2c4e5..b7f6e469 100644 --- a/components/nanobake/src/nb_display.c +++ b/components/nanobake/src/display.c @@ -1,5 +1,5 @@ -#include "nb_display.h" #include "check.h" +#include "display.h" DisplayDevice _Nonnull* nb_display_alloc(DisplayDriver _Nonnull* driver) { DisplayDevice _Nonnull* display = malloc(sizeof(DisplayDevice)); diff --git a/components/nanobake/src/nb_display.h b/components/nanobake/src/display.h similarity index 100% rename from components/nanobake/src/nb_display.h rename to components/nanobake/src/display.h diff --git a/components/nanobake/src/nb_lvgl.c b/components/nanobake/src/graphics.c similarity index 95% rename from components/nanobake/src/nb_lvgl.c rename to components/nanobake/src/graphics.c index 417edd8f..ca3d6619 100644 --- a/components/nanobake/src/nb_lvgl.c +++ b/components/nanobake/src/graphics.c @@ -1,10 +1,10 @@ #include "check.h" #include "esp_lvgl_port.h" -#include "nb_lvgl_i.h" +#include "graphics_i.h" #define TAG "lvgl" -Lvgl nb_lvgl_init(Devices _Nonnull* hardware) { +Lvgl nb_graphics_init(Devices _Nonnull* hardware) { const lvgl_port_cfg_t lvgl_cfg = { .task_priority = 4, .task_stack = 4096, diff --git a/components/nanobake/src/nb_lvgl.h b/components/nanobake/src/graphics.h similarity index 100% rename from components/nanobake/src/nb_lvgl.h rename to components/nanobake/src/graphics.h diff --git a/components/nanobake/src/nb_lvgl_i.h b/components/nanobake/src/graphics_i.h similarity index 58% rename from components/nanobake/src/nb_lvgl_i.h rename to components/nanobake/src/graphics_i.h index 29d2ee4f..b37de168 100644 --- a/components/nanobake/src/nb_lvgl_i.h +++ b/components/nanobake/src/graphics_i.h @@ -1,14 +1,13 @@ #pragma once #include "devices.h" -#include "nb_lvgl.h" +#include "graphics.h" #ifdef __cplusplus extern "C" { #endif -extern Lvgl nb_lvgl_init(Devices _Nonnull* hardware); - +Lvgl nb_graphics_init(Devices _Nonnull* hardware); #ifdef __cplusplus } diff --git a/components/nanobake/src/nanobake.c b/components/nanobake/src/nanobake.c index 8818ac0b..a89ce305 100644 --- a/components/nanobake/src/nanobake.c +++ b/components/nanobake/src/nanobake.c @@ -1,10 +1,10 @@ #include "nanobake.h" -#include "applications/nb_applications.h" +#include "app_i.h" +#include "applications/applications_i.h" +#include "devices_i.h" #include "esp_log.h" +#include "graphics_i.h" #include "m-list.h" -#include "nb_app_i.h" -#include "nb_hardware_i.h" -#include "nb_lvgl_i.h" // Furi #include "kernel.h" #include "record.h" @@ -60,21 +60,21 @@ static void prv_start_app(const App _Nonnull* app) { __attribute__((unused)) extern void nanobake_start(Config _Nonnull* config) { prv_furi_init(); - Devices hardware = nb_hardware_create(config); - /*NbLvgl lvgl =*/nb_lvgl_init(&hardware); + Devices hardware = nb_devices_create(config); + /*NbLvgl lvgl =*/nb_graphics_init(&hardware); thread_ids_init(prv_thread_ids); ESP_LOGI(TAG, "Starting apps"); // Services - for (size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) { - prv_start_app(FLIPPER_SERVICES[i]); + for (size_t i = 0; i < NANOBAKE_SERVICES_COUNT; i++) { + prv_start_app(NANOBAKE_SERVICES[i]); } // System - for (size_t i = 0; i < FLIPPER_SYSTEM_APPS_COUNT; i++) { - prv_start_app(FLIPPER_SYSTEM_APPS[i]); + for (size_t i = 0; i < NANOBAKE_SYSTEM_APPS_COUNT; i++) { + prv_start_app(NANOBAKE_SYSTEM_APPS[i]); } // User diff --git a/components/nanobake/src/nanobake.h b/components/nanobake/src/nanobake.h index 04092da9..c5c41d81 100644 --- a/components/nanobake/src/nanobake.h +++ b/components/nanobake/src/nanobake.h @@ -1,8 +1,9 @@ #pragma once +#include "app.h" #include "devices.h" -#include "nb_app.h" -#include "nb_config.h" +#include "core_defines.h" +#include "base.h" #ifdef __cplusplus extern "C" { @@ -10,11 +11,23 @@ extern "C" { // Forward declarations typedef void* FuriThreadId; +typedef TouchDriver (*CreateTouchDriver)(); +typedef DisplayDriver (*CreateDisplayDriver)(); + +typedef struct { + // Required driver for display + const CreateDisplayDriver _Nonnull display_driver; + // Optional driver for touch input + const CreateTouchDriver _Nullable touch_driver; + // List of user applications + const size_t apps_count; + const App* const apps[]; +} Config; __attribute__((unused)) extern void nanobake_start(Config _Nonnull* config); -extern FuriThreadId nanobake_get_app_thread_id(size_t index); -extern size_t nanobake_get_app_thread_count(); +FuriThreadId nanobake_get_app_thread_id(size_t index); +size_t nanobake_get_app_thread_count(); #ifdef __cplusplus } diff --git a/components/nanobake/src/nb_config.h b/components/nanobake/src/nb_config.h deleted file mode 100644 index 2b8084d9..00000000 --- a/components/nanobake/src/nb_config.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "nb_app.h" -#include "nb_display.h" -#include "nb_touch.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef TouchDriver (*CreateTouchDriver)(); -typedef DisplayDriver (*CreateDisplayDriver)(); - -typedef struct { - // Required driver for display - const CreateDisplayDriver _Nonnull display_driver; - // Optional driver for touch input - const CreateTouchDriver _Nullable touch_driver; - // List of user applications - const size_t apps_count; - const App* const apps[]; -} Config; - -#ifdef __cplusplus -} -#endif diff --git a/components/nanobake/src/nb_hardware_i.h b/components/nanobake/src/nb_hardware_i.h deleted file mode 100644 index c414e92e..00000000 --- a/components/nanobake/src/nb_hardware_i.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "devices.h" -#include "nb_config.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern Devices nb_hardware_create(Config _Nonnull* config); - -#ifdef __cplusplus -} -#endif diff --git a/components/nanobake/src/nb_touch.c b/components/nanobake/src/touch.c similarity index 93% rename from components/nanobake/src/nb_touch.c rename to components/nanobake/src/touch.c index 505def92..b98f1998 100644 --- a/components/nanobake/src/nb_touch.c +++ b/components/nanobake/src/touch.c @@ -1,5 +1,5 @@ -#include "nb_touch.h" #include "check.h" +#include "touch.h" TouchDevice _Nonnull* nb_touch_alloc(TouchDriver _Nonnull* driver) { TouchDevice _Nonnull* touch = malloc(sizeof(TouchDevice)); diff --git a/components/nanobake/src/nb_touch.h b/components/nanobake/src/touch.h similarity index 100% rename from components/nanobake/src/nb_touch.h rename to components/nanobake/src/touch.h diff --git a/main/src/hello_world/hello_world.c b/main/src/hello_world/hello_world.c index 80271f35..ca43addc 100644 --- a/main/src/hello_world/hello_world.c +++ b/main/src/hello_world/hello_world.c @@ -1,9 +1,9 @@ #include "hello_world.h" -#include "record.h" -#include "nb_lvgl.h" #include "applications/services/gui/gui.h" -#include "esp_lvgl_port.h" #include "esp_log.h" +#include "esp_lvgl_port.h" +#include "graphics.h" +#include "record.h" static const char* TAG = "app_helloworld"; diff --git a/main/src/hello_world/hello_world.h b/main/src/hello_world/hello_world.h index 88072ab5..53a47992 100644 --- a/main/src/hello_world/hello_world.h +++ b/main/src/hello_world/hello_world.h @@ -1,5 +1,5 @@ #pragma once -#include "nb_app.h" +#include "app.h" extern const App hello_world_app;