xf_controller.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #define NVS_POWER_CONTROLLER "power" // 电源
  13. #define NVS_MODEL_CONTROLLER "model" // 工作模式
  14. #define NVS_FAN_SPEED_SET "fan_speed" // 风速挡位
  15. #define NVS_FILTER_USED_TIME "filter_used_time" //滤芯已使用时间
  16. #define NVS_MAX_HUM_SET "set_max_hum" // 自动模式下最大湿度
  17. #define NVS_MIN_HUM_SET "set_min_hum" // 自动模式下最小湿度
  18. // 风口序号
  19. enum {
  20. FAN_VALVE_1 = 1,
  21. FAN_VALVE_2,
  22. FAN_VALVE_3,
  23. FAN_VALVE_4,
  24. FAN_VALVE_5,
  25. };
  26. /**
  27. * 定义保存空调设置参数的结构体
  28. */
  29. typedef struct {
  30. uint16_t power; // 电源状态
  31. uint16_t mode;
  32. uint16_t fan_speed;
  33. uint32_t filter_used_time;
  34. uint16_t set_max_hum;
  35. uint8_t filter_life_remaining;
  36. uint8_t error_code;
  37. }xf_status_t;
  38. enum {
  39. NXH = 1,
  40. JS=3,
  41. XF=2,
  42. AUTO=4,
  43. };
  44. void stop_xf_controller();
  45. // 保存当前空调状态
  46. extern xf_status_t xf_status;
  47. /**
  48. * 控制器初始化
  49. * @param setting 系统设置参数
  50. */
  51. void xf_controller_init(system_setting_t * setting);
  52. /**
  53. * 设置滤网剩余寿命
  54. * @param saved 是否保存到 nvs 中
  55. */
  56. void xf_set_filter_life_remain(bool saved);
  57. /**
  58. * 设置风档
  59. * @param saved 是否保存到 nvs 中
  60. */
  61. esp_err_t xf_set_fan_speed(bool saved);
  62. /**
  63. * 设置电源
  64. * @param saved 是否保存到 nvs 中
  65. */
  66. esp_err_t xf_set_power(bool saved);
  67. /**
  68. * 设置温度
  69. * @param saved 是否保存到 nvs 中
  70. */
  71. esp_err_t ac_set_temp(bool saved);
  72. /**
  73. * 设置模式
  74. * @param saved 是否保存到 nvs 中
  75. */
  76. esp_err_t xf_set_mode(bool saved);
  77. /**
  78. * 设置对应风阀开度
  79. * @param no 风阀序号
  80. * @param degree 风阀开度
  81. */
  82. esp_err_t ac_set_fan_valve(uint8_t no, uint16_t degree);
  83. /**
  84. * 注册云端指令
  85. */
  86. void register_sparrow_commands(void);
  87. esp_err_t xf_set_max_hum(bool saved);
  88. void read_xf_status(system_setting_t *setting);
  89. #endif //WIRE_CONTROLLER_XF_CONTROLLER_H