系统时间,环境温度湿度功能
This commit is contained in:
1 parent
823153c8ea
commit
0dfe8ddb1c
4 files changed
+28
-9
No files matched your search
@@ -135,8 +135,8 @@ static void aht20_thread_entry(void *parameter)
|
||||
{
|
||||
rt_uint8_t raw_data[6];
|
||||
|
||||
extern unsigned int sys_temperature;
|
||||
extern unsigned int sys_humidity;
|
||||
extern rt_int32_t sys_temperature;
|
||||
extern rt_int32_t sys_humidity;
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
@@ -141,6 +141,9 @@ static void ds1307_read_time(void)
|
||||
}
|
||||
|
||||
/* Software thread to maintain local time estimation */
|
||||
time_t now;
|
||||
struct tm *p_tm;
|
||||
extern unsigned char sys_time[6];
|
||||
static void auto_update_current_datatime(void *parameter)
|
||||
{
|
||||
uint32_t count = 0;
|
||||
@@ -154,6 +157,14 @@ static void auto_update_current_datatime(void *parameter)
|
||||
ds1307_read_time();
|
||||
count = 0;
|
||||
}
|
||||
time(&now); // 获取当前日历时间(秒,自 1970-01-01 00:00:00 UTC)
|
||||
p_tm = localtime(&now); // 转换为本地时间结构
|
||||
sys_time[5]= p_tm->tm_year - 100;
|
||||
sys_time[4]= p_tm->tm_mon + 1;
|
||||
sys_time[3]= p_tm->tm_mday;
|
||||
sys_time[2]= p_tm->tm_hour;
|
||||
sys_time[1]= p_tm->tm_min;
|
||||
sys_time[0]= p_tm->tm_sec;;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,7 +221,7 @@ static int rt_hw_ds1307_rtc_init(void)
|
||||
|
||||
ds1307_read_time();
|
||||
|
||||
ds1307.thd_soft_update_sec = rt_thread_create("ds1307",auto_update_current_datatime,RT_NULL,256, 20, 5);
|
||||
ds1307.thd_soft_update_sec = rt_thread_create("ds1307",auto_update_current_datatime,RT_NULL,512, 20, 5);
|
||||
if (ds1307.thd_soft_update_sec)
|
||||
{
|
||||
rt_thread_startup(ds1307.thd_soft_update_sec);
|
||||
|
||||
Reference in new issue
Block a user