It works well but I'm a bit confused about the data structure newpixel_led, why are you using uint16_t instead of uint8_t? and why a 3 elements of that size if every color is represented with only 8-bits?
Hi, If we look at the data structure: typedef struct { uint16_t g[8]; uint16_t r[8]; uint16_t b[8]; } neopixel_led; Each member is an array with 8 elements, corresponding to the number of bits per color. For each bit, we need to generate a PWM signal with a particular duty cycle. For that purpose, we need 16-bit values. Hope I could answer your question.
hey I have one doubt I want to connect more led stripes in parallel then i want use the different timer pwm but I have problem in the configuration DMA request another timer dma does not show that dma trigger option But I will change the code like that but my code run only single timer In my main c this for tim 2 reset_all_leds(leds, NUMBER_OF_LEDS); HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_3, (uint32_t*)leds, NUMBER_OF_LEDS1 * 24 + 24); HAL_Delay(300); set_all_leds(leds, NUMBER_OF_LEDS1); HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_3, (uint32_t*)leds, NUMBER_OF_LEDS1 * 24 + 24); and this one is same code tim 3 led_pos_counter++; if(led_pos_counter == NUMBER_OF_LEDS) { led_pos_counter = 0; } temp_neo_pixel = circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS]; circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS]; circular_pattern_led[2* NUMBER_OF_LEDS]; HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_1, (uint32_t*)&circular_pattern_led[led_pos_counter], NUMBER_OF_LEDS * 24 + 24); HAL_Delay(100); circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS] = temp_neo_pixel;
I am happy to announce that I have a Patreon page🙂 where you can access projects' source code, including this one: patreon.com/user?u=80399744&Link&
I understand how these addressable LEDs work after watching this video. Keep doing great work. 💪
Thanks, will do!
It works well but I'm a bit confused about the data structure newpixel_led, why are you using uint16_t instead of uint8_t? and why a 3 elements of that size if every color is represented with only 8-bits?
Hi,
If we look at the data structure:
typedef struct
{
uint16_t g[8];
uint16_t r[8];
uint16_t b[8];
} neopixel_led;
Each member is an array with 8 elements, corresponding to the number of bits per color. For each bit, we need to generate a PWM signal with a particular duty cycle. For that purpose, we need 16-bit values. Hope I could answer your question.
hey I have one doubt I want to connect more led stripes in parallel then i want use the different timer pwm but I have problem in the configuration DMA request another timer dma does not show that dma trigger option But I will change the code like that but my code run only single timer In my main c this for tim 2 reset_all_leds(leds, NUMBER_OF_LEDS);
HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_3, (uint32_t*)leds, NUMBER_OF_LEDS1 * 24 + 24);
HAL_Delay(300);
set_all_leds(leds, NUMBER_OF_LEDS1);
HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_3, (uint32_t*)leds, NUMBER_OF_LEDS1 * 24 + 24); and
this one is same code
tim 3
led_pos_counter++;
if(led_pos_counter == NUMBER_OF_LEDS)
{
led_pos_counter = 0;
}
temp_neo_pixel = circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS];
circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS];
circular_pattern_led[2* NUMBER_OF_LEDS];
HAL_TIM_PWM_Start_DMA(&htim3, TIM_CHANNEL_1, (uint32_t*)&circular_pattern_led[led_pos_counter], NUMBER_OF_LEDS * 24 + 24);
HAL_Delay(100);
circular_pattern_led[led_pos_counter + NUMBER_OF_LEDS] = temp_neo_pixel;