开了红外接收又不行了

This commit is contained in:
2024-08-06 10:00:49 +08:00
parent e0434cae47
commit fea76c91f4
13 changed files with 97 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 857 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

56
my_pro/myirfrared.c Normal file
View File

@@ -0,0 +1,56 @@
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include "infrared.h"
#include <drv_gpio.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include <ulog.h>
/* 配置 LED 灯引脚 */
#define PIN_LED_B GET_PIN(F, 11) // PF11 : LED_B --> LED
#define PIN_LED_R GET_PIN(F, 12) // PF12 : LED_R --> LED
void myir_entry(void *parameter)
{
rt_kprintf("myir_entry\n");
unsigned int count = 1;
rt_int16_t key;
struct infrared_decoder_data infrared_data;
/* 选择 NEC 解码器 */
ir_select_decoder("nec");
/* 设置 RGB 引脚为输出模式*/
rt_pin_mode(PIN_LED_R, PIN_MODE_OUTPUT);
rt_pin_mode(PIN_LED_B, PIN_MODE_OUTPUT);
rt_pin_write(PIN_LED_R, PIN_HIGH);
rt_pin_write(PIN_LED_B, PIN_HIGH);
while (count > 0)
{
if (infrared_read("nec", &infrared_data) == RT_EOK)
{
/* 读取到红外数据,红灯亮起 */
rt_pin_write(PIN_LED_R, PIN_LOW);
LOG_I("RECEIVE OK: addr:0x%02X key:0x%02X repeat:%d", infrared_data.data.nec.addr,
infrared_data.data.nec.key, infrared_data.data.nec.repeat);
rt_kprintf("RECEIVE OK\n");
}
rt_thread_mdelay(10);
/* 熄灭蓝灯 */
rt_pin_write(PIN_LED_B, PIN_HIGH);
/* 熄灭红灯 */
rt_pin_write(PIN_LED_R, PIN_HIGH);
count++;
// if( count % 100 == 0)
// rt_kprintf("count = %d\n", count);
}
}

View File

@@ -11,6 +11,7 @@
#include <drv_lcd.h>
#include "mysnake.h"
char DEMO_PRODUCT_KEY[IOTX_PRODUCT_KEY_LEN + 1] = {0};
char DEMO_DEVICE_NAME[IOTX_DEVICE_NAME_LEN + 1] = {0};
char DEMO_DEVICE_SECRET[IOTX_DEVICE_SECRET_LEN + 1] = {0};
@@ -49,9 +50,13 @@ float brightness;
int lcd_y;
int int_tmp;
extern void myir_entry(void *parameter);
void ath_init(void);
void mqt_init(void);
int ap3_init(void);
void irf_init(void);
#define EXAMPLE_TRACE(fmt, ...) \
do \
@@ -300,6 +305,7 @@ static void mqtt_example_main(void *parameter)
rt_thread_t MQTT_Thread = RT_NULL;
rt_thread_t Snake_Thread = RT_NULL;
rt_thread_t Irfrared_Thread = RT_NULL;
void ath_init(void)
{
@@ -355,6 +361,20 @@ MSH_CMD_EXPORT_ALIAS(snk_init, snake, "snake game");
// return 0;
// }
void irf_init(void)
{
Irfrared_Thread = rt_thread_create("Irfrared_Thread", myir_entry, RT_NULL, THREAD_STACK_SIZE, THREAD_PRIORITY, THREAD_TIMESLICE);
if (Irfrared_Thread != RT_NULL)
{
rt_thread_startup(Irfrared_Thread);
}
else
{
rt_kprintf("Irfrared Thread Create Failed!\n");
}
}
MSH_CMD_EXPORT_ALIAS(irf_init, irf, "Irfrared");
void my_project(void)
{
ath_init();
@@ -362,5 +382,7 @@ void my_project(void)
mqt_init();
ap3_init();
irf_init();
}
MSH_CMD_EXPORT_ALIAS(my_project, myproject, run my project);

View File

@@ -1,8 +0,0 @@
### 使能了sd card
![alt text](image-2.png)
结果
![alt text](image.png)
关了就好了
![alt text](image-1.png)
### 开了soft rtc
![alt text](image-3.png)