mirror of
https://git.beihong.wang/wangbeihong/iot-bedroom-environment-controller.git
synced 2026-04-24 00:53:05 +08:00
refactor(display): migrate from ST7735S to ST7789 driver
- Rename component directory from lvgl_st7735s_use to lvgl_st7789_use - Update CMakeLists.txt to register new source files - Add comprehensive README documentation for ST7789 configuration - Add time_alarm module with SNTP synchronization and alarm management - Add sensors header for sensor abstraction layer
This commit is contained in:
65
main/sensors.h
Normal file
65
main/sensors.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#ifndef SENSORS_H
|
||||
#define SENSORS_H
|
||||
#include "esp_err.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "driver/i2c_master.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// 默认 I2C 引脚/参数(如果上层未定义,则使用这些默认值)
|
||||
#ifndef I2C_MASTER_SCL_IO
|
||||
#define I2C_MASTER_SCL_IO 5
|
||||
#endif
|
||||
#ifndef I2C_MASTER_SDA_IO
|
||||
#define I2C_MASTER_SDA_IO 4
|
||||
#endif
|
||||
#ifndef I2C_MASTER_NUM
|
||||
#define I2C_MASTER_NUM I2C_NUM_0
|
||||
#endif
|
||||
#ifndef I2C_MASTER_FREQ_HZ
|
||||
#define I2C_MASTER_FREQ_HZ 100000
|
||||
#endif
|
||||
|
||||
// 传感器数据结构体(从 main.c 抽取)
|
||||
typedef struct
|
||||
{
|
||||
float temperature;
|
||||
float humidity;
|
||||
float lux;
|
||||
uint16_t co2_ppm;
|
||||
uint16_t tvoc_ppb;
|
||||
bool ahtxx_valid;
|
||||
bool bh1750_valid;
|
||||
bool sgp30_valid;
|
||||
} sensor_data_t;
|
||||
|
||||
// 全局传感器数据(在 sensors.c 定义)
|
||||
extern sensor_data_t g_sensor_data;
|
||||
|
||||
// 互斥锁(由 main.c 创建,sensors 使用 extern 引用)
|
||||
extern SemaphoreHandle_t xSensorDataMutex;
|
||||
|
||||
// I2C 句柄(在 sensors.c 中定义)
|
||||
extern i2c_master_bus_handle_t bus_handle;
|
||||
extern i2c_master_dev_handle_t dev_handle;
|
||||
|
||||
// 模块对外接口
|
||||
esp_err_t sensors_init(void);
|
||||
esp_err_t sensors_read(void);
|
||||
|
||||
// 低层接口 / 任务
|
||||
esp_err_t i2c_master_init(void);
|
||||
void i2c0_ahtxx_task(void *pvParameters);
|
||||
void i2c0_bh1750_task(void *pvParameters);
|
||||
void i2c0_sgp30_task(void *pvParameters);
|
||||
void get_sensor_data(sensor_data_t *data);
|
||||
void print_sensor_data(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SENSORS_H
|
||||
Reference in New Issue
Block a user