Hi,
Ā
The osDelay is delay function in free RTOS, the same as Arduino.
The entire sketch is as follows:
Ā
typedef struct
{
uint8_t B;
uint8_t R;
uint8_t G;
} led_pixel_t;
led_pixel_t g_colors[LED_FRAME_SIZE]={0};
void setPixel(int Pixel, uint8_t red, uint8_t green, uint8_t blue) {
g_colors[Pixel].R = red;
g_colors[Pixel].G = green;
g_colors[Pixel].B = blue;
}
void Light_Style_Curtain(void *data, int len)
{
light_style_color_curtain *tData = (light_style_color_curtain*)(data);
for(int i = 0; i < tData->u8RgbColorNum; i++ )
{
theaterChase(tData->u8aColorRgb[i].red, tData->u8aColorRgb[i].green, tData->u8aColorRgb[i].blue, tData->u8ColorSpeed);
}
}
Ā
void theaterChase(uint8_t red, uint8_t green, uint8_t blue, int SpeedDelay) {
for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
for (int q = 0; q < 3; q++) {
for (int i = 0; i < LED_FRAME_SIZE; i = i + 3) {
setPixel(i + q, red, green, blue); //turn every third pixel on
}
showStrip();
osDelay(SpeedDelay);
for (int i = 0; i < LED_FRAME_SIZE; i = i + 3) {
setPixel(i + q, 0, 0, 0); //turn every third pixel off
}
}
}
}
Ā