diff --git a/.settings/.rtmenus b/.settings/.rtmenus index b5c2f3e..5fbf020 100644 Binary files a/.settings/.rtmenus and b/.settings/.rtmenus differ diff --git a/applications/INI/config.c b/applications/INI/config.c index bd1dc3c..3d2220f 100644 --- a/applications/INI/config.c +++ b/applications/INI/config.c @@ -34,8 +34,8 @@ int read_write_sample(void) return -1; } // 读取各种类型的值 - strncpy(machine_ID, ini_get_value(ini, "CONFIG", "ID"),sizeof(machine_ID)); - machine_name = ini_get_value(ini, "CONFIG", "NAME"); + strncpy(machine_ID, ini_get_value(ini, "CONFIG", "ID","99"),sizeof(machine_ID)); + machine_name = ini_get_value(ini, "CONFIG", "NAME","828"); //// ini_set_value(ini,"database", "host","192.168.9.1"); diff --git a/applications/INI/ini.c b/applications/INI/ini.c index e0fb74a..cebf569 100644 --- a/applications/INI/ini.c +++ b/applications/INI/ini.c @@ -233,7 +233,7 @@ int ini_delete_key(INI_File *ini, const char *section, const char *key) { return -1; // 未找到 } // 获取键值 -char* ini_get_value(INI_File *ini, const char *section, const char *key) { +char* ini_get_value(INI_File *ini, const char *section, const char *key,char *def) { for (int i = 0; i < ini->section_count; i++) { if (strcmp(ini->sections[i].section, section) == 0) { for (int j = 0; j < ini->sections[i].entry_count; j++) { @@ -244,26 +244,26 @@ char* ini_get_value(INI_File *ini, const char *section, const char *key) { break; } } - return NULL; // 未找到 + return def; // 未找到 } // 获取整数值 int ini_get_int(INI_File *ini, const char *section, const char *key, int default_value) { - const char *value = ini_get_value(ini, section, key); + const char *value = ini_get_value(ini, section, key,"0"); if (!value) return default_value; return atoi(value); } // 获取浮点数值 double ini_get_double(INI_File *ini, const char *section, const char *key, double default_value) { - const char *value = ini_get_value(ini, section, key); + const char *value = ini_get_value(ini, section, key,"0"); if (!value) return default_value; return atof(value); } // 获取布尔值 int ini_get_bool(INI_File *ini, const char *section, const char *key, int default_value) { - const char *value = ini_get_value(ini, section, key); + const char *value = ini_get_value(ini, section, key,"0"); if (!value) return default_value; if (strcasecmp(value, "true") == 0 || strcasecmp(value, "yes") == 0 || diff --git a/applications/INI/ini.h b/applications/INI/ini.h index 8757a07..e271647 100644 --- a/applications/INI/ini.h +++ b/applications/INI/ini.h @@ -44,7 +44,7 @@ extern int ini_parse(INI_File *ini, const char *filename); extern int ini_set_value(INI_File *ini, const char *section, const char *key, const char *value); extern int ini_save(INI_File *ini, const char *filename); extern int ini_delete_key(INI_File *ini, const char *section, const char *key); -extern char* ini_get_value(INI_File *ini, const char *section, const char *key); +extern char* ini_get_value(INI_File *ini, const char *section, const char *key,char *def); extern int ini_get_int(INI_File *ini, const char *section, const char *key, int default_value); extern double ini_get_double(INI_File *ini, const char *section, const char *key, double default_value); extern int ini_get_bool(INI_File *ini, const char *section, const char *key, int default_value); diff --git a/applications/main.c b/applications/main.c index e138466..df32dea 100644 --- a/applications/main.c +++ b/applications/main.c @@ -9,10 +9,9 @@ */ #include -#include #include #include "DB_SQLite.h" -#include "lcd.h" + #define DBG_TAG "main" #define DBG_LVL DBG_LOG #include @@ -25,6 +24,5 @@ int main(void) thread_DB_SQLite(); thread_RUN_LED();//运行指示灯线程 - return RT_EOK; } diff --git a/drivers/drv_ds1307.c b/drivers/drv_ds1307.c index 14387b5..5296cad 100644 --- a/drivers/drv_ds1307.c +++ b/drivers/drv_ds1307.c @@ -131,14 +131,13 @@ static void ds1307_read_time(void) ds1307.datetime.tm_min, ds1307.datetime.tm_sec); + if(ds1307.datetime.tm_year<199)// + { /* 设置日期为年月号 */ set_date(ds1307.datetime.tm_year + 1900, ds1307.datetime.tm_mon + 1, ds1307.datetime.tm_mday); /* 设置时间为点分秒 */ set_time(ds1307.datetime.tm_hour, ds1307.datetime.tm_min, ds1307.datetime.tm_sec); - /* 获取时间 */ - time_t now = time(RT_NULL); - /* 打印输出时间信息 */ - rt_kprintf("DATE: %s", ctime(&now)); + } } /* Software thread to maintain local time estimation */ @@ -148,25 +147,9 @@ static void auto_update_current_datatime(void *parameter) while (1) { rt_thread_delay(RT_TICK_PER_SECOND); - ds1307.datetime.tm_sec++; - if (ds1307.datetime.tm_sec >= 60) - { - ds1307.datetime.tm_sec = 0; - ds1307.datetime.tm_min++; - if (ds1307.datetime.tm_min >= 60) - { - ds1307.datetime.tm_min = 0; - ds1307.datetime.tm_hour++; - if (ds1307.datetime.tm_hour >= 24) - { - ds1307.datetime.tm_hour = 0; - // Note: day/month/year rollover not handled in soft update - } - } - } // Sync with hardware every 10 minutes - if (++count >= 600) // 600 seconds + if (++count >= 3600) // 600 seconds { ds1307_read_time(); count = 0; @@ -227,7 +210,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,512, 10, 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); @@ -236,7 +219,7 @@ static int rt_hw_ds1307_rtc_init(void) LOG_I("DS1307 RTC initialized successfully on %s", ds1307.iic_name); return RT_EOK; } -INIT_COMPONENT_EXPORT(rt_hw_ds1307_rtc_init); +INIT_APP_EXPORT(rt_hw_ds1307_rtc_init); /* MSH Commands */ #include