lv_demo.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifdef PKG_USING_LV_MUSIC_DEMO
  30. extern void lv_demo_music(void);
  31. lv_demo_music();
  32. #else
  33. lv_demo_calendar();
  34. #endif
  35. /* handle the tasks of LVGL */
  36. while(1)
  37. {
  38. lv_task_handler();
  39. rt_thread_mdelay(10);
  40. }
  41. }
  42. static int lvgl_demo_init(void)
  43. {
  44. rt_thread_t tid;
  45. rt_device_t lcd = RT_NULL;
  46. lcd = rt_device_find("lcd");
  47. rt_device_init(lcd);
  48. tid = rt_thread_create("LVGL", lvgl_thread, RT_NULL, LV_THREAD_STACK_SIZE, LV_THREAD_PRIO, 0);
  49. if(tid == RT_NULL)
  50. {
  51. LOG_E("Fail to create 'LVGL' thread");
  52. }
  53. rt_thread_startup(tid);
  54. return 0;
  55. }
  56. INIT_APP_EXPORT(lvgl_demo_init);