various improvements
stopped using private header folder (for ease of development - for now) implemented basic gui service (WIP) added sdkconfig.defaults to the repo updated docs
This commit is contained in:
parent
aa24b84eb6
commit
f4088f5762
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,7 +9,7 @@ CMakeCache.txt
|
|||||||
*.cbp
|
*.cbp
|
||||||
|
|
||||||
sdkconfig
|
sdkconfig
|
||||||
sdkconfig.*
|
sdkconfig.old
|
||||||
|
|
||||||
managed_components/
|
managed_components/
|
||||||
dependencies.lock
|
dependencies.lock
|
||||||
|
|||||||
11
README.md
11
README.md
@ -7,6 +7,11 @@ Nanobake provides:
|
|||||||
- UI capabilities (via LVGL)
|
- UI capabilities (via LVGL)
|
||||||
- An application platform that can run apps and services
|
- An application platform that can run apps and services
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
- ESP32 (any?)
|
||||||
|
- [esp-idf 5.1.x](https://docs.espressif.com/projects/esp-idf/en/v5.1.2/esp32/get-started/index.html)
|
||||||
|
- a display (connected via SPI or I2C)
|
||||||
|
|
||||||
**Status: pre-alpha**
|
**Status: pre-alpha**
|
||||||
|
|
||||||
## Technologies
|
## Technologies
|
||||||
@ -20,10 +25,10 @@ UI is created with [lvgl](https://github.com/lvgl/lvgl) via [esp_lvgl_port](http
|
|||||||
|
|
||||||
### Devices
|
### Devices
|
||||||
|
|
||||||
In theory, all hardware from the [Board Support Packages](https://github.com/espressif/esp-bsp/) project is supported.
|
See below for the supported hardware.
|
||||||
|
Predefined configurations are available for:
|
||||||
In practice, there are pre-configured drivers available for these boards:
|
|
||||||
- Yellow Board / 2432S024
|
- Yellow Board / 2432S024
|
||||||
|
- (more will follow)
|
||||||
|
|
||||||
### Drivers
|
### Drivers
|
||||||
|
|
||||||
|
|||||||
@ -14,17 +14,17 @@ static const char* TAG = "2432s024_ili9341";
|
|||||||
|
|
||||||
static SemaphoreHandle_t refresh_finish = NULL;
|
static SemaphoreHandle_t refresh_finish = NULL;
|
||||||
|
|
||||||
#define SELECTED_SPI_HOST SPI2_HOST
|
#define LCD_SPI_HOST SPI2_HOST
|
||||||
#define PIN_SCLK GPIO_NUM_14
|
#define LCD_PIN_SCLK GPIO_NUM_14
|
||||||
#define PIN_MOSI GPIO_NUM_13
|
#define LCD_PIN_MOSI GPIO_NUM_13
|
||||||
#define PIN_CS GPIO_NUM_15
|
#define LCD_PIN_CS GPIO_NUM_15
|
||||||
#define PIN_DC GPIO_NUM_2
|
#define LCD_PIN_DC GPIO_NUM_2
|
||||||
#define PIN_BACKLIGHT GPIO_NUM_27
|
#define LCD_PIN_BACKLIGHT GPIO_NUM_27
|
||||||
|
|
||||||
#define HORIZONTAL_RESOLUTION 240
|
#define LCD_HORIZONTAL_RESOLUTION 240
|
||||||
#define VERTICAL_RESOLUTION 320
|
#define LCD_VERTICAL_RESOLUTION 320
|
||||||
#define BITS_PER_PIXEL 16
|
#define LCD_BITS_PER_PIXEL 16
|
||||||
#define DRAW_BUFFER_HEIGHT 80
|
#define LCD_DRAW_BUFFER_HEIGHT 80
|
||||||
|
|
||||||
IRAM_ATTR static bool prv_on_color_trans_done(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_io_event_data_t* edata, void* user_ctx) {
|
IRAM_ATTR static bool prv_on_color_trans_done(esp_lcd_panel_io_handle_t io_handle, esp_lcd_panel_io_event_data_t* edata, void* user_ctx) {
|
||||||
BaseType_t need_yield = pdFALSE;
|
BaseType_t need_yield = pdFALSE;
|
||||||
@ -36,7 +36,7 @@ static bool prv_create_display(nb_display_t* display) {
|
|||||||
ESP_LOGI(TAG, "creating display");
|
ESP_LOGI(TAG, "creating display");
|
||||||
|
|
||||||
gpio_config_t io_conf = {
|
gpio_config_t io_conf = {
|
||||||
.pin_bit_mask = BIT64(PIN_BACKLIGHT),
|
.pin_bit_mask = BIT64(LCD_PIN_BACKLIGHT),
|
||||||
.mode = GPIO_MODE_OUTPUT,
|
.mode = GPIO_MODE_OUTPUT,
|
||||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||||
@ -44,25 +44,26 @@ static bool prv_create_display(nb_display_t* display) {
|
|||||||
};
|
};
|
||||||
gpio_config(&io_conf);
|
gpio_config(&io_conf);
|
||||||
|
|
||||||
|
size_t draw_buffer_size = LCD_HORIZONTAL_RESOLUTION * LCD_DRAW_BUFFER_HEIGHT * (LCD_BITS_PER_PIXEL / 8);
|
||||||
const spi_bus_config_t bus_config = ILI9341_PANEL_BUS_SPI_CONFIG(
|
const spi_bus_config_t bus_config = ILI9341_PANEL_BUS_SPI_CONFIG(
|
||||||
PIN_SCLK,
|
LCD_PIN_SCLK,
|
||||||
PIN_MOSI,
|
LCD_PIN_MOSI,
|
||||||
HORIZONTAL_RESOLUTION * DRAW_BUFFER_HEIGHT * (BITS_PER_PIXEL / 8)
|
draw_buffer_size
|
||||||
);
|
);
|
||||||
|
|
||||||
if (spi_bus_initialize(SELECTED_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
|
if (spi_bus_initialize(LCD_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
|
||||||
ESP_LOGD(TAG, "spi bus init failed");
|
ESP_LOGD(TAG, "spi bus init failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG(
|
const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG(
|
||||||
PIN_CS,
|
LCD_PIN_CS,
|
||||||
PIN_DC,
|
LCD_PIN_DC,
|
||||||
prv_on_color_trans_done,
|
prv_on_color_trans_done,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)SELECTED_SPI_HOST, &panel_io_config, &display->io_handle) != ESP_OK) {
|
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)LCD_SPI_HOST, &panel_io_config, &display->io_handle) != ESP_OK) {
|
||||||
ESP_LOGD(TAG, "failed to create panel");
|
ESP_LOGD(TAG, "failed to create panel");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -71,8 +72,9 @@ static bool prv_create_display(nb_display_t* display) {
|
|||||||
const esp_lcd_panel_dev_config_t panel_config = {
|
const esp_lcd_panel_dev_config_t panel_config = {
|
||||||
.reset_gpio_num = GPIO_NUM_NC,
|
.reset_gpio_num = GPIO_NUM_NC,
|
||||||
.rgb_endian = LCD_RGB_ENDIAN_RGB,
|
.rgb_endian = LCD_RGB_ENDIAN_RGB,
|
||||||
.bits_per_pixel = BITS_PER_PIXEL,
|
.bits_per_pixel = LCD_BITS_PER_PIXEL,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (esp_lcd_new_panel_ili9341(display->io_handle, &panel_config, &display->display_handle) != ESP_OK) {
|
if (esp_lcd_new_panel_ili9341(display->io_handle, &panel_config, &display->display_handle) != ESP_OK) {
|
||||||
ESP_LOGD(TAG, "failed to create ili9341");
|
ESP_LOGD(TAG, "failed to create ili9341");
|
||||||
return false;
|
return false;
|
||||||
@ -91,6 +93,14 @@ static bool prv_create_display(nb_display_t* display) {
|
|||||||
|
|
||||||
if (esp_lcd_panel_mirror(display->display_handle, true, false) != ESP_OK) {
|
if (esp_lcd_panel_mirror(display->display_handle, true, false) != ESP_OK) {
|
||||||
ESP_LOGD(TAG, "failed to set panel to mirror");
|
ESP_LOGD(TAG, "failed to set panel to mirror");
|
||||||
|
display->mirror_x = true;
|
||||||
|
display->mirror_y = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (esp_lcd_panel_swap_xy(display->display_handle, false) != ESP_OK) {
|
||||||
|
ESP_LOGD(TAG, "failed to set panel xy swap");
|
||||||
|
display->swap_xy = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,17 +109,15 @@ static bool prv_create_display(nb_display_t* display) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpio_set_level(PIN_BACKLIGHT, 1) != ESP_OK) {
|
if (gpio_set_level(LCD_PIN_BACKLIGHT, 1) != ESP_OK) {
|
||||||
ESP_LOGD(TAG, "failed to turn backlight on");
|
ESP_LOGD(TAG, "failed to turn backlight on");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
display->horizontal_resolution = HORIZONTAL_RESOLUTION;
|
display->horizontal_resolution = LCD_HORIZONTAL_RESOLUTION;
|
||||||
display->vertical_resolution = VERTICAL_RESOLUTION;
|
display->vertical_resolution = LCD_VERTICAL_RESOLUTION;
|
||||||
display->draw_buffer_height = DRAW_BUFFER_HEIGHT;
|
display->draw_buffer_height = LCD_DRAW_BUFFER_HEIGHT;
|
||||||
display->bits_per_pixel = BITS_PER_PIXEL;
|
display->bits_per_pixel = LCD_BITS_PER_PIXEL;
|
||||||
display->mirror_x = true;
|
|
||||||
display->mirror_y = false;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
// File originated from Flipper Zero / Furi
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <m-core.h>
|
#include <m-core.h>
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
idf_component_register(
|
idf_component_register(
|
||||||
SRC_DIRS "src"
|
SRC_DIRS "src"
|
||||||
"src/applications"
|
"src/applications"
|
||||||
"src/applications/main/system_info"
|
"src/applications/system/system_info"
|
||||||
"src/applications/services/desktop"
|
"src/applications/services/desktop"
|
||||||
"src/applications/services/loader"
|
"src/applications/services/loader"
|
||||||
"src/applications/services/gui"
|
"src/applications/services/gui"
|
||||||
INCLUDE_DIRS "inc"
|
INCLUDE_DIRS "src"
|
||||||
PRIV_INCLUDE_DIRS "src"
|
|
||||||
REQUIRES esp_lvgl_port esp_lcd esp_lcd_touch driver mlib cmsis_core furi
|
REQUIRES esp_lvgl_port esp_lcd esp_lcd_touch driver mlib cmsis_core furi
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,9 +1,100 @@
|
|||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "core_defines.h"
|
#include "core_defines.h"
|
||||||
#include "check.h"
|
#include <record.h>
|
||||||
|
#include <mutex.h>
|
||||||
|
#include <check.h>
|
||||||
|
#include <m-dict.h>
|
||||||
|
#include <m-core.h>
|
||||||
|
|
||||||
|
typedef struct screen screen_t;
|
||||||
|
struct screen {
|
||||||
|
screen_id_t id;
|
||||||
|
lv_obj_t* parent;
|
||||||
|
on_init_lvgl _Nonnull callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
static screen_id_t screen_counter = 0;
|
||||||
|
|
||||||
|
DICT_DEF2(screen_dict, screen_id_t, M_BASIC_OPLIST, screen_t, M_POD_OPLIST)
|
||||||
|
|
||||||
|
typedef struct Gui Gui;
|
||||||
|
struct Gui {
|
||||||
|
// TODO: use mutex
|
||||||
|
FuriMutex* mutex;
|
||||||
|
screen_dict_t screens;
|
||||||
|
};
|
||||||
|
|
||||||
|
Gui* gui_alloc() {
|
||||||
|
Gui* gui = malloc(sizeof(Gui));
|
||||||
|
screen_dict_init(gui->screens);
|
||||||
|
gui->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||||
|
return gui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_free(Gui* gui) {
|
||||||
|
screen_dict_clear(gui->screens);
|
||||||
|
furi_mutex_free(gui->mutex);
|
||||||
|
free(gui);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_lock(Gui* gui) {
|
||||||
|
furi_assert(gui);
|
||||||
|
furi_check(furi_mutex_acquire(gui->mutex, FuriWaitForever) == FuriStatusOk);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_unlock(Gui* gui) {
|
||||||
|
furi_assert(gui);
|
||||||
|
furi_check(furi_mutex_release(gui->mutex) == FuriStatusOk);
|
||||||
|
}
|
||||||
|
|
||||||
|
screen_id_t gui_screen_create(Gui* gui, on_init_lvgl callback) {
|
||||||
|
screen_id_t id = screen_counter++;
|
||||||
|
screen_t screen = {
|
||||||
|
.id = id,
|
||||||
|
.parent = NULL,
|
||||||
|
.callback = callback
|
||||||
|
};
|
||||||
|
|
||||||
|
screen_dict_set_at(gui->screens, id, screen);
|
||||||
|
|
||||||
|
// TODO: notify desktop of change
|
||||||
|
// TODO: have desktop update views
|
||||||
|
lv_obj_t* parent = lv_scr_act();
|
||||||
|
gui_screen_set_parent(gui, id, parent);
|
||||||
|
|
||||||
|
// TODO: call from desktop
|
||||||
|
screen.callback(gui_screen_get_parent(gui, id), id);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
lv_obj_t* gui_screen_get_parent(Gui* gui, screen_id_t id) {
|
||||||
|
screen_t* screen = screen_dict_get(gui->screens, id);
|
||||||
|
furi_check(screen != NULL);
|
||||||
|
return screen->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_screen_set_parent(Gui* gui, screen_id_t id, lv_obj_t* parent) {
|
||||||
|
screen_t* screen = screen_dict_get(gui->screens, id);
|
||||||
|
furi_check(screen != NULL);
|
||||||
|
screen->parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gui_screen_free(Gui* gui, screen_id_t id) {
|
||||||
|
screen_t* screen = screen_dict_get(gui->screens, id);
|
||||||
|
furi_check(screen != NULL);
|
||||||
|
|
||||||
|
// TODO: notify? use callback? (done from desktop service)
|
||||||
|
lv_obj_clean(screen->parent);
|
||||||
|
|
||||||
|
screen_dict_erase(gui->screens, id);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t prv_gui_main(void* param) {
|
static int32_t prv_gui_main(void* param) {
|
||||||
UNUSED(param);
|
UNUSED(param);
|
||||||
|
|
||||||
|
Gui* gui = gui_alloc();
|
||||||
|
furi_record_create(RECORD_GUI, gui);
|
||||||
printf("gui app init\n");
|
printf("gui app init\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,19 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define RECORD_GUI "gui"
|
||||||
|
|
||||||
|
typedef uint16_t screen_id_t;
|
||||||
|
|
||||||
|
typedef struct Gui Gui;
|
||||||
|
typedef void (*on_init_lvgl)(lv_obj_t*, screen_id_t);
|
||||||
|
|
||||||
|
screen_id_t gui_screen_create(Gui* gui, on_init_lvgl callback);
|
||||||
|
void gui_screen_free(Gui* gui, screen_id_t id);
|
||||||
|
// TODO make internal
|
||||||
|
void gui_screen_set_parent(Gui* gui, screen_id_t id, lv_obj_t* parent);
|
||||||
|
lv_obj_t* gui_screen_get_parent(Gui* gui, screen_id_t id);
|
||||||
|
|
||||||
extern const nb_app_t gui_app;
|
extern const nb_app_t gui_app;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@ -58,7 +58,7 @@ static void prv_start_app(const nb_app_t _Nonnull* app) {
|
|||||||
thread_ids_push_back(prv_thread_ids, thread_id);
|
thread_ids_push_back(prv_thread_ids, thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void nanobake_start(nb_config_t _Nonnull* config) {
|
__attribute__((unused)) extern void nanobake_start(nb_config_t _Nonnull* config) {
|
||||||
prv_furi_init();
|
prv_furi_init();
|
||||||
|
|
||||||
nb_hardware_t hardware = nb_hardware_create(config);
|
nb_hardware_t hardware = nb_hardware_create(config);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ extern "C" {
|
|||||||
typedef void* FuriThreadId;
|
typedef void* FuriThreadId;
|
||||||
typedef struct nb_lvgl nb_lvgl_t;
|
typedef struct nb_lvgl nb_lvgl_t;
|
||||||
|
|
||||||
extern void nanobake_start(nb_config_t _Nonnull * config);
|
__attribute__((unused)) extern void nanobake_start(nb_config_t _Nonnull * config);
|
||||||
|
|
||||||
extern FuriThreadId nanobake_get_app_thread_id(size_t index);
|
extern FuriThreadId nanobake_get_app_thread_id(size_t index);
|
||||||
extern size_t nanobake_get_app_thread_count();
|
extern size_t nanobake_get_app_thread_count();
|
||||||
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
nb_display_t _Nonnull* nb_display_alloc(nb_display_driver_t _Nonnull* driver) {
|
nb_display_t _Nonnull* nb_display_alloc(nb_display_driver_t _Nonnull* driver) {
|
||||||
nb_display_t _Nonnull* display = malloc(sizeof(nb_display_t));
|
nb_display_t _Nonnull* display = malloc(sizeof(nb_display_t));
|
||||||
|
memset(display, 0, sizeof(nb_display_t));
|
||||||
furi_check(driver->create_display(display), "failed to create display");
|
furi_check(driver->create_display(display), "failed to create display");
|
||||||
|
furi_check(display->io_handle != NULL);
|
||||||
|
furi_check(display->display_handle != NULL);
|
||||||
|
furi_check(display->horizontal_resolution != 0);
|
||||||
|
furi_check(display->vertical_resolution != 0);
|
||||||
|
furi_check(display->draw_buffer_height > 0);
|
||||||
|
furi_check(display->bits_per_pixel > 0);
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ struct nb_display {
|
|||||||
esp_lcd_panel_handle_t _Nonnull display_handle;
|
esp_lcd_panel_handle_t _Nonnull display_handle;
|
||||||
bool mirror_x;
|
bool mirror_x;
|
||||||
bool mirror_y;
|
bool mirror_y;
|
||||||
|
bool swap_xy;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct nb_display_driver nb_display_driver_t;
|
typedef struct nb_display_driver nb_display_driver_t;
|
||||||
@ -28,7 +28,7 @@ nb_lvgl_t nb_lvgl_init(nb_hardware_t _Nonnull* hardware) {
|
|||||||
.vres = display->vertical_resolution,
|
.vres = display->vertical_resolution,
|
||||||
.monochrome = false,
|
.monochrome = false,
|
||||||
.rotation = {
|
.rotation = {
|
||||||
.swap_xy = false,
|
.swap_xy = display->swap_xy,
|
||||||
.mirror_x = display->mirror_x,
|
.mirror_x = display->mirror_x,
|
||||||
.mirror_y = display->mirror_y,
|
.mirror_y = display->mirror_y,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,37 +1,62 @@
|
|||||||
#include "hello_world.h"
|
#include "hello_world.h"
|
||||||
#include <core_defines.h>
|
#include <core_defines.h>
|
||||||
|
#include <record.h>
|
||||||
#include <nb_lvgl.h>
|
#include <nb_lvgl.h>
|
||||||
|
#include <nb_hardware.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>
|
||||||
#include <nb_hardware.h>
|
|
||||||
|
|
||||||
static const char* TAG = "app_helloworld";
|
static const char* TAG = "app_helloworld";
|
||||||
|
|
||||||
static void prv_on_button_click(lv_event_t _Nonnull* event) {
|
static void prv_on_button_click(lv_event_t _Nonnull* event) {
|
||||||
ESP_LOGI(TAG, "button clicked");
|
ESP_LOGI(TAG, "button clicked");
|
||||||
|
// Open Gui record
|
||||||
|
Gui* gui = furi_record_open(RECORD_GUI);
|
||||||
|
|
||||||
|
// Free this screen
|
||||||
|
screen_id_t screen_id = (screen_id_t)event->user_data;
|
||||||
|
gui_screen_free(gui, screen_id);
|
||||||
|
|
||||||
|
// Close Gui record
|
||||||
|
furi_record_close(RECORD_GUI);
|
||||||
|
gui = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t prv_on_create(void* param) {
|
static void prv_hello_world_lvgl(lv_obj_t* parent, screen_id_t screen_id) {
|
||||||
UNUSED(param);
|
|
||||||
lvgl_port_lock(0);
|
lvgl_port_lock(0);
|
||||||
|
|
||||||
lv_obj_t* lv_parent = lv_scr_act();
|
lv_obj_t* label = lv_label_create(parent);
|
||||||
|
|
||||||
lv_obj_t* label = lv_label_create(lv_parent);
|
|
||||||
lv_label_set_recolor(label, true);
|
lv_label_set_recolor(label, true);
|
||||||
lv_obj_set_width(label, 200);
|
lv_obj_set_width(label, 200);
|
||||||
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
|
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
|
||||||
lv_label_set_text(label, "Hello, world!");
|
lv_label_set_text(label, "Hello, world!");
|
||||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, -30);
|
lv_obj_align(label, LV_ALIGN_CENTER, 0, -30);
|
||||||
|
|
||||||
lv_obj_t* btn = lv_btn_create(lv_parent);
|
lv_obj_t* btn = lv_btn_create(parent);
|
||||||
label = lv_label_create(btn);
|
label = lv_label_create(btn);
|
||||||
lv_label_set_text_static(label, "Button");
|
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, prv_on_button_click, LV_EVENT_CLICKED, (void*)screen_id);
|
||||||
|
|
||||||
lvgl_port_unlock();
|
lvgl_port_unlock();
|
||||||
|
|
||||||
|
// TODO: on app exit, call gui_screen_destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
static int32_t prv_hello_world_main(void* param) {
|
||||||
|
UNUSED(param);
|
||||||
|
|
||||||
|
// Open Gui record
|
||||||
|
Gui* gui = furi_record_open(RECORD_GUI);
|
||||||
|
|
||||||
|
// Register an lvgl screen
|
||||||
|
gui_screen_create(gui, &prv_hello_world_lvgl);
|
||||||
|
|
||||||
|
// Close Gui record
|
||||||
|
furi_record_close(RECORD_GUI);
|
||||||
|
gui = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +64,7 @@ const nb_app_t hello_world_app = {
|
|||||||
.id = "helloworld",
|
.id = "helloworld",
|
||||||
.name = "Hello World",
|
.name = "Hello World",
|
||||||
.type = USER,
|
.type = USER,
|
||||||
.entry_point = &prv_on_create,
|
.entry_point = &prv_hello_world_main,
|
||||||
.stack_size = 2048,
|
.stack_size = 2048,
|
||||||
.priority = 10
|
.priority = 10
|
||||||
};
|
};
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
// Apps
|
// Apps
|
||||||
#include "hello_world/hello_world.h"
|
#include "hello_world/hello_world.h"
|
||||||
|
|
||||||
void app_main(void) {
|
__attribute__((unused)) void app_main(void) {
|
||||||
static nb_config_t config = {
|
static nb_config_t config = {
|
||||||
.display_driver = &board_2432s024_create_display_driver,
|
.display_driver = &board_2432s024_create_display_driver,
|
||||||
.touch_driver = &board_2432s024_create_touch_driver,
|
.touch_driver = &board_2432s024_create_touch_driver,
|
||||||
|
|||||||
4
sdkconfig.defaults
Normal file
4
sdkconfig.defaults
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
CONFIG_IDF_TARGET="esp32"
|
||||||
|
CONFIG_LV_COLOR_16_SWAP=y
|
||||||
|
CONFIG_LV_USE_USER_DATA=y
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user