Created
September 12, 2024 20:48
-
-
Save adrenalinehit/aaf6f78a01cb555e23e751d40a754724 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @file lv_images.ino | |
* @author Lewis He ([email protected]) | |
* @license MIT | |
* @copyright Copyright (c) 2024 Shenzhen Xin Yuan Electronic Technology Co., Ltd | |
* @date 2024-01-22 | |
* @note Place the images file in the data directory into the SD card | |
*/ | |
#include <LilyGo_RGBPanel.h> | |
#include <LV_Helper.h> | |
#if !LV_USE_PNG || !LV_USE_BMP || !LV_USE_SJPG | |
#error "lvgl png , bmp , sjpg decoder library is not enable!" | |
#endif | |
LilyGo_RGBPanel panel; | |
const char *filename[] = { | |
"my_beer_1.jpg", "my_other_beer.jpg", "some_scrummy_cider.jpg", | |
}; | |
void setup() | |
{ | |
Serial.begin(115200); | |
// Initialize T-RGB, if the initialization fails, false will be returned. | |
if (!panel.begin()) { | |
while (1) { | |
Serial.println("Error, failed to initialize T-RGB"); delay(1000); | |
} | |
} | |
// Initialize SD Card | |
if (!panel.installSD()) { | |
Serial.println("Can't install SD Card!"); | |
} | |
// Call lvgl initialization | |
beginLvglHelper(panel); | |
lv_obj_t *img = lv_img_create(lv_scr_act()); | |
lv_obj_center(img); | |
lv_timer_create([](lv_timer_t *t) { | |
// String path = LV_FS_POSIX_LETTER + String(":/image_") + filename[i]; | |
String path = lvgl_helper_get_fs_filename(filename[0]); | |
// ...or... | |
String path = lvgl_helper_get_fs_filename(filename[1]); | |
// ....or..... | |
String path = lvgl_helper_get_fs_filename(filename[2]); | |
//...etc.... | |
//or use a random number between 0 and the length of the array to pick a random image each time. | |
Serial.print("open : "); | |
Serial.println(path); | |
lv_img_set_src((lv_obj_t *)t->user_data, path.c_str()); | |
}, 5000, img); | |
panel.setBrightness(16); | |
} | |
void loop() | |
{ | |
lv_timer_handler(); | |
delay(2); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment