自己的设置颜色、闪烁函数(会卡在里面)
This commit is contained in:
parent
5de7792f95
commit
c4bf317bee
@ -55,6 +55,12 @@ const RGBColor_TypeDef LT_GREEN = {32, 0, 0};
|
|||||||
const RGBColor_TypeDef LT_BLUE = {0, 0, 32};
|
const RGBColor_TypeDef LT_BLUE = {0, 0, 32};
|
||||||
const RGBColor_TypeDef LT_WHITE = {16, 16, 16};
|
const RGBColor_TypeDef LT_WHITE = {16, 16, 16};
|
||||||
|
|
||||||
|
const RGBColor_TypeDef LED_OFF = {0, 0, 0};
|
||||||
|
const RGBColor_TypeDef LED_ON = {255, 255, 255};
|
||||||
|
|
||||||
|
//灯处于特定颜色还是闪烁状态
|
||||||
|
uint8_t LED_staue[LED_NUM]={0};
|
||||||
|
|
||||||
// 灯颜色缓存
|
// 灯颜色缓存
|
||||||
RGBColor_TypeDef RGB_Data[LED_NUM] = {0};
|
RGBColor_TypeDef RGB_Data[LED_NUM] = {0};
|
||||||
|
|
||||||
@ -158,7 +164,34 @@ void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color)
|
|||||||
RGB_Data[LedId].R = Color.R;
|
RGB_Data[LedId].R = Color.R;
|
||||||
RGB_Data[LedId].B = Color.B;
|
RGB_Data[LedId].B = Color.B;
|
||||||
}
|
}
|
||||||
|
void LED_Set(uint16_t LedId, RGBColor_TypeDef Color)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief TIM发送控制ws2812
|
* @brief TIM发送控制ws2812
|
||||||
* @param[in] 待发送缓存
|
* @param[in] 待发送缓存
|
||||||
|
@ -15,6 +15,9 @@ extern const RGBColor_TypeDef LED_RED;
|
|||||||
extern const RGBColor_TypeDef LED_BLUE;
|
extern const RGBColor_TypeDef LED_BLUE;
|
||||||
extern const RGBColor_TypeDef LED_WHITE;
|
extern const RGBColor_TypeDef LED_WHITE;
|
||||||
extern void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color);
|
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 RGB_Reflash(void);
|
extern void RGB_Reflash(void);
|
||||||
|
extern void LED_LITTLE_TEST(void);
|
||||||
extern void led_matrix_rst();
|
extern void led_matrix_rst();
|
||||||
#endif
|
#endif
|
||||||
|
@ -439,31 +439,34 @@ void led_matrix_example_entry(void *parameter)
|
|||||||
// RGB_Show_64(); // 调用RGB灯板显示函数
|
// RGB_Show_64(); // 调用RGB灯板显示函数
|
||||||
// rt_thread_mdelay(500);
|
// rt_thread_mdelay(500);
|
||||||
// }
|
// }
|
||||||
int count = 0;
|
|
||||||
while (1)
|
// int count = 0;
|
||||||
{
|
// while (1)
|
||||||
for (int i = EXTERN_LED_0; i <= EXTERN_LED_18; i++)
|
// {
|
||||||
{
|
// for (int i = EXTERN_LED_0; i <= EXTERN_LED_18; i++)
|
||||||
switch (count)
|
// {
|
||||||
{
|
// switch (count)
|
||||||
case 0:
|
// {
|
||||||
Set_LEDColor(i, LED_RED);
|
// case 0:
|
||||||
break;
|
// Set_LEDColor(i, LED_RED);
|
||||||
case 1:
|
// break;
|
||||||
Set_LEDColor(i, LED_GREEN);
|
// case 1:
|
||||||
break;
|
// Set_LEDColor(i, LED_GREEN);
|
||||||
case 2:
|
// break;
|
||||||
Set_LEDColor(i, LED_BLUE);
|
// case 2:
|
||||||
break;
|
// Set_LEDColor(i, LED_BLUE);
|
||||||
default:
|
// break;
|
||||||
return;
|
// default:
|
||||||
break;
|
// return;
|
||||||
}
|
// break;
|
||||||
RGB_Reflash();
|
// }
|
||||||
rt_thread_delay(20);
|
// RGB_Reflash();
|
||||||
}
|
// rt_thread_delay(20);
|
||||||
count = (count + 1) % 3;
|
// }
|
||||||
}
|
// count = (count + 1) % 3;
|
||||||
|
// }
|
||||||
|
|
||||||
|
LED_LITTLE_TEST();
|
||||||
}
|
}
|
||||||
// /* 用于接收消息的信号量 */
|
// /* 用于接收消息的信号量 */
|
||||||
// static struct rt_semaphore rx_sem;
|
// static struct rt_semaphore rx_sem;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user