xf_controller.h 2.3 KB

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