gui_guider.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2025 NXP
  3. * NXP Proprietary. This software is owned or controlled by NXP and may only be used strictly in
  4. * accordance with the applicable license terms. By expressly accepting such terms or by downloading, installing,
  5. * activating and/or otherwise using the software, you are agreeing that you have read, and that you agree to
  6. * comply with and are bound by, such license terms. If you do not agree to be bound by the applicable license
  7. * terms, then you may not retain, install, activate or otherwise use the software.
  8. */
  9. #include "lvgl.h"
  10. #include <stdio.h>
  11. #include "gui_guider.h"
  12. #include "widgets_init.h"
  13. void ui_init_style(lv_style_t * style)
  14. {
  15. if (style->prop_cnt > 1)
  16. lv_style_reset(style);
  17. else
  18. lv_style_init(style);
  19. }
  20. void ui_load_scr_animation(lv_ui *ui, lv_obj_t ** new_scr, bool new_scr_del, bool * old_scr_del, ui_setup_scr_t setup_scr,
  21. lv_screen_load_anim_t anim_type, uint32_t time, uint32_t delay, bool is_clean, bool auto_del)
  22. {
  23. lv_obj_t * act_scr = lv_screen_active();
  24. #if LV_USE_GUIDER_SIMULATOR && LV_USE_FREEMASTER
  25. #include "gg_external_data.h"
  26. if(auto_del) {
  27. gg_edata_task_clear(act_scr);
  28. }
  29. #endif
  30. if (auto_del && is_clean) {
  31. lv_obj_clean(act_scr);
  32. }
  33. if (new_scr_del) {
  34. setup_scr(ui);
  35. }
  36. lv_screen_load_anim(*new_scr, anim_type, time, delay, auto_del);
  37. *old_scr_del = auto_del;
  38. }
  39. void ui_animation(void * var, uint32_t duration, int32_t delay, int32_t start_value, int32_t end_value, lv_anim_path_cb_t path_cb,
  40. uint32_t repeat_cnt, uint32_t repeat_delay, uint32_t playback_time, uint32_t playback_delay,
  41. lv_anim_exec_xcb_t exec_cb, lv_anim_start_cb_t start_cb, lv_anim_completed_cb_t ready_cb, lv_anim_deleted_cb_t deleted_cb)
  42. {
  43. lv_anim_t anim;
  44. lv_anim_init(&anim);
  45. lv_anim_set_var(&anim, var);
  46. lv_anim_set_exec_cb(&anim, exec_cb);
  47. lv_anim_set_values(&anim, start_value, end_value);
  48. lv_anim_set_time(&anim, duration);
  49. lv_anim_set_delay(&anim, delay);
  50. lv_anim_set_path_cb(&anim, path_cb);
  51. lv_anim_set_repeat_count(&anim, repeat_cnt);
  52. lv_anim_set_repeat_delay(&anim, repeat_delay);
  53. lv_anim_set_playback_time(&anim, playback_time);
  54. lv_anim_set_playback_delay(&anim, playback_delay);
  55. if (start_cb) {
  56. lv_anim_set_start_cb(&anim, start_cb);
  57. }
  58. if (ready_cb) {
  59. lv_anim_set_completed_cb(&anim, ready_cb);
  60. }
  61. if (deleted_cb) {
  62. lv_anim_set_deleted_cb(&anim, deleted_cb);
  63. }
  64. lv_anim_start(&anim);
  65. }
  66. void init_scr_del_flag(lv_ui *ui)
  67. {
  68. ui->screen_main_del = true;
  69. ui->SettingPage_del = true;
  70. ui->FactorySettingPage_del = true;
  71. ui->OTAPage_del = true;
  72. }
  73. void setup_bottom_layer(void)
  74. {
  75. lv_theme_apply(lv_layer_bottom());
  76. }
  77. void setup_ui(lv_ui *ui)
  78. {
  79. setup_bottom_layer();
  80. init_scr_del_flag(ui);
  81. init_keyboard(ui);
  82. setup_scr_screen_main(ui);
  83. lv_screen_load(ui->screen_main);
  84. }
  85. void video_play(lv_ui *ui)
  86. {
  87. }
  88. void init_keyboard(lv_ui *ui)
  89. {
  90. ui->g_kb_top_layer = lv_keyboard_create(lv_layer_top());
  91. lv_obj_add_event_cb(ui->g_kb_top_layer, kb_event_cb, LV_EVENT_ALL, NULL);
  92. lv_obj_add_flag(ui->g_kb_top_layer, LV_OBJ_FLAG_HIDDEN);
  93. lv_obj_set_style_text_font(ui->g_kb_top_layer, &lv_font_SourceHanSerifSC_Regular_18, LV_PART_MAIN|LV_STATE_DEFAULT);
  94. }