添加人体门状态检测功能,包含初始化和读取状态的逻辑,并更新主程序以集成此功能
This commit is contained in:
26
components/human_door/include/human_door.h
Normal file
26
components/human_door/include/human_door.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HUMAN_SENSOR_GPIO 16
|
||||
#define DOOR_SWITCH_GPIO 17
|
||||
|
||||
typedef struct {
|
||||
bool human_present;
|
||||
bool door_closed;
|
||||
} human_door_state_t;
|
||||
|
||||
// GPIO16: HC-SR312. High means motion detected.
|
||||
// GPIO17: Door switch. Low means door closed.
|
||||
esp_err_t human_door_init(void);
|
||||
esp_err_t human_door_read(human_door_state_t *out_state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user