lv_demo.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-10-17 Meco Man First version
  9. */
  10. #include <rtthread.h>
  11. #include <lvgl.h>
  12. #include <lv_port_indev.h>
  13. #include <lv_demo_calendar.h>
  14. #define DBG_TAG "LVGL.demo"
  15. #define DBG_LVL DBG_INFO
  16. #include <rtdbg.h>
  17. #ifndef LV_THREAD_STACK_SIZE
  18. #define LV_THREAD_STACK_SIZE 4096
  19. #endif
  20. #ifndef LV_THREAD_PRIO
  21. #define LV_THREAD_PRIO (RT_THREAD_PRIORITY_MAX*2/3)
  22. #endif
  23. static void lvgl_thread(void *parameter)
  24. {
  25. /*assign buttons to coordinates*/
  26. const lv_point_t points_array[] = {{200,35},{0,0},{70,35},{0,0}};
  27. lv_indev_set_button_points(button_indev, points_array);
  28. /* display demo; you may replace with your LVGL application at here */
  29. lv_demo_calendar();
  30. /* handle the tasks of LVGL */
  31. while(1)
  32. {
  33. lv_task_handler();
  34. rt_thread_mdelay(10);
  35. }
  36. }
  37. static int lvgl_demo_init(void)
  38. {
  39. rt_thread_t tid;
  40. tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 0);
  41. if(tid == RT_NULL)
  42. {
  43. LOG_E("Fail to create 'LVGL' thread");
  44. }
  45. rt_thread_startup(tid);
  46. return 0;
  47. }
  48. INIT_APP_EXPORT(lvgl_demo_init);