widgets_init.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 "gui_guider.h"
  11. #include "widgets_init.h"
  12. #include <stdlib.h>
  13. #include <string.h>
  14. __attribute__((unused)) void kb_event_cb (lv_event_t *e) {
  15. lv_event_code_t code = lv_event_get_code(e);
  16. lv_obj_t *kb = lv_event_get_target(e);
  17. if(code == LV_EVENT_READY || code == LV_EVENT_CANCEL) {
  18. lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
  19. }
  20. }
  21. __attribute__((unused)) void ta_event_cb (lv_event_t *e) {
  22. #if LV_USE_KEYBOARD
  23. lv_event_code_t code = lv_event_get_code(e);
  24. lv_obj_t * ta = lv_event_get_target(e);
  25. lv_obj_t * kb = lv_event_get_user_data(e);
  26. if(code == LV_EVENT_FOCUSED) {
  27. if(lv_indev_get_type(lv_indev_active()) != LV_INDEV_TYPE_KEYPAD) {
  28. lv_keyboard_set_textarea(kb, ta);
  29. lv_obj_remove_flag(kb, LV_OBJ_FLAG_HIDDEN);
  30. }
  31. } else if(code == LV_EVENT_READY) {
  32. lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
  33. lv_obj_remove_state(ta, LV_STATE_FOCUSED);
  34. lv_indev_reset(NULL, ta);
  35. } else if(code == LV_EVENT_DEFOCUSED) {
  36. lv_keyboard_set_textarea(kb, NULL);
  37. lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
  38. }
  39. #endif
  40. }
  41. void clock_count(int *hour, int *min, int *sec)
  42. {
  43. (*sec)++;
  44. if(*sec == 60)
  45. {
  46. *sec = 0;
  47. (*min)++;
  48. }
  49. if(*min == 60)
  50. {
  51. *min = 0;
  52. if(*hour < 12)
  53. {
  54. (*hour)++;
  55. } else {
  56. (*hour)++;
  57. *hour = *hour %12;
  58. }
  59. }
  60. }
  61. void digital_clock_count(int * hour, int * minute, int * seconds, char * meridiem)
  62. {
  63. (*seconds)++;
  64. if(*seconds == 60) {
  65. *seconds = 0;
  66. (*minute)++;
  67. }
  68. if(*minute == 60) {
  69. *minute = 0;
  70. if(*hour < 12) {
  71. (*hour)++;
  72. }
  73. else {
  74. (*hour)++;
  75. (*hour) = (*hour) % 12;
  76. }
  77. }
  78. if(*hour == 12 && *seconds == 0 && *minute == 0) {
  79. if((lv_strcmp(meridiem, "PM") == 0)) {
  80. lv_strcpy(meridiem, "AM");
  81. }
  82. else {
  83. lv_strcpy(meridiem, "PM");
  84. }
  85. }
  86. }
  87. void lv_SettingPage_spinbox_2_increment_event_cb(lv_event_t * event)
  88. {
  89. lv_event_code_t code = lv_event_get_code(event);
  90. if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
  91. lv_spinbox_increment(guider_ui.SettingPage_spinbox_2);
  92. }
  93. }
  94. void lv_SettingPage_spinbox_2_decrement_event_cb(lv_event_t * event)
  95. {
  96. lv_event_code_t code = lv_event_get_code(event);
  97. if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
  98. lv_spinbox_decrement(guider_ui.SettingPage_spinbox_2);
  99. }
  100. }
  101. void lv_FactorySettingPage_sp_temp_recoup_increment_event_cb(lv_event_t * event)
  102. {
  103. lv_event_code_t code = lv_event_get_code(event);
  104. if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
  105. lv_spinbox_increment(guider_ui.FactorySettingPage_sp_temp_recoup);
  106. }
  107. }
  108. void lv_FactorySettingPage_sp_temp_recoup_decrement_event_cb(lv_event_t * event)
  109. {
  110. lv_event_code_t code = lv_event_get_code(event);
  111. if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
  112. lv_spinbox_decrement(guider_ui.FactorySettingPage_sp_temp_recoup);
  113. }
  114. }
  115. void lv_FactorySettingPage_sp_hum_recoup_increment_event_cb(lv_event_t * event)
  116. {
  117. lv_event_code_t code = lv_event_get_code(event);
  118. if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
  119. lv_spinbox_increment(guider_ui.FactorySettingPage_sp_hum_recoup);
  120. }
  121. }
  122. void lv_FactorySettingPage_sp_hum_recoup_decrement_event_cb(lv_event_t * event)
  123. {
  124. lv_event_code_t code = lv_event_get_code(event);
  125. if(code == LV_EVENT_SHORT_CLICKED || code == LV_EVENT_LONG_PRESSED_REPEAT) {
  126. lv_spinbox_decrement(guider_ui.FactorySettingPage_sp_hum_recoup);
  127. }
  128. }