improved hello world readability
This commit is contained in:
parent
6e03655767
commit
2d47104aa9
@ -1,8 +1,6 @@
|
|||||||
#include "hello_world.h"
|
#include "hello_world.h"
|
||||||
#include "core_defines.h"
|
|
||||||
#include "record.h"
|
#include "record.h"
|
||||||
#include "nb_lvgl.h"
|
#include "nb_lvgl.h"
|
||||||
#include "nb_hardware.h"
|
|
||||||
#include "applications/services/gui/gui.h"
|
#include "applications/services/gui/gui.h"
|
||||||
#include "esp_lvgl_port.h"
|
#include "esp_lvgl_port.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
@ -11,7 +9,7 @@ static const char* TAG = "app_helloworld";
|
|||||||
|
|
||||||
ViewPort* view_port = NULL;
|
ViewPort* view_port = NULL;
|
||||||
|
|
||||||
static void prv_on_button_click(lv_event_t _Nonnull* event) {
|
static void on_button_click(lv_event_t _Nonnull* event) {
|
||||||
ESP_LOGI(TAG, "button clicked");
|
ESP_LOGI(TAG, "button clicked");
|
||||||
|
|
||||||
FURI_RECORD_TRANSACTION(RECORD_GUI, gui, {
|
FURI_RECORD_TRANSACTION(RECORD_GUI, gui, {
|
||||||
@ -21,7 +19,8 @@ static void prv_on_button_click(lv_event_t _Nonnull* event) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prv_hello_world_lvgl(lv_obj_t* parent, void* context) {
|
// Main entry point for LVGL widget creation
|
||||||
|
static void app_lvgl(lv_obj_t* parent, void* context) {
|
||||||
lvgl_port_lock(0);
|
lvgl_port_lock(0);
|
||||||
|
|
||||||
lv_obj_t* label = lv_label_create(parent);
|
lv_obj_t* label = lv_label_create(parent);
|
||||||
@ -35,18 +34,20 @@ static void prv_hello_world_lvgl(lv_obj_t* parent, void* context) {
|
|||||||
label = lv_label_create(btn);
|
label = lv_label_create(btn);
|
||||||
lv_label_set_text_static(label, "Exit");
|
lv_label_set_text_static(label, "Exit");
|
||||||
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 30);
|
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 30);
|
||||||
lv_obj_add_event_cb(btn, prv_on_button_click, LV_EVENT_CLICKED, NULL);
|
lv_obj_add_event_cb(btn, on_button_click, LV_EVENT_CLICKED, NULL);
|
||||||
|
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t prv_hello_world_main(void* param) {
|
// Main entry point for the app
|
||||||
|
static int32_t app_main(void* param) {
|
||||||
UNUSED(param);
|
UNUSED(param);
|
||||||
|
|
||||||
// Configure view port
|
// Configure view port to enable UI with LVGL
|
||||||
view_port = view_port_alloc();
|
view_port = view_port_alloc();
|
||||||
view_port_draw_callback_set(view_port, &prv_hello_world_lvgl, view_port);
|
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, {
|
FURI_RECORD_TRANSACTION(RECORD_GUI, gui, {
|
||||||
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
|
||||||
})
|
})
|
||||||
@ -58,7 +59,7 @@ const NbApp hello_world_app = {
|
|||||||
.id = "helloworld",
|
.id = "helloworld",
|
||||||
.name = "Hello World",
|
.name = "Hello World",
|
||||||
.type = USER,
|
.type = USER,
|
||||||
.entry_point = &prv_hello_world_main,
|
.entry_point = &app_main,
|
||||||
.stack_size = NB_TASK_STACK_SIZE_DEFAULT,
|
.stack_size = NB_TASK_STACK_SIZE_DEFAULT,
|
||||||
.priority = NB_TASK_PRIORITY_DEFAULT
|
.priority = NB_TASK_PRIORITY_DEFAULT
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user