Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shpegun60/ws2812_dma
ws2812 project
https://github.com/shpegun60/ws2812_dma
nonblocking stm32 ws2812 ws2812-dma
Last synced: about 2 months ago
JSON representation
ws2812 project
- Host: GitHub
- URL: https://github.com/shpegun60/ws2812_dma
- Owner: shpegun60
- License: apache-2.0
- Created: 2022-02-20T18:03:15.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-20T18:35:30.000Z (almost 3 years ago)
- Last Synced: 2023-09-13T07:45:59.113Z (over 1 year ago)
- Topics: nonblocking, stm32, ws2812, ws2812-dma
- Language: C
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Nonblocking continious ws2812 handler
```c
#include "ws2812b.h"#define NUMBER_OF_LEDS 24
typedef struct {
RGB_t colors [NUMBER_OF_LEDS]; // or HSV_t
ws2812b_t ws2812b_obj;
} WS2812_Handle;extern TIM_HandleTypeDef htim1;
WS2812_Handle ws2812;int main () {
ws2812b_Init(&ws2812->ws2812b_obj, &htim1, TIM_CHANNEL_4);
//white color load
for(uint32_t i = 0; i < NUMBER_OF_LEDS; ++i) {
ws2812->colors[i].r = 0xFF;
ws2812->colors[i].g = 0xFF;
ws2812->colors[i].b = 0xFF;
}
while(1) {
if(ws2812b_IsReady(&ws2812->ws2812b_obj)) {
ws2812b_SendRGB(&ws2812->ws2812b_obj, ws2812->colors, NUMBER_OF_LEDS);
}
}
}// callbacks overwriting
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {
if(htim->Instance == ws2812.ws2812b_obj.tim->Instance) {
ws2812b_dma_handler(&ws2812.ws2812b_obj, 0);
}
}void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim) {
if(htim->Instance == ws2812.ws2812b_obj.tim->Instance) {
ws2812b_dma_handler(&ws2812.ws2812b_obj, 1);
}
}```