fp_controller.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /**
  2. * @Author: 李建
  3. * @Date: 2025/3/25 15:23
  4. * Description: 空调控制器
  5. * Copyright: Copyright (©) 2025 永续绿建. All rights reserved.
  6. */
  7. #ifndef WIRE_CONTROLLER_XF_CONTROLLER_H
  8. #define WIRE_CONTROLLER_XF_CONTROLLER_H
  9. #include "stdint.h"
  10. #include "setting.h"
  11. #include "esp_err.h"
  12. #include "gui_guider.h"
  13. #define NVS_POWER_CONTROLLER "power" // 电源
  14. #define NVS_MODEL_CONTROLLER "model" // 工作模式
  15. #define NVS_FAN_SPEED_SET "fan_speed" // 风速挡位
  16. #define NVS_XF_MODE_SET "xf_mode" // 新风模式
  17. #define NVS_AC_SET_TEMP_KEY "AC_SET_TEMP"//
  18. #define NVS_FILTER_USED_TIME "filter" //滤芯已使用时间
  19. #define NVS_TW_STATUS "tw_status" //滤芯已使用时间
  20. #define NVS_XF_MODE "xf_mode" //滤芯已使用时间
  21. #define NVS_MAX_HUM_SET "set_max_hum" // 自动模式下最大湿度
  22. #define NVS_MIN_HUM_SET "set_min_hum" // 自动模式下最小湿度
  23. // 风口序号
  24. enum {
  25. FAN_VALVE_1 = 1,
  26. FAN_VALVE_2,
  27. FAN_VALVE_3,
  28. FAN_VALVE_4,
  29. FAN_VALVE_5,
  30. };
  31. /**
  32. * 定义保存空调设置参数的结构体
  33. */
  34. typedef struct {
  35. uint16_t power; // 电源状态
  36. uint16_t mode;
  37. uint16_t fan_speed;
  38. uint16_t set_temp;
  39. uint16_t filter_used_time;
  40. uint16_t set_max_hum;
  41. uint8_t filter_life_remaining;
  42. uint8_t error_code;
  43. uint8_t tw_status;
  44. uint8_t xf_mode;
  45. }ac_status_t;
  46. typedef struct {
  47. uint8_t code[3];
  48. uint8_t description[32];
  49. }xf_fault_t;
  50. enum {
  51. COLD = 0,
  52. HEAT=1,
  53. TF=3,
  54. };
  55. extern xf_fault_t xf_fault[9];
  56. void stop_xf_controller();
  57. // 保存当前空调状态
  58. extern ac_status_t ac_status;
  59. /**
  60. * 控制器初始化
  61. * @param setting 系统设置参数
  62. */
  63. void ac_controller_init(system_setting_t * setting);
  64. /**
  65. * 设置滤网剩余寿命
  66. * @param saved 是否保存到 nvs 中
  67. */
  68. void xf_set_filter_life_remain(bool saved);
  69. /**
  70. * 设置风档
  71. * @param saved 是否保存到 nvs 中
  72. */
  73. esp_err_t xf_set_fan_speed(bool saved);
  74. /**
  75. * 设置电源
  76. * @param saved 是否保存到 nvs 中
  77. */
  78. esp_err_t ac_set_power(bool saved);
  79. /**
  80. * 设置温度
  81. * @param saved 是否保存到 nvs 中
  82. */
  83. esp_err_t ac_set_temp(bool saved);
  84. /**
  85. * 设置模式
  86. * @param saved 是否保存到 nvs 中
  87. */
  88. esp_err_t xf_set_mode(bool saved);
  89. /**
  90. * 设置对应风阀开度
  91. * @param no 风阀序号
  92. * @param degree 风阀开度
  93. */
  94. esp_err_t ac_set_fan_valve(uint8_t no, uint16_t degree);
  95. /**
  96. * 新风模式(手动新风)
  97. * @param no
  98. * @param degree
  99. */
  100. esp_err_t ac_set_xf_mode(bool saved);
  101. /**
  102. * 注册云端指令
  103. */
  104. void register_sparrow_commands(void);
  105. esp_err_t xf_set_max_hum(bool saved);
  106. extern void set_fan_level(lv_ui *ui, uint16_t speed);
  107. void read_xf_status(system_setting_t *setting);
  108. void timer_init_lx();
  109. #endif //WIRE_CONTROLLER_XF_CONTROLLER_H