widgets_init.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. }
  32. else if(code == LV_EVENT_READY) {
  33. lv_obj_add_flag(kb, LV_OBJ_FLAG_HIDDEN);
  34. lv_obj_remove_state(ta, LV_STATE_FOCUSED);
  35. lv_indev_reset(NULL, ta);
  36. }
  37. #endif
  38. }
  39. void clock_count(int *hour, int *min, int *sec)
  40. {
  41. (*sec)++;
  42. if(*sec == 60)
  43. {
  44. *sec = 0;
  45. (*min)++;
  46. }
  47. if(*min == 60)
  48. {
  49. *min = 0;
  50. if(*hour < 12)
  51. {
  52. (*hour)++;
  53. } else {
  54. (*hour)++;
  55. *hour = *hour %12;
  56. }
  57. }
  58. }
  59. void digital_clock_count(int * hour, int * minute, int * seconds, char * meridiem)
  60. {
  61. (*seconds)++;
  62. if(*seconds == 60) {
  63. *seconds = 0;
  64. (*minute)++;
  65. }
  66. if(*minute == 60) {
  67. *minute = 0;
  68. if(*hour < 12) {
  69. (*hour)++;
  70. }
  71. else {
  72. (*hour)++;
  73. (*hour) = (*hour) % 12;
  74. }
  75. }
  76. if(*hour == 12 && *seconds == 0 && *minute == 0) {
  77. if((lv_strcmp(meridiem, "PM") == 0)) {
  78. lv_strcpy(meridiem, "AM");
  79. }
  80. else {
  81. lv_strcpy(meridiem, "PM");
  82. }
  83. }
  84. }