mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-19 09:25:54 +08:00
添加智能灯固件代码
This commit is contained in:
38
firmware/esp-idf/wumei-smart-firmware/main/device_temp.c
Normal file
38
firmware/esp-idf/wumei-smart-firmware/main/device_temp.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/******************************************************************************
|
||||
* 作者:kerwincui
|
||||
* 时间:2021-06-08
|
||||
* 邮箱:164770707@qq.com
|
||||
* 源码地址:https://gitee.com/kerwincui/wumei-smart
|
||||
* author: kerwincui
|
||||
* create: 2021-06-08
|
||||
* email:164770707@qq.com
|
||||
* source:https://github.com/kerwincui/wumei-smart
|
||||
******************************************************************************/
|
||||
#include "device_temp.h"
|
||||
|
||||
static const char *TAG = "TempSensor";
|
||||
|
||||
static void tempsensor_task(void *arg)
|
||||
{
|
||||
// 初始化触摸板外围设备,它将启动计时器以运行过滤器
|
||||
ESP_LOGI(TAG, "Initializing Temperature sensor");
|
||||
float tsens_out;
|
||||
temp_sensor_config_t temp_sensor = TSENS_CONFIG_DEFAULT();
|
||||
temp_sensor_get_config(&temp_sensor);
|
||||
ESP_LOGI(TAG, "default dac %d, clk_div %d", temp_sensor.dac_offset, temp_sensor.clk_div);
|
||||
temp_sensor.dac_offset = TSENS_DAC_DEFAULT; // 默认: 范围:-10℃ ~ 80℃, 错误 < 1℃.
|
||||
temp_sensor_set_config(temp_sensor);
|
||||
temp_sensor_start();
|
||||
ESP_LOGI(TAG, "Temperature sensor started");
|
||||
while (1) {
|
||||
vTaskDelay(1000 / portTICK_RATE_MS);
|
||||
temp_sensor_read_celsius(&tsens_out);
|
||||
ESP_LOGI(TAG, "Temperature out celsius %f°C", tsens_out);
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void get_device_temp(void)
|
||||
{
|
||||
xTaskCreate(tempsensor_task, "temp", 2048, NULL, 5, NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user