added data partitions and app loading logic
This commit is contained in:
@@ -1,21 +1,16 @@
|
||||
#include "hello_world.h"
|
||||
#include "furi.h"
|
||||
#include "apps/services/gui/gui.h"
|
||||
#include "esp_lvgl_port.h"
|
||||
|
||||
static const char* TAG = "app_hello_world";
|
||||
|
||||
ViewPort* view_port = NULL;
|
||||
FuriSemaphore* quit_lock = NULL;
|
||||
#include "apps/services/loader/loader.h"
|
||||
|
||||
static void on_button_click(lv_event_t _Nonnull* event) {
|
||||
ESP_LOGI(TAG, "button clicked");
|
||||
furi_semaphore_give(quit_lock);
|
||||
FURI_RECORD_TRANSACTION(RECORD_LOADER, Loader*, loader, {
|
||||
loader_start_app_nonblocking(loader, "systeminfo", NULL);
|
||||
})
|
||||
}
|
||||
|
||||
// Main entry point for LVGL widget creation
|
||||
static void app_lvgl(lv_obj_t* parent, void* context) {
|
||||
lvgl_port_lock(0);
|
||||
static void app_show(lv_obj_t* parent, void* context) {
|
||||
UNUSED(context);
|
||||
|
||||
lv_obj_t* label = lv_label_create(parent);
|
||||
lv_label_set_recolor(label, true);
|
||||
@@ -26,41 +21,9 @@ static void app_lvgl(lv_obj_t* parent, void* context) {
|
||||
|
||||
lv_obj_t* btn = lv_btn_create(parent);
|
||||
label = lv_label_create(btn);
|
||||
lv_label_set_text_static(label, "Exit");
|
||||
lv_label_set_text_static(label, "System Info");
|
||||
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 30);
|
||||
lv_obj_add_event_cb(btn, on_button_click, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
lvgl_port_unlock();
|
||||
}
|
||||
|
||||
// Main entry point for the app
|
||||
static int32_t app_main(void* param) {
|
||||
UNUSED(param);
|
||||
|
||||
// Configure view port to enable UI with LVGL
|
||||
view_port = view_port_alloc();
|
||||
view_port_draw_callback_set(view_port, &app_lvgl, view_port);
|
||||
|
||||
// The transaction automatically calls furi_record_open() and furi_record_close()
|
||||
FURI_RECORD_TRANSACTION(RECORD_GUI, Gui*, gui, {
|
||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||
})
|
||||
|
||||
// Wait for the button click to release the mutex (lock)
|
||||
quit_lock = furi_semaphore_alloc(1, 0);
|
||||
while (!furi_semaphore_take(quit_lock, UINT32_MAX)) {
|
||||
// Do nothing
|
||||
}
|
||||
furi_semaphore_free(quit_lock);
|
||||
quit_lock = NULL;
|
||||
|
||||
FURI_RECORD_TRANSACTION(RECORD_GUI, Gui*, gui, {
|
||||
gui_remove_view_port(gui, view_port);
|
||||
view_port_free(view_port);
|
||||
view_port = NULL;
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const AppManifest hello_world_app = {
|
||||
@@ -68,6 +31,8 @@ const AppManifest hello_world_app = {
|
||||
.name = "Hello World",
|
||||
.icon = NULL,
|
||||
.type = AppTypeUser,
|
||||
.entry_point = &app_main,
|
||||
.on_start = NULL,
|
||||
.on_stop = NULL,
|
||||
.on_show = &app_show,
|
||||
.stack_size = AppStackSizeNormal,
|
||||
};
|
||||
|
||||
+2
-1
@@ -22,8 +22,9 @@ __attribute__((unused)) void app_main(void) {
|
||||
|
||||
FURI_RECORD_TRANSACTION(RECORD_LOADER, Loader*, loader, {
|
||||
FuriString* error_message = furi_string_alloc();
|
||||
if (loader_start(loader, hello_world_app.id, NULL, error_message) != LoaderStatusOk) {
|
||||
if (loader_start_app(loader, hello_world_app.id, NULL, error_message) != LoaderStatusOk) {
|
||||
FURI_LOG_E(hello_world_app.id, "%s\r\n", furi_string_get_cstr(error_message));
|
||||
}
|
||||
furi_string_free(error_message);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user