diff --git a/main/main.cpp b/main/main.cpp index cf5435a..2367e0d 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -42,9 +42,6 @@ void init_queues( EventGroupHandle_t& system_lifecycle_event_group ); - - - void app_main(void) { display_chip_info(); @@ -60,14 +57,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( - // std::unique_ptr(new NVSStorageHandler(WIFI_CREDENTIALS_STORAGE_NAMESPACE)) - // ); - // NetworkHandler* network_handler = new NetworkHandler(std::move(wifi_handler)); + auto wifi_handler = std::make_unique( + std::unique_ptr(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); @@ -84,8 +81,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"); @@ -100,63 +97,73 @@ void app_main(void) { ); ESP_LOGI(TAG, "System is ready. Starting main application...\n"); + DiscordAppDescriptor::instance(); + UIHandler ui_handler; + err = ui_handler.init(); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to initialize UI handler: %s", esp_err_to_name(err)); + vTaskDelay(5000 / portTICK_PERIOD_MS); + return esp_restart(); + } + ESP_LOGI(TAG, "UI handler initialized.\n"); + // Allow LVGL system to stabilize before creating objects vTaskDelay(pdMS_TO_TICKS(100)); // Create main screen and button for random rectangle demo - lv_obj_t* scr = lv_scr_act(); + // lv_obj_t* scr = lv_scr_act(); - // Create a button - lv_obj_t* btn = lv_btn_create(scr); - lv_obj_set_size(btn, 200, 60); - lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, 20); - lv_obj_set_style_border_width(btn, 2, 0); - lv_obj_set_style_border_color(btn, lv_color_make(0, 0, 0), 0); + // // Create a button + // lv_obj_t* btn = lv_btn_create(scr); + // lv_obj_set_size(btn, 200, 60); + // lv_obj_align(btn, LV_ALIGN_TOP_MID, 0, 20); + // lv_obj_set_style_border_width(btn, 2, 0); + // lv_obj_set_style_border_color(btn, lv_color_make(0, 0, 0), 0); - // Add label to button - lv_obj_t* label = lv_label_create(btn); - lv_label_set_text(label, "Create Random Rect"); - lv_obj_center(label); - lv_obj_set_style_text_color(label, lv_color_make(0, 0, 0), 0); + // // Add label to button + // lv_obj_t* label = lv_label_create(btn); + // lv_label_set_text(label, "Create Random Rect"); + // lv_obj_center(label); + // lv_obj_set_style_text_color(label, lv_color_make(0, 0, 0), 0); - // Event handler for button - creates random rectangles - auto btn_event_cb = [](lv_event_t* e) { - lv_obj_t* scr = lv_scr_act(); + // // Event handler for button - creates random rectangles + // auto btn_event_cb = [](lv_event_t* e) { + // lv_obj_t* scr = lv_scr_act(); - // Create a random rectangle - lv_obj_t* rect = lv_obj_create(scr); + // // Create a random rectangle + // lv_obj_t* rect = lv_obj_create(scr); - // Random size (30-100 pixels) - lv_coord_t width = 30 + (esp_random() % 70); - lv_coord_t height = 30 + (esp_random() % 70); - lv_obj_set_size(rect, width, height); + // // Random size (30-100 pixels) + // lv_coord_t width = 30 + (esp_random() % 70); + // lv_coord_t height = 30 + (esp_random() % 70); + // lv_obj_set_size(rect, width, height); - // Random position (avoid top 100px where button is) - lv_coord_t x = esp_random() % (LV_HOR_RES - width); - lv_coord_t y = 100 + (esp_random() % (LV_VER_RES - 100 - height)); - lv_obj_set_pos(rect, x, y); + // // Random position (avoid top 100px where button is) + // lv_coord_t x = esp_random() % (LV_HOR_RES - width); + // lv_coord_t y = 100 + (esp_random() % (LV_VER_RES - 100 - height)); + // lv_obj_set_pos(rect, x, y); - lv_obj_set_style_bg_color(rect, lv_color_make(0, 0, 0), 0); - lv_obj_set_style_bg_opa(rect, LV_OPA_COVER, 0); + // lv_obj_set_style_bg_color(rect, lv_color_make(0, 0, 0), 0); + // lv_obj_set_style_bg_opa(rect, LV_OPA_COVER, 0); - // Make rectangle clickable - lv_obj_add_flag(rect, LV_OBJ_FLAG_CLICKABLE); + // // Make rectangle clickable + // lv_obj_add_flag(rect, LV_OBJ_FLAG_CLICKABLE); - // Event handler to delete rectangle when clicked - auto rect_event_cb = [](lv_event_t* e) { - lv_obj_t* rect = static_cast(lv_event_get_target(e)); - lv_obj_del(rect); - ESP_LOGI(TAG, "Rectangle deleted"); - }; + // // Event handler to delete rectangle when clicked + // auto rect_event_cb = [](lv_event_t* e) { + // lv_obj_t* rect = static_cast(lv_event_get_target(e)); + // lv_obj_del(rect); + // ESP_LOGI(TAG, "Rectangle deleted"); + // }; - lv_obj_add_event_cb(rect, rect_event_cb, LV_EVENT_CLICKED, NULL); + // lv_obj_add_event_cb(rect, rect_event_cb, LV_EVENT_CLICKED, NULL); - ESP_LOGI(TAG, "Created rectangle at (%d, %d) with size %dx%d", x, y, width, height); - }; + // ESP_LOGI(TAG, "Created rectangle at (%d, %d) with size %dx%d", x, y, width, height); + // }; - lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); + // lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); - ESP_LOGI(TAG, "Random rectangle demo initialized. Tap button to create rectangles.\n"); + // ESP_LOGI(TAG, "Random rectangle demo initialized. Tap button to create rectangles.\n"); // wait for shutdown signal ESP_LOGI(TAG, "Waiting for shutdown signal...\n");