app type cleanup and improvements
This commit is contained in:
parent
88c5c55be3
commit
aa24b84eb6
@ -16,8 +16,7 @@ typedef enum nb_app_type nb_app_type_t;
|
||||
enum nb_app_type {
|
||||
SERVICE,
|
||||
SYSTEM,
|
||||
USER,
|
||||
STARTUP
|
||||
USER
|
||||
};
|
||||
|
||||
typedef struct nb_app nb_app_t;
|
||||
|
||||
@ -17,9 +17,7 @@ static int32_t system_info_entry_point(void* param) {
|
||||
const char* name = furi_thread_get_name(thread_id);
|
||||
bool is_suspended = furi_thread_is_suspended(thread_id);
|
||||
const char* status = is_suspended ? "suspended" : "active";
|
||||
bool is_service = furi_thread_mark_is_service(thread_id);
|
||||
const char* type = is_service ? "service" : "app";
|
||||
printf(" - [%s, %s] %s (%s)\n", type, status, name, appid);
|
||||
printf(" - [%s] %s (%s)\n", status, name, appid);
|
||||
}
|
||||
|
||||
printf("Heap memory available: %d / %d\n",
|
||||
|
||||
@ -1,27 +1,10 @@
|
||||
#include "desktop.h"
|
||||
#include "nb_hardware.h"
|
||||
#include <esp_lvgl_port.h>
|
||||
#include "core_defines.h"
|
||||
#include <esp_log.h>
|
||||
|
||||
//nb_desktop_t* shared_desktop = NULL;
|
||||
#include <core_defines.h>
|
||||
|
||||
static int32_t prv_desktop_main(void* param) {
|
||||
UNUSED(param);
|
||||
printf("desktop app init\n");
|
||||
// nb_desktop_t* desktop = desktop_alloc();
|
||||
// shared_desktop = desktop;
|
||||
|
||||
// lvgl_port_lock(0);
|
||||
//
|
||||
// lv_obj_t* label = lv_label_create(lv_parent);
|
||||
// lv_label_set_recolor(label, true);
|
||||
// lv_obj_set_width(label, (lv_coord_t)hardware->display->horizontal_resolution);
|
||||
// lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, 0);
|
||||
// lv_label_set_text(label, "Desktop app");
|
||||
// lv_obj_align(label, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
//
|
||||
// lvgl_port_unlock();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ static int32_t prv_gui_main(void* param) {
|
||||
const nb_app_t gui_app = {
|
||||
.id = "gui",
|
||||
.name = "GUI",
|
||||
.type = STARTUP,
|
||||
.type = SERVICE,
|
||||
.entry_point = &prv_gui_main,
|
||||
.stack_size = 2048,
|
||||
.priority = 10
|
||||
|
||||
@ -10,7 +10,7 @@ static int32_t prv_loader_main(void* param) {
|
||||
const nb_app_t loader_app = {
|
||||
.id = "loader",
|
||||
.name = "Loader",
|
||||
.type = STARTUP,
|
||||
.type = SERVICE,
|
||||
.entry_point = &prv_loader_main,
|
||||
.stack_size = 2048,
|
||||
.priority = 10
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "nanobake.h"
|
||||
#include "nb_hardwarei.h"
|
||||
#include "nb_lvgli.h"
|
||||
#include "nb_appi.h"
|
||||
#include "applications/nb_applications.h"
|
||||
#include <esp_log.h>
|
||||
#include <m-list.h>
|
||||
@ -8,7 +9,6 @@
|
||||
#include <thread.h>
|
||||
#include <kernel.h>
|
||||
#include <record.h>
|
||||
#include <check.h>
|
||||
|
||||
M_LIST_DEF(thread_ids, FuriThreadId);
|
||||
|
||||
@ -34,69 +34,53 @@ size_t nanobake_get_app_thread_count() {
|
||||
return thread_ids_size(prv_thread_ids);
|
||||
}
|
||||
|
||||
static void prv_start_app(const nb_app_t _Nonnull* app) {
|
||||
ESP_LOGI(TAG, "Starting %s app \"%s\"",
|
||||
nb_app_type_to_string(app->type),
|
||||
app->name
|
||||
);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
app->name,
|
||||
app->stack_size,
|
||||
app->entry_point,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (app->type == SERVICE) {
|
||||
furi_thread_mark_as_service(thread);
|
||||
}
|
||||
|
||||
furi_thread_set_appid(thread, app->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
}
|
||||
|
||||
extern void nanobake_start(nb_config_t _Nonnull* config) {
|
||||
prv_furi_init();
|
||||
|
||||
nb_hardware_t hardware = nb_hardware_create(config);
|
||||
nb_lvgl_t lvgl = nb_lvgl_init(&hardware);
|
||||
/*nb_lvgl_t lvgl =*/ nb_lvgl_init(&hardware);
|
||||
|
||||
thread_ids_init(prv_thread_ids);
|
||||
|
||||
ESP_LOGI(TAG, "Starting services");
|
||||
ESP_LOGI(TAG, "Starting apps");
|
||||
|
||||
for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
|
||||
ESP_LOGI(TAG, "Starting system service \"%s\"", FLIPPER_SERVICES[i]->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
FLIPPER_SERVICES[i]->name,
|
||||
FLIPPER_SERVICES[i]->stack_size,
|
||||
FLIPPER_SERVICES[i]->entry_point,
|
||||
NULL
|
||||
);
|
||||
furi_thread_mark_as_service(thread);
|
||||
furi_thread_set_appid(thread, FLIPPER_SERVICES[i]->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
// Services
|
||||
for (size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
|
||||
prv_start_app(FLIPPER_SERVICES[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Starting system apps");
|
||||
|
||||
for(size_t i = 0; i < FLIPPER_SYSTEM_APPS_COUNT; i++) {
|
||||
ESP_LOGI(TAG, "Starting system app \"%s\"", FLIPPER_SYSTEM_APPS[i]->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
FLIPPER_SYSTEM_APPS[i]->name,
|
||||
FLIPPER_SYSTEM_APPS[i]->stack_size,
|
||||
FLIPPER_SYSTEM_APPS[i]->entry_point,
|
||||
NULL
|
||||
);
|
||||
furi_thread_mark_as_service(thread);
|
||||
furi_thread_set_appid(thread, FLIPPER_SYSTEM_APPS[i]->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
// System
|
||||
for (size_t i = 0; i < FLIPPER_SYSTEM_APPS_COUNT; i++) {
|
||||
prv_start_app(FLIPPER_SYSTEM_APPS[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Starting external apps");
|
||||
|
||||
for(size_t i = 0; i < config->apps_count; i++) {
|
||||
const nb_app_t* app = config->apps[i];
|
||||
ESP_LOGI(TAG, "Starting external app \"%s\"", app->name);
|
||||
|
||||
FuriThread* thread = furi_thread_alloc_ex(
|
||||
app->name,
|
||||
app->stack_size,
|
||||
app->entry_point,
|
||||
NULL
|
||||
);
|
||||
furi_thread_set_appid(thread, app->id);
|
||||
furi_thread_start(thread);
|
||||
|
||||
FuriThreadId thread_id = furi_thread_get_id(thread);
|
||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||
// User
|
||||
for (size_t i = 0; i < config->apps_count; i++) {
|
||||
prv_start_app(config->apps[i]);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Startup complete");
|
||||
|
||||
19
components/nanobake/src/nb_app.c
Normal file
19
components/nanobake/src/nb_app.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include "nb_appi.h"
|
||||
#include <check.h>
|
||||
|
||||
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(nb_app_type_t type) {
|
||||
switch (type) {
|
||||
case SERVICE:
|
||||
return prv_type_service;
|
||||
case SYSTEM:
|
||||
return prv_type_system;
|
||||
case USER:
|
||||
return prv_type_user;
|
||||
default:
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
13
components/nanobake/src/nb_appi.h
Normal file
13
components/nanobake/src/nb_appi.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "nb_app.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char* nb_app_type_to_string(nb_app_type_t type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user