#include /* INCLUDE THE CONF FILES FIRST! THEY SET UP DEFINES AND SYSTEM SETTINGS! */ #include "lv_conf.h" #include "lv_drv_conf.h" #include #include "lvgl/lvgl.h" #include "lvgl/lv_hal/lv_hal_indev.h" bool g_app_quit_qry = false; /*set to notify app it needs to exit*/ #if USE_FBDEV #include "hal_init_fbdev.cc" #elif USE_SDL2 #include "hal_init_SDL2.cc" #elif USE_BRONEX #include "hal_init_bronex.cc" #else #warning "NO HARDWARE IMPLEMENTATION SELECTED in lv_drv_conf! (e.g. USE_FBDEV)" #endif #include "lodepng.h" #include "lvgl/lv_draw/lv_draw_img.h" #include "decoder.cc" /** * Test PNG functionality */ static void test_png(const char * fname) { /*Create an image object and set the decoded PNG image as it's source*/ lv_obj_t * img_obj = lv_img_create(lv_scr_act(), NULL); /*Create the an image object in LittlevGL*/ lv_img_set_src(img_obj, fname); /*Set the image source to the decoded PNG*/ lv_obj_set_pos(img_obj, 50, 50); // lv_obj_set_drag(img_obj, true); /*Make to image dragable*/ /*Set a non-white background color for the scren to see the alpha is working on the image*/ lv_style_scr.body.main_color = LV_COLOR_MAKE(0x40, 0x70, 0xAA); } int main(int argc, char ** argv) { if(argc != 2) { printf("USAGE: %s \n", argv[0]); return 0; } /*Initialize LittlevGL*/ lv_init(); /*Initialize the HAL for LittlevGL*/ hal_init(); /*Load a demo*/ //demo_create(); /*Or try the benchmark too to see the speed of your MCU*/ //benchmark_create(); /*Or try a theme (Enable the theme in lv_conf.h with USE_LV_THEME_... 1 )*/ //lv_theme_t * th = lv_theme_night_init(210, NULL); /*Hue: 210; Font: NULL (default)*/ //lv_test_theme_1(th); /*Or try a tutorial (Enable USE_LV_TUTORIALS in lv_ex_conf.h)*/ //lv_tutorial_keyboard(); lv_img_decoder_set_custom(png_decoder_info, png_decoder_open, NULL, png_decoder_close); test_png( argv[1] ); while(!g_app_quit_qry) { /* Periodically call the lv_task handler. * It could be done in a timer interrupt or an OS task too.*/ lv_task_handler(); usleep(10000); /*Just to let the system breathe*/ } hal_deinit(); return 0; }