diff --git a/README.md b/README.md index b45b708..7655add 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,24 @@ ![alt text](my_picture/温度.png) ### 显示时间 - +[参考(https://blog.csdn.net/toopoo/article/details/113665077)](https://blog.csdn.net/toopoo/article/details/113665077) +``` c +void greattime() +{ + time_t cur_time; + struct tm *info; + cur_time = ntp_get_time(RT_NULL); + info=localtime(&cur_time); + strftime(tmp, 80, "%Y-%m-%d", info); + lcd_show_string(40, 240/2-32-24, 32, tmp); + strftime(tmp, 80, "%H:%M:%S", info); + lcd_show_string(50, 240/2+24, 32, tmp); + if (cur_time) + { + rt_kprintf("NTP Server Time: %s", ctime((const time_t *)&cur_time)); + } +} +``` # STM32F407 星火一号开发板 BSP 说明 diff --git a/my_pro/my_func.c b/my_pro/my_func.c index 0ab0883..70ce81b 100644 --- a/my_pro/my_func.c +++ b/my_pro/my_func.c @@ -4,8 +4,11 @@ #include #include #include +#include #define LCD_MAX 240 + +extern char tmp[]; void lcd_black(int x, int y) { lcd_address_set(x, y, x, y); @@ -41,6 +44,21 @@ void mytime() } lcd_show_string(20, 2, 16, ctime((const time_t *)&cur_time)); } +void greattime() +{ + time_t cur_time; + struct tm *info; + cur_time = ntp_get_time(RT_NULL); + info=localtime(&cur_time); + strftime(tmp, 80, "%Y-%m-%d", info); + lcd_show_string(40, 240/2-32-24, 32, tmp); + strftime(tmp, 80, "%H:%M:%S", info); + lcd_show_string(50, 240/2+24, 32, tmp); + if (cur_time) + { + rt_kprintf("NTP Server Time: %s", ctime((const time_t *)&cur_time)); + } +} void xy_round(int x, int y, int x2, int y2, int r, int ii) { diff --git a/my_pro/my_func.h b/my_pro/my_func.h index d746ece..a990832 100644 --- a/my_pro/my_func.h +++ b/my_pro/my_func.h @@ -5,6 +5,7 @@ // 当前方向 void mytime(); +void greattime(); void xy_round(int x, int y, int x2, int y2, int r, int ii); void my_round(int r); void xy_sink(); diff --git a/my_pro/myinfrared.c b/my_pro/myinfrared.c index f0c4cd9..beab65a 100644 --- a/my_pro/myinfrared.c +++ b/my_pro/myinfrared.c @@ -7,7 +7,7 @@ #define DBG_TAG "main" #define DBG_LVL DBG_LOG #include -#include +// #include #include /* 配置 LED 灯引脚 */ @@ -21,7 +21,7 @@ extern rt_atomic_t page_chosen; extern rt_atomic_t page_first; extern rt_atomic_t page_stop; extern int snake_max; -extern char tmp[10]; +extern char tmp[]; void snake_compare(rt_uint8_t key, rt_uint8_t repeat) { diff --git a/my_pro/myproject.c b/my_pro/myproject.c index bca369f..929590d 100644 --- a/my_pro/myproject.c +++ b/my_pro/myproject.c @@ -12,6 +12,7 @@ #include "mysnake.h" #include "infrared.h" #include +#include "my_func.h" char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0}; char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0}; @@ -209,8 +210,8 @@ void tmp_payload(void) my_round(20); page_first = 0; } - - show_lcd(); + greattime(); + // show_lcd(); } if (ps_data > 1022) {