#include #include "jc3636w518.h" #include "perf_monitor.h" #include "SD_MMC.h" void my_print(const char* buf) { Serial.println(buf); // Print logs to the serial monitor } void display_animation() { lv_obj_t* img; img = lv_gif_create(lv_screen_active()); // shown on a plain black screen: no transparency needed, so decode straight into the display's // color format (no alpha blending, no conversion) to save CPU lv_gif_set_color_format(img, lv_display_get_color_format(lv_display_get_default())); Serial.print("Available Heap before: "); Serial.println(esp_get_free_heap_size()); lv_mem_monitor_t mem_mon; lv_mem_monitor(&mem_mon); printf("Free memory: %d bytes\n", mem_mon.free_size); // Load the whole GIF from the SD card into PSRAM once and play it from memory: // no SD access while playing (faster, and kinder to flaky cards) static lv_image_dsc_t gif_dsc; File f = SD_MMC.open("/wallpaper.gif"); size_t size = f ? f.size() : 0; uint8_t* data = size ? (uint8_t*)ps_malloc(size) : NULL; if (data && f.read(data, size) == size) { gif_dsc.header.magic = LV_IMAGE_HEADER_MAGIC; gif_dsc.header.cf = LV_COLOR_FORMAT_RAW; gif_dsc.header.w = data[6] | (data[7] << 8); // GIF logical screen size gif_dsc.header.h = data[8] | (data[9] << 8); gif_dsc.data_size = size; gif_dsc.data = data; lv_gif_set_src(img, &gif_dsc); Serial.printf("GIF loaded into PSRAM: %u bytes, %u x %u\n", size, gif_dsc.header.w, gif_dsc.header.h); } else { Serial.println("Failed to load /wallpaper.gif from the SD card"); free(data); } if (f) f.close(); Serial.print("Available Heap after: "); Serial.println(esp_get_free_heap_size()); lv_mem_monitor(&mem_mon); printf("Free memory: %d bytes\n", mem_mon.free_size); lv_obj_align(img, LV_ALIGN_CENTER, 0, 0); } void display_text() { // Create a style for the text static lv_style_t style_text; lv_style_init(&style_text); // Set the text color to white lv_style_set_text_color(&style_text, lv_color_white()); // // Set the shadow color to black (this will simulate the outline) // lv_style_set_shadow_color(&style_text, lv_color_black()); // // Set the shadow width to create the outline effect // lv_style_set_shadow_width(&style_text, 2); // Adjust for desired outline thickness // // Set the shadow offset to 0 so it surrounds the text evenly // lv_style_set_shadow_ofs_x(&style_text, 0); // lv_style_set_shadow_ofs_y(&style_text, 0); lv_obj_t* label1 = lv_label_create(lv_screen_active()); // Apply the style to the label lv_obj_add_style(label1, &style_text, LV_PART_MAIN); // lv_style_set_text_font(&label1, &LV_FONT_MONTSERRAT_46); /*Set a larger font*/ lv_label_set_long_mode(label1, LV_LABEL_LONG_WRAP); /*Break the long lines*/ lv_label_set_text(label1, "Test text"); lv_obj_set_width(label1, 150); /*Set smaller width to make the lines wrap*/ lv_obj_set_style_text_align(label1, LV_TEXT_ALIGN_CENTER, 0); lv_obj_align(label1, LV_ALIGN_CENTER, 0, 0); } void setup() { delay(200); Serial.begin(115200); lv_display_t* disp = scr_lvgl_init(); perf_monitor_begin(disp); //lv_log_register_print_cb(my_print); // Register print function for LVGL logs // Get the active screen (root object for the display) lv_obj_t* screen = lv_screen_active(); // Set the background color of the entire screen to black lv_obj_set_style_bg_color(screen, lv_color_black(), 0); // 0 is the part ID for the main part lv_obj_set_style_bg_opa(screen, LV_OPA_COVER, 0); // Set opacity to fully opaque // Configure the SDMMC host SD_MMC.setPins(SD_MMC_CLK_PIN, SD_MMC_CMD_PIN, SD_MMC_D0_PIN, SD_MMC_D1_PIN, SD_MMC_D2_PIN, SD_MMC_D3_PIN); if (!SD_MMC.begin()) { Serial.println("Card Mount Failed"); return; } uint8_t cardType = SD_MMC.cardType(); if (cardType == CARD_NONE) { Serial.println("No SD card attached"); return; } Serial.println("SD Card initialized successfully."); display_animation(); //display_text(); } void loop() { perf_timer_handler(); vTaskDelay(1); perf_monitor_print(); }