Compare commits
2 Commits
5a90df0da8
...
43e6e6127f
Author | SHA1 | Date | |
---|---|---|---|
43e6e6127f | |||
207c11051f |
61
README.md
61
README.md
@ -1,6 +1,8 @@
|
||||
# My_project
|
||||
# 红外遥控贪吃蛇/显示+上传温度等数据
|
||||
### 红外遥控贪吃蛇
|
||||
|
||||

|
||||
|
||||
### 红外遥控器
|
||||
| 编号(key)| 功能 |
|
||||
| :----: | :----: |
|
||||
@ -14,6 +16,7 @@
|
||||
| 0x88 | 菜单 |
|
||||
| 0x28 | 退出 |
|
||||
|
||||
|
||||
### LCD 显示温湿度
|
||||

|
||||
左上角是(0,0) →x,↓y
|
||||
@ -21,6 +24,62 @@
|
||||
### 简易贪吃蛇
|
||||

|
||||
|
||||
### 页面切换、冻结(贪吃蛇与数据显示)
|
||||
``` c
|
||||
// 菜单(切换页面)
|
||||
if (repeat == 0 && (rt_strcmp(tmp, "88") == 0 || rt_strcmp(tmp, "11") == 0))
|
||||
{
|
||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||
page_first = 1;
|
||||
rt_kprintf("page_chosen = %d\n", page_chosen);
|
||||
}
|
||||
// 确认(暂停、页面冻结)
|
||||
if (repeat == 0 && (rt_strcmp(tmp, "73") == 0))
|
||||
{
|
||||
page_stop = (page_stop + 1) % 2;
|
||||
if (page_stop == 1)
|
||||
{
|
||||
lcd_show_string(240 - 24 * 3, 240 - 24, 24, "Stop");
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_show_string(240 - 24 * 3, 240 - 24, 24, " ");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### MQTT上传到阿里云
|
||||
#### 光照强度
|
||||

|
||||
#### 接近感应
|
||||

|
||||
#### 蛇长
|
||||

|
||||
#### 湿度
|
||||

|
||||
#### 温度
|
||||

|
||||
|
||||
### 显示时间
|
||||
[参考(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 说明
|
||||
|
||||
## 简介
|
||||
|
BIN
my_picture/光照强度.png
Normal file
BIN
my_picture/光照强度.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 150 KiB |
BIN
my_picture/接近感应.png
Normal file
BIN
my_picture/接近感应.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 131 KiB |
BIN
my_picture/温度.png
Normal file
BIN
my_picture/温度.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 KiB |
BIN
my_picture/湿度.png
Normal file
BIN
my_picture/湿度.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 169 KiB |
BIN
my_picture/蛇长.png
Normal file
BIN
my_picture/蛇长.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 116 KiB |
@ -4,8 +4,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <drv_lcd.h>
|
||||
#include <ntp.h>
|
||||
#include <time.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
|
@ -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();
|
||||
|
@ -7,7 +7,8 @@
|
||||
#define DBG_TAG "main"
|
||||
#define DBG_LVL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
#include <ulog.h>
|
||||
// #include <ulog.h>
|
||||
#include <drv_lcd.h>
|
||||
|
||||
/* 配置 LED 灯引脚 */
|
||||
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
||||
@ -20,35 +21,47 @@ 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)
|
||||
{
|
||||
rt_sprintf(tmp, "%02X", key);
|
||||
rt_atomic_store(&snake_pressed, snake_max + 1);
|
||||
|
||||
// 上
|
||||
if (rt_strcmp(tmp, "30") == 0 || rt_strcmp(tmp, "53") == 0)
|
||||
if (rt_atomic_load(&now_direction) != 2)
|
||||
rt_atomic_store(&now_direction, 0);
|
||||
|
||||
// 左
|
||||
if (rt_strcmp(tmp, "E8") == 0 || rt_strcmp(tmp, "99") == 0)
|
||||
if (rt_atomic_load(&now_direction) != 3)
|
||||
rt_atomic_store(&now_direction, 1);
|
||||
// 下
|
||||
if (rt_strcmp(tmp, "B0") == 0 || rt_strcmp(tmp, "4B") == 0)
|
||||
if (rt_atomic_load(&now_direction) != 0)
|
||||
rt_atomic_store(&now_direction, 2);
|
||||
// 右
|
||||
if (rt_strcmp(tmp, "68") == 0 || rt_strcmp(tmp, "83") == 0)
|
||||
if (rt_atomic_load(&now_direction) != 1)
|
||||
rt_atomic_store(&now_direction, 3);
|
||||
// 菜单(切换页面)
|
||||
if (repeat == 0 && (rt_strcmp(tmp, "88") == 0 || rt_strcmp(tmp, "11") == 0))
|
||||
{
|
||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||
page_first = 1;
|
||||
rt_kprintf("page_chosen = %d\n", page_chosen);
|
||||
}
|
||||
if (repeat == 0 && (rt_strcmp(tmp, "73") == 0 ))
|
||||
// 确认(暂停、页面冻结)
|
||||
if (repeat == 0 && (rt_strcmp(tmp, "73") == 0))
|
||||
{
|
||||
page_stop = (page_stop + 1) % 2;
|
||||
if (page_stop == 1)
|
||||
{
|
||||
lcd_show_string(240 - 24 * 3, 240 - 24, 24, "Stop");
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_show_string(240 - 24 * 3, 240 - 24, 24, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "mysnake.h"
|
||||
#include "infrared.h"
|
||||
#include <ulog.h>
|
||||
#include "my_func.h"
|
||||
|
||||
char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0};
|
||||
char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0};
|
||||
@ -205,13 +206,14 @@ void tmp_payload(void)
|
||||
{
|
||||
if (page_first)
|
||||
{
|
||||
rt_kprintf("page:Data\n");
|
||||
my_round(20);
|
||||
page_first = 0;
|
||||
}
|
||||
|
||||
show_lcd();
|
||||
greattime();
|
||||
// show_lcd();
|
||||
}
|
||||
if (ps_data > 14)
|
||||
if (ps_data > 1022)
|
||||
{
|
||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||
page_first = 1;
|
||||
|
@ -58,10 +58,12 @@ void snake_entry(void *parameter)
|
||||
int new_direction = 0,snake_now=0;
|
||||
while (1)
|
||||
{
|
||||
|
||||
if (page_chosen == 1&&!page_stop)
|
||||
{
|
||||
if (page_first == 1)
|
||||
{
|
||||
rt_kprintf("page:snake\n");
|
||||
page_first = 0;
|
||||
lcd_fill(0, 0, 240, 240, WHITE);
|
||||
snake_address(snake_food[0], snake_food[1], SNAKE_SIZE, GREEN);
|
||||
|
Loading…
x
Reference in New Issue
Block a user