Compare commits
No commits in common. "43e6e6127f4d53b06ffad422809af9a9dad64471" and "5a90df0da826670da9d064c07d8ab1b20e77aaff" have entirely different histories.
43e6e6127f
...
5a90df0da8
61
README.md
61
README.md
@ -1,8 +1,6 @@
|
|||||||
# 红外遥控贪吃蛇/显示+上传温度等数据
|
# My_project
|
||||||
### 红外遥控贪吃蛇
|
### 红外遥控贪吃蛇
|
||||||
|
|
||||||

|

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

|

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

|

|
||||||
|
|
||||||
### 页面切换、冻结(贪吃蛇与数据显示)
|
|
||||||
``` 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 说明
|
# STM32F407 星火一号开发板 BSP 说明
|
||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 150 KiB |
Binary file not shown.
Before Width: | Height: | Size: 131 KiB |
Binary file not shown.
Before Width: | Height: | Size: 165 KiB |
Binary file not shown.
Before Width: | Height: | Size: 169 KiB |
Binary file not shown.
Before Width: | Height: | Size: 116 KiB |
@ -4,11 +4,8 @@
|
|||||||
#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);
|
||||||
@ -44,21 +41,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// 当前方向
|
// 当前方向
|
||||||
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();
|
||||||
|
@ -7,8 +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>
|
|
||||||
|
|
||||||
/* 配置 LED 灯引脚 */
|
/* 配置 LED 灯引脚 */
|
||||||
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
|
||||||
@ -21,47 +20,35 @@ 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[];
|
extern char tmp[10];
|
||||||
|
|
||||||
void snake_compare(rt_uint8_t key, rt_uint8_t repeat)
|
void snake_compare(rt_uint8_t key, rt_uint8_t repeat)
|
||||||
{
|
{
|
||||||
rt_sprintf(tmp, "%02X", key);
|
rt_sprintf(tmp, "%02X", key);
|
||||||
rt_atomic_store(&snake_pressed, snake_max + 1);
|
rt_atomic_store(&snake_pressed, snake_max + 1);
|
||||||
// 上
|
|
||||||
if (rt_strcmp(tmp, "30") == 0 || rt_strcmp(tmp, "53") == 0)
|
if (rt_strcmp(tmp, "30") == 0 || rt_strcmp(tmp, "53") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 2)
|
if (rt_atomic_load(&now_direction) != 2)
|
||||||
rt_atomic_store(&now_direction, 0);
|
rt_atomic_store(&now_direction, 0);
|
||||||
// 左
|
|
||||||
if (rt_strcmp(tmp, "E8") == 0 || rt_strcmp(tmp, "99") == 0)
|
if (rt_strcmp(tmp, "E8") == 0 || rt_strcmp(tmp, "99") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 3)
|
if (rt_atomic_load(&now_direction) != 3)
|
||||||
rt_atomic_store(&now_direction, 1);
|
rt_atomic_store(&now_direction, 1);
|
||||||
// 下
|
|
||||||
if (rt_strcmp(tmp, "B0") == 0 || rt_strcmp(tmp, "4B") == 0)
|
if (rt_strcmp(tmp, "B0") == 0 || rt_strcmp(tmp, "4B") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 0)
|
if (rt_atomic_load(&now_direction) != 0)
|
||||||
rt_atomic_store(&now_direction, 2);
|
rt_atomic_store(&now_direction, 2);
|
||||||
// 右
|
|
||||||
if (rt_strcmp(tmp, "68") == 0 || rt_strcmp(tmp, "83") == 0)
|
if (rt_strcmp(tmp, "68") == 0 || rt_strcmp(tmp, "83") == 0)
|
||||||
if (rt_atomic_load(&now_direction) != 1)
|
if (rt_atomic_load(&now_direction) != 1)
|
||||||
rt_atomic_store(&now_direction, 3);
|
rt_atomic_store(&now_direction, 3);
|
||||||
// 菜单(切换页面)
|
|
||||||
if (repeat == 0 && (rt_strcmp(tmp, "88") == 0 || rt_strcmp(tmp, "11") == 0))
|
if (repeat == 0 && (rt_strcmp(tmp, "88") == 0 || rt_strcmp(tmp, "11") == 0))
|
||||||
{
|
{
|
||||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||||
page_first = 1;
|
page_first = 1;
|
||||||
rt_kprintf("page_chosen = %d\n", page_chosen);
|
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;
|
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,7 +12,6 @@
|
|||||||
#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};
|
||||||
@ -206,14 +205,13 @@ void tmp_payload(void)
|
|||||||
{
|
{
|
||||||
if (page_first)
|
if (page_first)
|
||||||
{
|
{
|
||||||
rt_kprintf("page:Data\n");
|
|
||||||
my_round(20);
|
my_round(20);
|
||||||
page_first = 0;
|
page_first = 0;
|
||||||
}
|
}
|
||||||
greattime();
|
|
||||||
// show_lcd();
|
show_lcd();
|
||||||
}
|
}
|
||||||
if (ps_data > 1022)
|
if (ps_data > 14)
|
||||||
{
|
{
|
||||||
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
page_chosen = (page_chosen % PAGE_MAX) + 1;
|
||||||
page_first = 1;
|
page_first = 1;
|
||||||
|
@ -58,12 +58,10 @@ void snake_entry(void *parameter)
|
|||||||
int new_direction = 0,snake_now=0;
|
int new_direction = 0,snake_now=0;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (page_chosen == 1&&!page_stop)
|
if (page_chosen == 1&&!page_stop)
|
||||||
{
|
{
|
||||||
if (page_first == 1)
|
if (page_first == 1)
|
||||||
{
|
{
|
||||||
rt_kprintf("page:snake\n");
|
|
||||||
page_first = 0;
|
page_first = 0;
|
||||||
lcd_fill(0, 0, 240, 240, WHITE);
|
lcd_fill(0, 0, 240, 240, WHITE);
|
||||||
snake_address(snake_food[0], snake_food[1], SNAKE_SIZE, GREEN);
|
snake_address(snake_food[0], snake_food[1], SNAKE_SIZE, GREEN);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user