#include "apps/shutdown_app.h" #include "esp_log.h" #define TAG "ShutdownApp" ShutdownApp::ShutdownApp(std::string message) : _message(message.empty() ? "System Shutting Down..." : message) { } esp_err_t ShutdownApp::init(lv_obj_t* container) { if (!container) { ESP_LOGE(TAG, "Container is null"); return ESP_ERR_INVALID_ARG; } _container = container; ESP_LOGI(TAG, "Initializing shutdown app with message: %s", _message.c_str()); // Main message label _label_message = lv_label_create(_container); lv_label_set_text(_label_message, _message.c_str()); lv_obj_set_style_text_color(_label_message, lv_color_white(), 0); lv_obj_align(_label_message, LV_ALIGN_CENTER, 0, 0); // Optional: Add spinner animation lv_obj_t* spinner = lv_spinner_create(_container); lv_obj_set_size(spinner, 80, 80); lv_obj_align(spinner, LV_ALIGN_CENTER, 0, 80); lv_obj_set_style_arc_color(spinner, lv_color_white(), LV_PART_INDICATOR); ESP_LOGI(TAG, "Shutdown app initialized successfully"); return ESP_OK; } esp_err_t ShutdownApp::deinit(void) { ESP_LOGI(TAG, "Deinitializing shutdown app"); _label_message = nullptr; return ESP_OK; } std::string ShutdownApp::get_name(void) const { return "Shutdown"; } // ShutdownAppDescriptor implementation ShutdownApp* ShutdownAppDescriptor::_app_instance = nullptr; ShutdownAppDescriptor::ShutdownAppDescriptor() : AppDescriptor("Shutdown", nullptr) { // Create singleton app instance with default message if (!_app_instance) { _app_instance = new ShutdownApp(); } // it's only used during system shutdown, not as a user-launchable app } void ShutdownAppDescriptor::draw_icon(lv_obj_t* parent) { // Create a simple icon (not normally shown in nav bar) lv_obj_t* icon_label = lv_label_create(parent); lv_label_set_text(icon_label, LV_SYMBOL_POWER "\nShutdown"); lv_obj_set_style_text_color(icon_label, lv_color_white(), 0); lv_obj_set_style_text_align(icon_label, LV_TEXT_ALIGN_CENTER, 0); lv_obj_center(icon_label); }