Compare commits
2 Commits
c4bf317bee
...
ecb8ff9d6a
Author | SHA1 | Date | |
---|---|---|---|
ecb8ff9d6a | |||
827d08456c |
@ -59,7 +59,9 @@ const RGBColor_TypeDef LED_OFF = {0, 0, 0};
|
||||
const RGBColor_TypeDef LED_ON = {255, 255, 255};
|
||||
|
||||
//灯处于特定颜色还是闪烁状态
|
||||
uint8_t LED_staue[LED_NUM]={0};
|
||||
uint8_t LED_Blink_Staue[LED_NUM]={0};
|
||||
// 灯闪烁颜色缓存
|
||||
RGBColor_TypeDef LED_Blink_Color[LED_NUM] = {0};
|
||||
|
||||
// 灯颜色缓存
|
||||
RGBColor_TypeDef RGB_Data[LED_NUM] = {0};
|
||||
@ -166,31 +168,55 @@ void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color)
|
||||
}
|
||||
void LED_Set(uint16_t LedId, RGBColor_TypeDef Color)
|
||||
{
|
||||
LED_Blink_Staue[LedId]=0;
|
||||
RGB_Data[LedId].G = Color.G;
|
||||
RGB_Data[LedId].R = Color.R;
|
||||
RGB_Data[LedId].B = Color.B;
|
||||
RGB_Reflash();
|
||||
}
|
||||
void LED_Toggle(uint16_t LedId, RGBColor_TypeDef Color)
|
||||
void LED_Blink(uint16_t LedId, RGBColor_TypeDef Color)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
LED_Set(LedId,Color);
|
||||
rt_thread_mdelay(500);
|
||||
LED_Set(LedId,LED_OFF);
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
LED_Blink_Staue[LedId]=1;
|
||||
LED_Blink_Color[LedId]=Color;
|
||||
// while(1)
|
||||
// {
|
||||
// LED_Set(LedId,Color);
|
||||
// rt_thread_mdelay(500);
|
||||
// LED_Set(LedId,LED_OFF);
|
||||
// rt_thread_mdelay(500);
|
||||
// }
|
||||
}
|
||||
void LED_LITTLE_TEST(void)
|
||||
{
|
||||
LED_Set(1,LED_RED);
|
||||
rt_thread_mdelay(4000);
|
||||
LED_Toggle(1,LED_RED);
|
||||
rt_thread_mdelay(4000);
|
||||
LED_Set(1,LED_RED);
|
||||
rt_thread_mdelay(4000);
|
||||
LED_Toggle(1,LED_RED);
|
||||
rt_thread_mdelay(4000);
|
||||
uint8_t LED_Blink_ON=1;
|
||||
while(1)
|
||||
{
|
||||
for(int LedId=0;LedId<LED_NUM;LedId++)
|
||||
{
|
||||
if(LED_Blink_Staue[LedId])
|
||||
{
|
||||
if(LED_Blink_ON)
|
||||
{
|
||||
Set_LEDColor(LedId,LED_Blink_Color[LedId]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Set_LEDColor(LedId,LED_OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
LED_Blink_ON=!LED_Blink_ON;
|
||||
RGB_Reflash();
|
||||
rt_thread_mdelay(500);
|
||||
}
|
||||
// LED_Set(1,LED_RED);
|
||||
// rt_thread_mdelay(4000);
|
||||
// LED_Toggle(1,LED_RED);
|
||||
// rt_thread_mdelay(4000);
|
||||
// LED_Set(1,LED_RED);
|
||||
// rt_thread_mdelay(4000);
|
||||
// LED_Toggle(1,LED_RED);
|
||||
// rt_thread_mdelay(4000);
|
||||
}
|
||||
/**
|
||||
* @brief TIM发送控制ws2812
|
||||
|
@ -9,6 +9,12 @@ typedef struct RGBColor_TypeDef
|
||||
uint8_t B;
|
||||
} RGBColor_TypeDef; // 颜色结构体
|
||||
|
||||
|
||||
// //灯处于特定颜色还是闪烁状态
|
||||
// extern uint8_t LED_Blink_Staue[LED_NUM]={0};
|
||||
// // 灯闪烁颜色缓存
|
||||
// extern RGBColor_TypeDef LED_Blink_Color[LED_NUM] = {0};
|
||||
|
||||
extern const RGBColor_TypeDef LED_DARK;
|
||||
extern const RGBColor_TypeDef LED_GREEN;
|
||||
extern const RGBColor_TypeDef LED_RED;
|
||||
@ -16,7 +22,7 @@ extern const RGBColor_TypeDef LED_BLUE;
|
||||
extern const RGBColor_TypeDef LED_WHITE;
|
||||
extern void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color);
|
||||
extern void LED_Set(uint16_t LedId, RGBColor_TypeDef Color);
|
||||
extern void LED_Toggle(uint16_t LedId, RGBColor_TypeDef Color);
|
||||
extern void LED_Blink(uint16_t LedId, RGBColor_TypeDef Color);
|
||||
extern void RGB_Reflash(void);
|
||||
extern void LED_LITTLE_TEST(void);
|
||||
extern void led_matrix_rst();
|
||||
|
54
my_pro/mytest.c
Normal file
54
my_pro/mytest.c
Normal file
@ -0,0 +1,54 @@
|
||||
#include "drv_matrix_led.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void ledblink(int argc, char **argv){//设置/查询设备名称
|
||||
// if(argc < 2){
|
||||
// const rt_uint8_t Buffer[] = "AT+NAME\r\n";
|
||||
// rt_uint8_t len = rt_strlen((const char*)Buffer);
|
||||
// rt_device_write(Project_uart_Device,0,Buffer,len);
|
||||
// }else if(argc > 2){
|
||||
// rt_kprintf("Only one parameter can be entered\r\n");
|
||||
// }else{
|
||||
// char Buffer[] = "AT+NAME";
|
||||
// char* NewBuf = strcat(Buffer,argv[1]);
|
||||
// NewBuf = strcat(NewBuf,"\r\n");
|
||||
// rt_uint8_t len = rt_strlen((const char*)NewBuf);
|
||||
// rt_device_write(Project_uart_Device,0,NewBuf,len);
|
||||
// }
|
||||
int LedId = atoi(argv[1]);
|
||||
if(!rt_strcmp(argv[2],"RED"))
|
||||
{
|
||||
LED_Blink(LedId,LED_RED);
|
||||
}
|
||||
else if(!rt_strcmp(argv[2],"BLUE"))
|
||||
{
|
||||
LED_Blink(LedId,LED_BLUE);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(ledblink,LED0, "BLINK LedId Color");
|
||||
|
||||
void ledset(int argc, char **argv){//设置/查询设备名称
|
||||
// if(argc < 2){
|
||||
// const rt_uint8_t Buffer[] = "AT+NAME\r\n";
|
||||
// rt_uint8_t len = rt_strlen((const char*)Buffer);
|
||||
// rt_device_write(Project_uart_Device,0,Buffer,len);
|
||||
// }else if(argc > 2){
|
||||
// rt_kprintf("Only one parameter can be entered\r\n");
|
||||
// }else{
|
||||
// char Buffer[] = "AT+NAME";
|
||||
// char* NewBuf = strcat(Buffer,argv[1]);
|
||||
// NewBuf = strcat(NewBuf,"\r\n");
|
||||
// rt_uint8_t len = rt_strlen((const char*)NewBuf);
|
||||
// rt_device_write(Project_uart_Device,0,NewBuf,len);
|
||||
// }
|
||||
int LedId = atoi(argv[1]);
|
||||
if(!rt_strcmp(argv[2],"RED"))
|
||||
{
|
||||
LED_Set(LedId,LED_RED);
|
||||
}
|
||||
else if(!rt_strcmp(argv[2],"BLUE"))
|
||||
{
|
||||
LED_Set(LedId,LED_BLUE);
|
||||
}
|
||||
}
|
||||
MSH_CMD_EXPORT_ALIAS(ledset,LED1, "BLINK LedId Color");
|
Loading…
x
Reference in New Issue
Block a user