actions.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @Author: 李建
  3. * @Date: 2025/3/18 11:34
  4. * Description: 定义了UI 与 逻辑的交互
  5. * Copyright: Copyright (©) 2025 永续绿建. All rights reserved.
  6. */
  7. #include <esp_log.h>
  8. #include <string.h>
  9. #include <nvs_flash.h>
  10. #include "misc/lv_types.h"
  11. #include "widgets/tabview/lv_tabview.h"
  12. #include "gui_guider.h"
  13. #include "main.h"
  14. #include "actions.h"
  15. #include "lvgl_port.h"
  16. char mode_str[][8] = {"制冷", "制热"};
  17. // 设置温度
  18. // AC 页面温度弧形滑块事件
  19. void on_ac_page_arc_value_changed(lv_event_t *e) {
  20. lv_obj_t *arc = lv_event_get_current_target(e);
  21. int32_t value = lv_arc_get_value(arc);
  22. lvgl_port_lock(0);
  23. lv_label_set_text_static(guider_ui.screen_lab_mode, mode_str[0]);
  24. lv_label_set_text_fmt(guider_ui.screen_lab_ac_temp, "%d", (uint16_t) value);
  25. lvgl_port_unlock();
  26. }
  27. // 温度弧形滑块释放事件
  28. void on_ac_page_arc_released(lv_event_t *e) {
  29. lv_obj_t *arc = lv_event_get_current_target(e);
  30. int32_t value = lv_arc_get_value(arc);
  31. // ac_status.set_temp = (uint16_t) value;
  32. // ac_set_temp(true);
  33. }
  34. void on_set_ac_mode(lv_event_t *e) {
  35. uint8_t mode = 0;
  36. lv_obj_t *cont = (lv_obj_t *) lv_event_get_current_target(e);
  37. lv_obj_t *act_cb = lv_event_get_target(e);
  38. // if (act_cb == cont) return;
  39. lv_obj_add_state(act_cb, LV_STATE_CHECKED);
  40. uint32_t count = lv_obj_get_child_count(cont);
  41. // 遍历所有子控件
  42. for (int i = 0; i < count; i++) {
  43. lv_obj_t *child = lv_obj_get_child(cont, i);
  44. if (child != act_cb) {
  45. lv_obj_remove_state(child, LV_STATE_CHECKED);
  46. }
  47. }
  48. if (act_cb == guider_ui.screen_ib_cool) {
  49. mode = 0;
  50. } else if (act_cb == guider_ui.screen_ib_heat) {
  51. mode = 1;
  52. }
  53. lvgl_port_lock(-1);
  54. lv_label_set_text_static(guider_ui.screen_lab_mode, mode_str[mode]);
  55. lvgl_port_unlock();
  56. }
  57. void on_set_water_valve_txt(lv_event_t *e)
  58. {
  59. lv_checkbox_set_text_static(guider_ui.WaterValvePage_cb_2, mode_str[0]);
  60. }