while(1) { /* Periodically call the lv_task handler. * It could be done in a timer interrupt or an OS task too.*/ lv_timer_handler(); usleep(5 * 1000); }
return0; }
staticvoidhal_init(void) { /* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/ sdl_init();
lv_group_t * g = lv_group_create(); lv_group_set_default(g);
/* Add the mouse as input device * Use the 'mouse' driver which reads the PC's mouse*/ staticlv_indev_drv_t indev_drv_1; lv_indev_drv_init(&indev_drv_1); /*Basic initialization*/ indev_drv_1.type = LV_INDEV_TYPE_POINTER;
/*This function will be called periodically (by the library) to get the mouse position and state*/ indev_drv_1.read_cb = sdl_mouse_read; lv_indev_t *mouse_indev = lv_indev_drv_register(&indev_drv_1);
/*Set a cursor for the mouse*/ LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/ lv_obj_t * cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */ lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/ lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/ }