xf_controller.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. }xf_status_t;
  37. enum {
  38. NXH = 1,
  39. JS=3,
  40. XF=2,
  41. AUTO=4,
  42. };
  43. void stop_xf_controller();
  44. // 保存当前空调状态
  45. extern xf_status_t xf_status;
  46. /**
  47. * 控制器初始化
  48. * @param setting 系统设置参数
  49. */
  50. void xf_controller_init(system_setting_t * setting);
  51. /**
  52. * 设置滤网剩余寿命
  53. * @param saved 是否保存到 nvs 中
  54. */
  55. void xf_set_filter_life_remain(bool saved);
  56. /**
  57. * 设置风档
  58. * @param saved 是否保存到 nvs 中
  59. */
  60. esp_err_t xf_set_fan_speed(bool saved);
  61. /**
  62. * 设置电源
  63. * @param saved 是否保存到 nvs 中
  64. */
  65. esp_err_t xf_set_power(bool saved);
  66. /**
  67. * 设置温度
  68. * @param saved 是否保存到 nvs 中
  69. */
  70. esp_err_t ac_set_temp(bool saved);
  71. /**
  72. * 设置模式
  73. * @param saved 是否保存到 nvs 中
  74. */
  75. esp_err_t xf_set_mode(bool saved);
  76. /**
  77. * 设置对应风阀开度
  78. * @param no 风阀序号
  79. * @param degree 风阀开度
  80. */
  81. esp_err_t ac_set_fan_valve(uint8_t no, uint16_t degree);
  82. /**
  83. * 注册云端指令
  84. */
  85. void register_sparrow_commands(void);
  86. esp_err_t xf_set_max_hum(bool saved);
  87. void read_xf_status(system_setting_t *setting);
  88. #endif //WIRE_CONTROLLER_XF_CONTROLLER_H