renamed struct types
This commit is contained in:
parent
6282011634
commit
1cafa1ec1a
@ -31,7 +31,7 @@ IRAM_ATTR static bool prv_on_color_trans_done(esp_lcd_panel_io_handle_t io_handl
|
||||
return (need_yield == pdTRUE);
|
||||
}
|
||||
|
||||
static bool prv_create_display(NbDisplay* display) {
|
||||
static bool prv_create_display(DisplayDevice* display) {
|
||||
ESP_LOGI(TAG, "creating display");
|
||||
|
||||
gpio_config_t io_conf = {
|
||||
@ -121,8 +121,8 @@ static bool prv_create_display(NbDisplay* display) {
|
||||
return true;
|
||||
}
|
||||
|
||||
NbDisplayDriver board_2432s024_create_display_driver() {
|
||||
return (NbDisplayDriver) {
|
||||
DisplayDriver board_2432s024_create_display_driver() {
|
||||
return (DisplayDriver) {
|
||||
.name = "ili9341_2432s024",
|
||||
.create_display = &prv_create_display
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern NbDisplayDriver board_2432s024_create_display_driver();
|
||||
extern DisplayDriver board_2432s024_create_display_driver();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -64,8 +64,8 @@ static bool prv_create_touch(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch
|
||||
return true;
|
||||
}
|
||||
|
||||
NbTouchDriver board_2432s024_create_touch_driver() {
|
||||
return (NbTouchDriver) {
|
||||
TouchDriver board_2432s024_create_touch_driver() {
|
||||
return (TouchDriver) {
|
||||
.name = "cst816s_2432s024",
|
||||
.create_touch = &prv_create_touch
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern NbTouchDriver board_2432s024_create_touch_driver();
|
||||
extern TouchDriver board_2432s024_create_touch_driver();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -19,8 +19,8 @@ extern "C" {
|
||||
* @param code the code to execute: consider putting it between {}
|
||||
*/
|
||||
#define FURI_RECORD_TRANSACTION(record_name, variable_name, code) \
|
||||
{ \
|
||||
NbGui*(variable_name) = (NbGui*)furi_record_open(record_name); \
|
||||
{ \
|
||||
Gui*(variable_name) = (Gui*)furi_record_open(record_name); \
|
||||
code; \
|
||||
furi_record_close(record_name); \
|
||||
}
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
#include "nb_applications.h"
|
||||
|
||||
// System services
|
||||
extern const NbApp desktop_app;
|
||||
extern const NbApp gui_app;
|
||||
extern const NbApp loader_app;
|
||||
extern const App desktop_app;
|
||||
extern const App gui_app;
|
||||
extern const App loader_app;
|
||||
|
||||
// System apps
|
||||
extern const NbApp system_info_app;
|
||||
extern const App system_info_app;
|
||||
|
||||
const NbApp* const FLIPPER_SERVICES[] = {
|
||||
const App* const FLIPPER_SERVICES[] = {
|
||||
&desktop_app,
|
||||
&gui_app,
|
||||
&loader_app
|
||||
};
|
||||
|
||||
const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(NbApp*);
|
||||
const size_t FLIPPER_SERVICES_COUNT = sizeof(FLIPPER_SERVICES) / sizeof(App*);
|
||||
|
||||
const NbApp* const FLIPPER_SYSTEM_APPS[] = {
|
||||
const App* const FLIPPER_SYSTEM_APPS[] = {
|
||||
&system_info_app
|
||||
};
|
||||
|
||||
const size_t FLIPPER_SYSTEM_APPS_COUNT = sizeof(FLIPPER_SYSTEM_APPS) / sizeof(NbApp*);
|
||||
const size_t FLIPPER_SYSTEM_APPS_COUNT = sizeof(FLIPPER_SYSTEM_APPS) / sizeof(App*);
|
||||
|
||||
const NbOnSystemStart FLIPPER_ON_SYSTEM_START[] = {
|
||||
const OnSystemStart FLIPPER_ON_SYSTEM_START[] = {
|
||||
};
|
||||
|
||||
const size_t FLIPPER_ON_SYSTEM_START_COUNT = sizeof(FLIPPER_ON_SYSTEM_START) / sizeof(NbOnSystemStart);
|
||||
const size_t FLIPPER_ON_SYSTEM_START_COUNT = sizeof(FLIPPER_ON_SYSTEM_START) / sizeof(OnSystemStart);
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "devices.h"
|
||||
#include "nb_app.h"
|
||||
#include "nb_hardware.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*NbOnSystemStart)(NbHardware* hardware);
|
||||
typedef void (*OnSystemStart)(Devices* hardware);
|
||||
|
||||
extern const NbApp* const FLIPPER_SERVICES[];
|
||||
extern const App* const FLIPPER_SERVICES[];
|
||||
extern const size_t FLIPPER_SERVICES_COUNT;
|
||||
|
||||
extern const NbApp* const FLIPPER_SYSTEM_APPS[];
|
||||
extern const App* const FLIPPER_SYSTEM_APPS[];
|
||||
extern const size_t FLIPPER_SYSTEM_APPS_COUNT;
|
||||
|
||||
extern const NbOnSystemStart FLIPPER_ON_SYSTEM_START[];
|
||||
extern const OnSystemStart FLIPPER_ON_SYSTEM_START[];
|
||||
extern const size_t FLIPPER_ON_SYSTEM_START_COUNT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include "desktop.h"
|
||||
#include "core_defines.h"
|
||||
#include "nb_hardware.h"
|
||||
#include "devices.h"
|
||||
|
||||
static int32_t prv_desktop_main(void* param) {
|
||||
UNUSED(param);
|
||||
@ -8,7 +8,7 @@ static int32_t prv_desktop_main(void* param) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const NbApp desktop_app = {
|
||||
const App desktop_app = {
|
||||
.id = "desktop",
|
||||
.name = "Desktop",
|
||||
.type = SERVICE,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const NbApp desktop_app;
|
||||
extern const App desktop_app;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
#define TAG "gui"
|
||||
|
||||
// Forward declarations from gui_draw.c
|
||||
bool gui_redraw_fs(NbGui* gui);
|
||||
void gui_redraw(NbGui* gui);
|
||||
bool gui_redraw_fs(Gui* gui);
|
||||
void gui_redraw(Gui* gui);
|
||||
|
||||
ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) {
|
||||
// Iterating backward
|
||||
@ -23,7 +23,7 @@ ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t gui_active_view_port_count(NbGui* gui, GuiLayer layer) {
|
||||
size_t gui_active_view_port_count(Gui* gui, GuiLayer layer) {
|
||||
furi_assert(gui);
|
||||
furi_check(layer < GuiLayerMAX);
|
||||
size_t ret = 0;
|
||||
@ -43,23 +43,23 @@ size_t gui_active_view_port_count(NbGui* gui, GuiLayer layer) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void gui_update(NbGui* gui) {
|
||||
void gui_update(Gui* gui) {
|
||||
ESP_LOGI(TAG, "gui_update");
|
||||
furi_assert(gui);
|
||||
furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_DRAW);
|
||||
}
|
||||
|
||||
void gui_lock(NbGui* gui) {
|
||||
void gui_lock(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(furi_mutex_acquire(gui->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void gui_unlock(NbGui* gui) {
|
||||
void gui_unlock(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
furi_check(furi_mutex_release(gui->mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void gui_add_view_port(NbGui* gui, ViewPort* view_port, GuiLayer layer) {
|
||||
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
furi_check(layer < GuiLayerMAX);
|
||||
@ -83,7 +83,7 @@ void gui_add_view_port(NbGui* gui, ViewPort* view_port, GuiLayer layer) {
|
||||
gui_update(gui);
|
||||
}
|
||||
|
||||
void gui_remove_view_port(NbGui* gui, ViewPort* view_port) {
|
||||
void gui_remove_view_port(Gui* gui, ViewPort* view_port) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
|
||||
@ -111,7 +111,7 @@ void gui_remove_view_port(NbGui* gui, ViewPort* view_port) {
|
||||
gui_update(gui);
|
||||
}
|
||||
|
||||
void gui_view_port_send_to_front(NbGui* gui, ViewPort* view_port) {
|
||||
void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
|
||||
@ -140,7 +140,7 @@ void gui_view_port_send_to_front(NbGui* gui, ViewPort* view_port) {
|
||||
gui_update(gui);
|
||||
}
|
||||
|
||||
void gui_view_port_send_to_back(NbGui* gui, ViewPort* view_port) {
|
||||
void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port) {
|
||||
furi_assert(gui);
|
||||
furi_assert(view_port);
|
||||
|
||||
@ -169,7 +169,7 @@ void gui_view_port_send_to_back(NbGui* gui, ViewPort* view_port) {
|
||||
gui_update(gui);
|
||||
}
|
||||
|
||||
void gui_set_lockdown(NbGui* gui, bool lockdown) {
|
||||
void gui_set_lockdown(Gui* gui, bool lockdown) {
|
||||
furi_assert(gui);
|
||||
|
||||
gui_lock(gui);
|
||||
@ -180,8 +180,8 @@ void gui_set_lockdown(NbGui* gui, bool lockdown) {
|
||||
gui_update(gui);
|
||||
}
|
||||
|
||||
NbGui* gui_alloc() {
|
||||
NbGui* gui = malloc(sizeof(NbGui));
|
||||
Gui* gui_alloc() {
|
||||
Gui* gui = malloc(sizeof(Gui));
|
||||
gui->thread_id = furi_thread_get_current_id();
|
||||
gui->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
gui->lvgl_parent = lv_scr_act();
|
||||
@ -204,7 +204,7 @@ NbGui* gui_alloc() {
|
||||
|
||||
__attribute((__noreturn__)) int32_t prv_gui_main(void* parameter) {
|
||||
UNUSED(parameter);
|
||||
NbGui* gui = gui_alloc();
|
||||
Gui* gui = gui_alloc();
|
||||
|
||||
furi_record_create(RECORD_GUI, gui);
|
||||
|
||||
@ -231,7 +231,7 @@ __attribute((__noreturn__)) int32_t prv_gui_main(void* parameter) {
|
||||
}
|
||||
}
|
||||
|
||||
const NbApp gui_app = {
|
||||
const App gui_app = {
|
||||
.id = "gui",
|
||||
.name = "GUI",
|
||||
.type = SERVICE,
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const NbApp gui_app;
|
||||
extern const App gui_app;
|
||||
|
||||
/** Canvas Orientation */
|
||||
typedef enum {
|
||||
@ -42,7 +42,7 @@ typedef void (*GuiCanvasCommitCallback)(
|
||||
|
||||
#define RECORD_GUI "gui"
|
||||
|
||||
typedef struct NbGui NbGui;
|
||||
typedef struct Gui Gui;
|
||||
|
||||
/** Add view_port to view_port tree
|
||||
*
|
||||
@ -52,7 +52,7 @@ typedef struct NbGui NbGui;
|
||||
* @param view_port ViewPort instance
|
||||
* @param[in] layer GuiLayer where to place view_port
|
||||
*/
|
||||
void gui_add_view_port(NbGui* gui, ViewPort* view_port, GuiLayer layer);
|
||||
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer);
|
||||
|
||||
/** Remove view_port from rendering tree
|
||||
*
|
||||
@ -61,7 +61,7 @@ void gui_add_view_port(NbGui* gui, ViewPort* view_port, GuiLayer layer);
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void gui_remove_view_port(NbGui* gui, ViewPort* view_port);
|
||||
void gui_remove_view_port(Gui* gui, ViewPort* view_port);
|
||||
|
||||
/** Send ViewPort to the front
|
||||
*
|
||||
@ -70,7 +70,7 @@ void gui_remove_view_port(NbGui* gui, ViewPort* view_port);
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void gui_view_port_send_to_front(NbGui* gui, ViewPort* view_port);
|
||||
void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port);
|
||||
|
||||
/** Send ViewPort to the back
|
||||
*
|
||||
@ -79,7 +79,7 @@ void gui_view_port_send_to_front(NbGui* gui, ViewPort* view_port);
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void gui_view_port_send_to_back(NbGui* gui, ViewPort* view_port);
|
||||
void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port);
|
||||
|
||||
/** Set lockdown mode
|
||||
*
|
||||
@ -89,7 +89,7 @@ void gui_view_port_send_to_back(NbGui* gui, ViewPort* view_port);
|
||||
* @param gui Gui instance
|
||||
* @param lockdown bool, true if enabled
|
||||
*/
|
||||
void gui_set_lockdown(NbGui* gui, bool lockdown);
|
||||
void gui_set_lockdown(Gui* gui, bool lockdown);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include "check.h"
|
||||
#include "gui_i.h"
|
||||
|
||||
static void gui_redraw_status_bar(NbGui* gui, bool need_attention) {
|
||||
static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
/*
|
||||
ViewPortArray_it_t it;
|
||||
uint8_t left_used = 0;
|
||||
@ -149,7 +149,7 @@ static void gui_redraw_status_bar(NbGui* gui, bool need_attention) {
|
||||
*/
|
||||
}
|
||||
|
||||
static bool gui_redraw_window(NbGui* gui) {
|
||||
static bool gui_redraw_window(Gui* gui) {
|
||||
/*
|
||||
canvas_frame_set(gui->lvgl_parent, GUI_WINDOW_X, GUI_WINDOW_Y, GUI_WINDOW_WIDTH, GUI_WINDOW_HEIGHT);
|
||||
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]);
|
||||
@ -161,7 +161,7 @@ static bool gui_redraw_window(NbGui* gui) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool gui_redraw_desktop(NbGui* gui) {
|
||||
static bool gui_redraw_desktop(Gui* gui) {
|
||||
/*
|
||||
canvas_frame_set(gui->lvgl_parent, 0, 0, GUI_DISPLAY_WIDTH, GUI_DISPLAY_HEIGHT);
|
||||
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]);
|
||||
@ -174,7 +174,7 @@ static bool gui_redraw_desktop(NbGui* gui) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool gui_redraw_fs(NbGui* gui) {
|
||||
bool gui_redraw_fs(Gui* gui) {
|
||||
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]);
|
||||
if (view_port) {
|
||||
view_port_draw(view_port, gui->lvgl_parent);
|
||||
@ -184,7 +184,7 @@ bool gui_redraw_fs(NbGui* gui) {
|
||||
}
|
||||
}
|
||||
|
||||
void gui_redraw(NbGui* gui) {
|
||||
void gui_redraw(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
gui_lock(gui);
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ typedef struct {
|
||||
} CanvasCallbackPair;
|
||||
|
||||
/** Gui structure */
|
||||
struct NbGui {
|
||||
struct Gui {
|
||||
// Thread and lock
|
||||
FuriThreadId thread_id;
|
||||
FuriMutex* mutex;
|
||||
@ -75,7 +75,7 @@ ViewPort* gui_view_port_find_enabled(ViewPortArray_t array);
|
||||
*
|
||||
* @param gui Gui instance
|
||||
*/
|
||||
void gui_update(NbGui* gui);
|
||||
void gui_update(Gui* gui);
|
||||
|
||||
///** Input event callback
|
||||
// *
|
||||
@ -91,16 +91,16 @@ void gui_update(NbGui* gui);
|
||||
* @param gui The Gui instance
|
||||
* @param[in] layer GuiLayer that we want to get count of view ports
|
||||
*/
|
||||
size_t gui_active_view_port_count(NbGui* gui, GuiLayer layer);
|
||||
size_t gui_active_view_port_count(Gui* gui, GuiLayer layer);
|
||||
|
||||
/** Lock GUI
|
||||
*
|
||||
* @param gui The Gui instance
|
||||
*/
|
||||
void gui_lock(NbGui* gui);
|
||||
void gui_lock(Gui* gui);
|
||||
|
||||
/** Unlock GUI
|
||||
*
|
||||
* @param gui The Gui instance
|
||||
*/
|
||||
void gui_unlock(NbGui* gui);
|
||||
void gui_unlock(Gui* gui);
|
||||
|
||||
@ -68,7 +68,7 @@ void view_port_update(ViewPort* view_port) {
|
||||
furi_mutex_release(view_port->mutex);
|
||||
}
|
||||
|
||||
void view_port_gui_set(ViewPort* view_port, NbGui* gui) {
|
||||
void view_port_gui_set(ViewPort* view_port, Gui* gui) {
|
||||
furi_assert(view_port);
|
||||
furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk);
|
||||
view_port->gui = gui;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "view_port.h"
|
||||
|
||||
struct ViewPort {
|
||||
NbGui* gui;
|
||||
Gui* gui;
|
||||
FuriMutex* mutex;
|
||||
bool is_enabled;
|
||||
|
||||
@ -25,7 +25,7 @@ struct ViewPort {
|
||||
* @param view_port ViewPort instance
|
||||
* @param gui gui instance pointer
|
||||
*/
|
||||
void view_port_gui_set(ViewPort* view_port, NbGui* gui);
|
||||
void view_port_gui_set(ViewPort* view_port, Gui* gui);
|
||||
|
||||
/** Process draw call. Calls draw callback.
|
||||
*
|
||||
|
||||
@ -7,7 +7,7 @@ static int32_t prv_loader_main(void* param) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const NbApp loader_app = {
|
||||
const App loader_app = {
|
||||
.id = "loader",
|
||||
.name = "Loader",
|
||||
.type = SERVICE,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const NbApp loader_app;
|
||||
extern const App loader_app;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ static int32_t system_info_entry_point(void* param) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NbApp system_info_app = {
|
||||
App system_info_app = {
|
||||
.id = "systeminfo",
|
||||
.name = "System Info",
|
||||
.type = SYSTEM,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern NbApp system_info_app;
|
||||
extern App system_info_app;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -5,16 +5,16 @@
|
||||
|
||||
#define TAG "hardware"
|
||||
|
||||
NbHardware nb_hardware_create(NbConfig _Nonnull* config) {
|
||||
Devices nb_hardware_create(Config _Nonnull* config) {
|
||||
|
||||
furi_check(config->display_driver != NULL, "no display driver configured");
|
||||
NbDisplayDriver display_driver = config->display_driver();
|
||||
DisplayDriver display_driver = config->display_driver();
|
||||
ESP_LOGI(TAG, "display with driver %s", display_driver.name);
|
||||
NbDisplay* display = nb_display_alloc(&display_driver);
|
||||
DisplayDevice* display = nb_display_alloc(&display_driver);
|
||||
|
||||
NbTouch* touch = NULL;
|
||||
TouchDevice* touch = NULL;
|
||||
if (config->touch_driver != NULL) {
|
||||
NbTouchDriver touch_driver = config->touch_driver();
|
||||
TouchDriver touch_driver = config->touch_driver();
|
||||
ESP_LOGI(TAG, "touch with driver %s", touch_driver.name);
|
||||
touch = nb_touch_alloc(&touch_driver);
|
||||
} else {
|
||||
@ -22,7 +22,7 @@ NbHardware nb_hardware_create(NbConfig _Nonnull* config) {
|
||||
touch = NULL;
|
||||
}
|
||||
|
||||
return (NbHardware) {
|
||||
return (Devices) {
|
||||
.display = display,
|
||||
.touch = touch
|
||||
};
|
||||
@ -8,9 +8,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
NbDisplay* _Nonnull display;
|
||||
NbTouch* _Nullable touch;
|
||||
} NbHardware;
|
||||
DisplayDevice* _Nonnull display;
|
||||
TouchDevice* _Nullable touch;
|
||||
} Devices;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@ -35,7 +35,7 @@ size_t nanobake_get_app_thread_count() {
|
||||
return thread_ids_size(prv_thread_ids);
|
||||
}
|
||||
|
||||
static void prv_start_app(const NbApp _Nonnull* app) {
|
||||
static void prv_start_app(const App _Nonnull* app) {
|
||||
ESP_LOGI(TAG, "Starting %s app \"%s\"", nb_app_type_to_string(app->type), app->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
@ -57,10 +57,10 @@ static void prv_start_app(const NbApp _Nonnull* app) {
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
}
|
||||
|
||||
__attribute__((unused)) extern void nanobake_start(NbConfig _Nonnull* config) {
|
||||
__attribute__((unused)) extern void nanobake_start(Config _Nonnull* config) {
|
||||
prv_furi_init();
|
||||
|
||||
NbHardware hardware = nb_hardware_create(config);
|
||||
Devices hardware = nb_hardware_create(config);
|
||||
/*NbLvgl lvgl =*/nb_lvgl_init(&hardware);
|
||||
|
||||
thread_ids_init(prv_thread_ids);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "devices.h"
|
||||
#include "nb_app.h"
|
||||
#include "nb_config.h"
|
||||
#include "nb_hardware.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -11,7 +11,7 @@ extern "C" {
|
||||
// Forward declarations
|
||||
typedef void* FuriThreadId;
|
||||
|
||||
__attribute__((unused)) extern void nanobake_start(NbConfig _Nonnull* 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();
|
||||
|
||||
@ -5,7 +5,7 @@ const char* prv_type_service = "service";
|
||||
const char* prv_type_system = "system";
|
||||
const char* prv_type_user = "user";
|
||||
|
||||
const char* nb_app_type_to_string(NbAppType type) {
|
||||
const char* nb_app_type_to_string(AppType type) {
|
||||
switch (type) {
|
||||
case SERVICE:
|
||||
return prv_type_service;
|
||||
|
||||
@ -15,26 +15,26 @@ typedef enum {
|
||||
SERVICE,
|
||||
SYSTEM,
|
||||
USER
|
||||
} NbAppType;
|
||||
} AppType;
|
||||
|
||||
typedef enum {
|
||||
NB_TASK_PRIORITY_DEFAULT = 10
|
||||
} NbTaskPriority;
|
||||
} AppPriority;
|
||||
|
||||
typedef enum {
|
||||
NB_TASK_STACK_SIZE_DEFAULT = 2048
|
||||
} NbStackSize;
|
||||
} AppStackSize;
|
||||
|
||||
typedef int32_t (*NbAppEntryPoint)(void _Nonnull* parameter);
|
||||
typedef int32_t (*AppEntryPoint)(void _Nonnull* parameter);
|
||||
|
||||
typedef struct {
|
||||
const char id[NB_APP_ID_LENGTH];
|
||||
const char name[NB_APP_NAME_LENGTH];
|
||||
const NbAppType type;
|
||||
const NbAppEntryPoint _Nullable entry_point;
|
||||
const NbStackSize stack_size;
|
||||
const NbTaskPriority priority;
|
||||
} NbApp;
|
||||
const AppType type;
|
||||
const AppEntryPoint _Nullable entry_point;
|
||||
const AppStackSize stack_size;
|
||||
const AppPriority priority;
|
||||
} App;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char* nb_app_type_to_string(NbAppType type);
|
||||
extern const char* nb_app_type_to_string(AppType type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef NbTouchDriver (*CreateTouchDriver)();
|
||||
typedef NbDisplayDriver (*CreateDisplayDriver)();
|
||||
typedef TouchDriver (*CreateTouchDriver)();
|
||||
typedef DisplayDriver (*CreateDisplayDriver)();
|
||||
|
||||
typedef struct {
|
||||
// Required driver for display
|
||||
@ -18,8 +18,8 @@ typedef struct {
|
||||
const CreateTouchDriver _Nullable touch_driver;
|
||||
// List of user applications
|
||||
const size_t apps_count;
|
||||
const NbApp* const apps[];
|
||||
} NbConfig;
|
||||
const App* const apps[];
|
||||
} Config;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
#include "nb_display.h"
|
||||
#include "check.h"
|
||||
|
||||
NbDisplay _Nonnull* nb_display_alloc(NbDisplayDriver _Nonnull* driver) {
|
||||
NbDisplay _Nonnull* display = malloc(sizeof(NbDisplay));
|
||||
memset(display, 0, sizeof(NbDisplay));
|
||||
DisplayDevice _Nonnull* nb_display_alloc(DisplayDriver _Nonnull* driver) {
|
||||
DisplayDevice _Nonnull* display = malloc(sizeof(DisplayDevice));
|
||||
memset(display, 0, sizeof(DisplayDevice));
|
||||
furi_check(driver->create_display(display), "failed to create display");
|
||||
furi_check(display->io_handle != NULL);
|
||||
furi_check(display->display_handle != NULL);
|
||||
|
||||
@ -7,29 +7,29 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_io_handle_t _Nonnull io_handle;
|
||||
esp_lcd_panel_handle_t _Nonnull display_handle;
|
||||
uint16_t horizontal_resolution;
|
||||
uint16_t vertical_resolution;
|
||||
uint16_t draw_buffer_height;
|
||||
uint16_t bits_per_pixel;
|
||||
esp_lcd_panel_io_handle_t _Nonnull io_handle;
|
||||
esp_lcd_panel_handle_t _Nonnull display_handle;
|
||||
bool mirror_x;
|
||||
bool mirror_y;
|
||||
bool swap_xy;
|
||||
} NbDisplay;
|
||||
} DisplayDevice;
|
||||
|
||||
typedef bool (*CreateDisplay)(NbDisplay* display);
|
||||
typedef bool (*CreateDisplay)(DisplayDevice* display);
|
||||
|
||||
typedef struct {
|
||||
char name[32];
|
||||
CreateDisplay create_display;
|
||||
} NbDisplayDriver;
|
||||
} DisplayDriver;
|
||||
|
||||
/**
|
||||
* @param[in] driver
|
||||
* @return allocated display object
|
||||
*/
|
||||
NbDisplay _Nonnull* nb_display_alloc(NbDisplayDriver _Nonnull* driver);
|
||||
DisplayDevice _Nonnull* nb_display_alloc(DisplayDriver _Nonnull* driver);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "devices.h"
|
||||
#include "nb_config.h"
|
||||
#include "nb_hardware.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern NbHardware nb_hardware_create(NbConfig _Nonnull* config);
|
||||
extern Devices nb_hardware_create(Config _Nonnull* config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
#define TAG "lvgl"
|
||||
|
||||
NbLvgl nb_lvgl_init(NbHardware _Nonnull* hardware) {
|
||||
Lvgl nb_lvgl_init(Devices _Nonnull* hardware) {
|
||||
const lvgl_port_cfg_t lvgl_cfg = {
|
||||
.task_priority = 4,
|
||||
.task_stack = 4096,
|
||||
@ -14,7 +14,7 @@ NbLvgl nb_lvgl_init(NbHardware _Nonnull* hardware) {
|
||||
};
|
||||
|
||||
furi_check(lvgl_port_init(&lvgl_cfg) == ESP_OK, "lvgl port init failed");
|
||||
NbDisplay _Nonnull* display = hardware->display;
|
||||
DisplayDevice _Nonnull* display = hardware->display;
|
||||
|
||||
// Add display
|
||||
ESP_LOGD(TAG, "lvgl add display");
|
||||
@ -49,7 +49,7 @@ NbLvgl nb_lvgl_init(NbHardware _Nonnull* hardware) {
|
||||
furi_check(touch_indev != NULL, "failed to add touch to lvgl");
|
||||
}
|
||||
|
||||
return (NbLvgl) {
|
||||
return (Lvgl) {
|
||||
.disp = disp,
|
||||
.touch_indev = touch_indev
|
||||
};
|
||||
|
||||
@ -9,7 +9,7 @@ extern "C" {
|
||||
typedef struct {
|
||||
lv_disp_t* _Nonnull disp;
|
||||
lv_indev_t* _Nullable touch_indev;
|
||||
} NbLvgl;
|
||||
} Lvgl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "nb_hardware.h"
|
||||
#include "devices.h"
|
||||
#include "nb_lvgl.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern NbLvgl nb_lvgl_init(NbHardware _Nonnull* hardware);
|
||||
extern Lvgl nb_lvgl_init(Devices _Nonnull* hardware);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
#include "nb_touch.h"
|
||||
#include "check.h"
|
||||
|
||||
NbTouch _Nonnull* nb_touch_alloc(NbTouchDriver _Nonnull* driver) {
|
||||
NbTouch _Nonnull* touch = malloc(sizeof(NbTouch));
|
||||
TouchDevice _Nonnull* nb_touch_alloc(TouchDriver _Nonnull* driver) {
|
||||
TouchDevice _Nonnull* touch = malloc(sizeof(TouchDevice));
|
||||
bool success = driver->create_touch(
|
||||
&(touch->io_handle),
|
||||
&(touch->touch_handle)
|
||||
|
||||
@ -12,18 +12,18 @@ typedef bool (*CreateTouch)(esp_lcd_panel_io_handle_t* io_handle, esp_lcd_touch_
|
||||
typedef struct {
|
||||
char name[32];
|
||||
CreateTouch create_touch;
|
||||
} NbTouchDriver;
|
||||
} TouchDriver;
|
||||
|
||||
typedef struct {
|
||||
esp_lcd_panel_io_handle_t _Nonnull io_handle;
|
||||
esp_lcd_touch_handle_t _Nonnull touch_handle;
|
||||
} NbTouch;
|
||||
} TouchDevice;
|
||||
|
||||
/**
|
||||
* @param[in] driver
|
||||
* @return a newly allocated instance
|
||||
*/
|
||||
NbTouch _Nonnull* nb_touch_alloc(NbTouchDriver _Nonnull* driver);
|
||||
TouchDevice _Nonnull* nb_touch_alloc(TouchDriver _Nonnull* driver);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ static int32_t app_main(void* param) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const NbApp hello_world_app = {
|
||||
const App hello_world_app = {
|
||||
.id = "helloworld",
|
||||
.name = "Hello World",
|
||||
.type = USER,
|
||||
|
||||
@ -2,4 +2,4 @@
|
||||
|
||||
#include "nb_app.h"
|
||||
|
||||
extern const NbApp hello_world_app;
|
||||
extern const App hello_world_app;
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "hello_world/hello_world.h"
|
||||
|
||||
__attribute__((unused)) void app_main(void) {
|
||||
static NbConfig config = {
|
||||
static Config config = {
|
||||
.display_driver = &board_2432s024_create_display_driver,
|
||||
.touch_driver = &board_2432s024_create_touch_driver,
|
||||
.apps = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user