自己的设置颜色、闪烁函数(会卡在里面)
This commit is contained in:
@@ -55,6 +55,12 @@ const RGBColor_TypeDef LT_GREEN = {32, 0, 0};
|
||||
const RGBColor_TypeDef LT_BLUE = {0, 0, 32};
|
||||
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};
|
||||
|
||||
@@ -158,7 +164,34 @@ void Set_LEDColor(uint16_t LedId, RGBColor_TypeDef Color)
|
||||
RGB_Data[LedId].R = Color.R;
|
||||
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
|
||||
* @param[in] 待发送缓存
|
||||
|
@@ -15,6 +15,9 @@ extern const RGBColor_TypeDef LED_RED;
|
||||
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 RGB_Reflash(void);
|
||||
extern void LED_LITTLE_TEST(void);
|
||||
extern void led_matrix_rst();
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user