1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- /**
- * @Author: 李建
- * @Date: 2025/3/18 11:34
- * Description: 定义了UI 与 逻辑的交互
- * Copyright: Copyright (©) 2025 永续绿建. All rights reserved.
- */
- #include <esp_log.h>
- #include <string.h>
- #include <nvs_flash.h>
- #include "misc/lv_types.h"
- #include "widgets/tabview/lv_tabview.h"
- #include "gui_guider.h"
- #include "main.h"
- #include "actions.h"
- #include "lvgl_port.h"
- char mode_str[][8] = {"制冷", "制热"};
- // 设置温度
- // AC 页面温度弧形滑块事件
- void on_ac_page_arc_value_changed(lv_event_t *e) {
- lv_obj_t *arc = lv_event_get_current_target(e);
- int32_t value = lv_arc_get_value(arc);
- lvgl_port_lock(0);
- lv_label_set_text_static(guider_ui.screen_lab_mode, mode_str[0]);
- lv_label_set_text_fmt(guider_ui.screen_lab_ac_temp, "%d", (uint16_t) value);
- lvgl_port_unlock();
- }
- // 温度弧形滑块释放事件
- void on_ac_page_arc_released(lv_event_t *e) {
- lv_obj_t *arc = lv_event_get_current_target(e);
- int32_t value = lv_arc_get_value(arc);
- // ac_status.set_temp = (uint16_t) value;
- // ac_set_temp(true);
- }
- void on_set_ac_mode(lv_event_t *e) {
- uint8_t mode = 0;
- lv_obj_t *cont = (lv_obj_t *) lv_event_get_current_target(e);
- lv_obj_t *act_cb = lv_event_get_target(e);
- // if (act_cb == cont) return;
- lv_obj_add_state(act_cb, LV_STATE_CHECKED);
- uint32_t count = lv_obj_get_child_count(cont);
- // 遍历所有子控件
- for (int i = 0; i < count; i++) {
- lv_obj_t *child = lv_obj_get_child(cont, i);
- if (child != act_cb) {
- lv_obj_remove_state(child, LV_STATE_CHECKED);
- }
- }
- if (act_cb == guider_ui.screen_ib_cool) {
- mode = 0;
- } else if (act_cb == guider_ui.screen_ib_heat) {
- mode = 1;
- }
- lvgl_port_lock(-1);
- lv_label_set_text_static(guider_ui.screen_lab_mode, mode_str[mode]);
- lvgl_port_unlock();
- }
- void on_set_water_valve_txt(lv_event_t *e)
- {
- lv_checkbox_set_text_static(guider_ui.WaterValvePage_cb_2, mode_str[0]);
- }
|