可以分别显示具体时间

This commit is contained in:
james 2024-08-10 01:11:15 +08:00
parent 207c11051f
commit 43e6e6127f
5 changed files with 42 additions and 5 deletions

View File

@ -61,7 +61,24 @@
![alt text](my_picture/温度.png) ![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 说明 # STM32F407 星火一号开发板 BSP 说明

View File

@ -4,8 +4,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <drv_lcd.h> #include <drv_lcd.h>
#include <ntp.h> #include <ntp.h>
#include <time.h>
#define LCD_MAX 240 #define LCD_MAX 240
extern char tmp[];
void lcd_black(int x, int y) void lcd_black(int x, int y)
{ {
lcd_address_set(x, y, x, 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)); 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) void xy_round(int x, int y, int x2, int y2, int r, int ii)
{ {

View File

@ -5,6 +5,7 @@
// 当前方向 // 当前方向
void mytime(); void mytime();
void greattime();
void xy_round(int x, int y, int x2, int y2, int r, int ii); void xy_round(int x, int y, int x2, int y2, int r, int ii);
void my_round(int r); void my_round(int r);
void xy_sink(); void xy_sink();

View File

@ -7,7 +7,7 @@
#define DBG_TAG "main" #define DBG_TAG "main"
#define DBG_LVL DBG_LOG #define DBG_LVL DBG_LOG
#include <rtdbg.h> #include <rtdbg.h>
#include <ulog.h> // #include <ulog.h>
#include <drv_lcd.h> #include <drv_lcd.h>
/* 配置 LED 灯引脚 */ /* 配置 LED 灯引脚 */
@ -21,7 +21,7 @@ extern rt_atomic_t page_chosen;
extern rt_atomic_t page_first; extern rt_atomic_t page_first;
extern rt_atomic_t page_stop; extern rt_atomic_t page_stop;
extern int snake_max; extern int snake_max;
extern char tmp[10]; extern char tmp[];
void snake_compare(rt_uint8_t key, rt_uint8_t repeat) void snake_compare(rt_uint8_t key, rt_uint8_t repeat)
{ {

View File

@ -12,6 +12,7 @@
#include "mysnake.h" #include "mysnake.h"
#include "infrared.h" #include "infrared.h"
#include <ulog.h> #include <ulog.h>
#include "my_func.h"
char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0}; char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0};
char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0}; char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0};
@ -209,8 +210,8 @@ void tmp_payload(void)
my_round(20); my_round(20);
page_first = 0; page_first = 0;
} }
greattime();
show_lcd(); // show_lcd();
} }
if (ps_data > 1022) if (ps_data > 1022)
{ {