Refactor draw buffer handling
This commit is contained in:
@@ -44,6 +44,40 @@ void init_queues(
|
||||
|
||||
|
||||
|
||||
void random_draw_rect(
|
||||
LVGLHandler* lvgl_handler
|
||||
) {
|
||||
// Draw a random rectangle on the display using LVGL every 2 seconds until 100 rectangles have been drawn
|
||||
static int rect_count = 0;
|
||||
do {
|
||||
|
||||
rect_count++;
|
||||
LVGLHandler* handler = lvgl_handler;
|
||||
if (handler == nullptr) {
|
||||
return;
|
||||
}
|
||||
lvgl_port_lock(pdMS_TO_TICKS(5000));
|
||||
// Create a random rectangle
|
||||
lv_obj_t* rect = lv_obj_create(lv_scr_act());
|
||||
int x = esp_random() % (DISPLAY_WIDTH - 50);
|
||||
int y = esp_random() % (DISPLAY_HEIGHT - 50);
|
||||
lv_obj_set_pos(rect, x, y);
|
||||
int w = 20 + (esp_random() % 100);
|
||||
int h = 20 + (esp_random() % 100);
|
||||
lv_obj_set_size(rect, w, h);
|
||||
// white or black fill for the rect
|
||||
bool is_white = (esp_random() % 2 == 0);
|
||||
lv_obj_set_style_bg_color(rect, is_white ? lv_color_hex(0xFFFFFF) : lv_color_hex(0x000000), 0);
|
||||
|
||||
lvgl_port_unlock();
|
||||
ESP_LOGI(TAG, "Drawn %s rectangle %d at (%d,%d) size (%d x %d)",
|
||||
is_white ? "white" : "black",
|
||||
rect_count, x, y, w, h);
|
||||
// Schedule next rectangle draw
|
||||
vTaskDelay(pdMS_TO_TICKS(2000));
|
||||
} while (rect_count < 100);
|
||||
}
|
||||
|
||||
void EInk_Checkerboard(
|
||||
EInkDisplayHandler* display_handler
|
||||
) {
|
||||
@@ -231,7 +265,7 @@ void LVGL_Checkerboard(
|
||||
}
|
||||
lvgl_port_unlock();
|
||||
// Yield to allow LVGL to process rendering
|
||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +278,7 @@ void LVGL_Checkerboard(
|
||||
checker_params->lvgl_handler = lvgl_handler;
|
||||
BaseType_t res = xTaskCreate(
|
||||
checkerboard_task_fn,
|
||||
"lvgl_checkerboard_task",
|
||||
"lvgl_checkerboard_task0",
|
||||
8192,
|
||||
static_cast<void*>(checker_params),
|
||||
tskIDLE_PRIORITY + 1,
|
||||
@@ -272,14 +306,14 @@ void app_main(void) {
|
||||
ESP_LOGI(TAG, "Queues initialized.\n");
|
||||
|
||||
//
|
||||
// KVStorageHandler* kv_storage_handler = new NVSStorageHandler(
|
||||
// DEFAULT_STORAGE_NAMESPACE
|
||||
// );
|
||||
KVStorageHandler* kv_storage_handler = new NVSStorageHandler(
|
||||
DEFAULT_STORAGE_NAMESPACE
|
||||
);
|
||||
|
||||
// auto wifi_handler = std::make_unique<WifiHandler>(
|
||||
// std::unique_ptr<KVStorageHandler>(new NVSStorageHandler(WIFI_CREDENTIALS_STORAGE_NAMESPACE))
|
||||
// );
|
||||
// NetworkHandler* network_handler = new NetworkHandler(std::move(wifi_handler));
|
||||
auto wifi_handler = std::make_unique<WifiHandler>(
|
||||
std::unique_ptr<KVStorageHandler>(new NVSStorageHandler(WIFI_CREDENTIALS_STORAGE_NAMESPACE))
|
||||
);
|
||||
NetworkHandler* network_handler = new NetworkHandler(std::move(wifi_handler));
|
||||
EInkDisplayHandler* display_handler = new EInkDisplayHandler();
|
||||
// Initialize display and touch
|
||||
// display_handler->init_devices(system_event_group);
|
||||
@@ -296,8 +330,8 @@ void app_main(void) {
|
||||
}
|
||||
|
||||
//
|
||||
// kv_storage_handler->init(system_event_group);
|
||||
// network_handler->init(system_event_group);
|
||||
kv_storage_handler->init(system_event_group);
|
||||
network_handler->init(system_event_group);
|
||||
|
||||
//
|
||||
ESP_LOGI(TAG, "Waiting for system to be ready...\n");
|
||||
@@ -317,13 +351,13 @@ void app_main(void) {
|
||||
|
||||
// Show checkerboard pattern on display for testing
|
||||
// EInk_Checkerboard(display_handler);
|
||||
LVGL_Checkerboard(&lvgl_handler);
|
||||
// LVGL_Checkerboard(&lvgl_handler);
|
||||
|
||||
// Register apps with AppRegistry by creating their descriptors
|
||||
// Each descriptor will create and register the app instance
|
||||
// DemoAppDescriptor* demo_descriptor = new DemoAppDescriptor();
|
||||
// ShutdownAppDescriptor* shutdown_descriptor = new ShutdownAppDescriptor();
|
||||
// DiscordAppDescriptor::instance(); // Use singleton pattern for Discord app
|
||||
DiscordAppDescriptor::instance(); // Use singleton pattern for Discord app
|
||||
// MtrAppDescriptor* mtr_descriptor = new MtrAppDescriptor();
|
||||
|
||||
// Pass network handler to MtrApp so it can fetch arrival data
|
||||
@@ -332,17 +366,17 @@ void app_main(void) {
|
||||
// mtr_app->set_network_handler(network_handler);
|
||||
// }
|
||||
|
||||
// ESP_LOGI(TAG, "Apps registered with AppRegistry\n");
|
||||
ESP_LOGI(TAG, "Apps registered with AppRegistry\n");
|
||||
|
||||
// Initialize UI Handler (will render app icons from registry)
|
||||
// UIHandler ui_handler;
|
||||
// if (ui_handler.init() != ESP_OK) {
|
||||
// ESP_LOGE(TAG, "Failed to initialize UI handler");
|
||||
// vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||
// return esp_restart();
|
||||
// }
|
||||
// ESP_LOGI(TAG, "UI handler initialized successfully\n");
|
||||
// ESP_LOGI(TAG, "Main screen displayed with app icons. Tap an icon to launch an app.\n");
|
||||
UIHandler ui_handler;
|
||||
if (ui_handler.init() != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to initialize UI handler");
|
||||
vTaskDelay(5000 / portTICK_PERIOD_MS);
|
||||
return esp_restart();
|
||||
}
|
||||
ESP_LOGI(TAG, "UI handler initialized successfully\n");
|
||||
ESP_LOGI(TAG, "Main screen displayed with app icons. Tap an icon to launch an app.\n");
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user