- CMake 多目标工程:shs_core 静态库 + smart_home 可执行 + shs_tests 测试 - CMakePresets.json:debug/release/asan/coverage 四个预设(debug 告警即错误) - 自研零依赖测试框架 tests/framework/test_framework.h + 运行器(套件过滤、CTest 集成) - 工具:tools/header_check.sh 头文件独立编译检查(接口冻结门) - 已实现公共层:errors / string_utils / num_utils,main 启动自检 - 实测:debug 预设 0 告警、ctest 3/3 通过(45 项断言)
51 lines
1.9 KiB
C
51 lines
1.9 KiB
C
/**
|
||
* @file scene.h
|
||
* @brief 场景联动与空调多模式控制
|
||
*
|
||
* 教材对应:项目三(多分支与 switch)·项目六(函数嵌套调用)·项目七(指针数组遍历)
|
||
*/
|
||
#ifndef SHS_SCENE_H
|
||
#define SHS_SCENE_H
|
||
|
||
#include "shs/common.h"
|
||
#include "shs/errors.h"
|
||
#include "shs/device.h"
|
||
|
||
/** 场景编号 */
|
||
typedef enum {
|
||
SHS_SCENE_HOME = 1, /**< 回家:开灯、开空调 */
|
||
SHS_SCENE_LEAVE = 2, /**< 离家:关灯、关空调、门锁上锁 */
|
||
SHS_SCENE_SLEEP = 3, /**< 睡眠:调暗灯光、空调睡眠模式 */
|
||
SHS_SCENE_MOVIE = 4, /**< 影音:调暗灯光、关闭窗帘 */
|
||
SHS_SCENE_ENERGY = 5 /**< 节能:关闭非必要设备 */
|
||
} shs_scene_t;
|
||
|
||
/** 空调工作模式 */
|
||
typedef enum {
|
||
SHS_AC_OFF = 0,
|
||
SHS_AC_COOL, /**< 制冷 */
|
||
SHS_AC_HEAT, /**< 制热 */
|
||
SHS_AC_FAN, /**< 送风 */
|
||
SHS_AC_DRY, /**< 除湿 */
|
||
SHS_AC_AUTO /**< 自动 */
|
||
} shs_ac_mode_t;
|
||
|
||
/** 空调模式选择(项目三 多分支 + 嵌套分支:温度与目标温度比较) */
|
||
shs_ac_mode_t scene_ac_mode_select(float current_temp, float target_temp);
|
||
/** 模式名称(switch 演示) */
|
||
const char *scene_ac_mode_name(shs_ac_mode_t mode);
|
||
/** 空调目标温度调节:18~30℃ 之外返回 SHS_ERR_RANGE */
|
||
shs_err_t scene_ac_set_target(Device *ac, float target_temp);
|
||
|
||
/** 执行场景(项目六 嵌套调用:本函数 → device_set_* → hal_gpio_write) */
|
||
shs_err_t scene_execute(Device devices[], int count, shs_scene_t scene, char *log_msg, size_t log_size);
|
||
/** 场景名称(switch 演示) */
|
||
const char *scene_name(shs_scene_t scene);
|
||
|
||
/** 室内光照舒适度评估(项目三 多分支):返回 0~100 的建议亮度 */
|
||
int scene_suggest_brightness(float lux, bool occupied);
|
||
/** 节能建议(项目二 运算符 + 项目三 分支) */
|
||
shs_err_t scene_energy_advice(const Device devices[], int count, char *buf, size_t buf_size);
|
||
|
||
#endif /* SHS_SCENE_H */
|