light_ws2812#17618
Conversation
a18df22 to
27ef1c1
Compare
|
I think this PKG could be integrated into the existing ws281x driver as an alternative backend. See https://api.riot-os.org/group__drivers__ws281x.html |
27ef1c1 to
4dfdd1e
Compare
@maribu to be clear, are you thinking keep the package, and also add a reference to it in the ws281x driver? or eliminate adding it as a standalone package and ONLY update the driver? |
|
The current If this package gets added as a backend, it would benefit from the existing test application and existing users could directly make use of it. If it is added with a different API, users will have a hard time switching between different modes of generating the ws281x signal. |
|
That makes sense. So I think I will leave it in as a pkg, but then add the needful references to that package to the ws281x driver. That way if a developer wants to go as-slim-as-possible they can just use the package directly, or they can use the driver as you detailed. Does that sound good? |
|
@maribu please see the most recent commit. I verified it builds via the following operation: cd tests/driver_ws281x
CFLAGS="-DLIGHT_WS2812_UC_STM32G0XX -DLIGHT_WS2812_GPIO_PIN=7 -DLIGHT_WS2812_GPIO_PORT=GPIOA -DCONFIG_USE_CLOCK_HSI=1" make BOARD=nucleo-g070rb |
maribu
left a comment
There was a problem hiding this comment.
Sorry for being so slow to reply. I currently have a lot of other things to tend to :-/
I have some comments inline, mostly minor style nitpicks. However, the package currently only requires the features periph_gpio, which results in the build system assuming it to be compatible with all boards that have a GPIO driver (which I believe each and every board has). Consequently, the CI will try to build it also for e.g. RISC-V boards. In addition, the package is not compatible with all Cortex-M boards, see the long inline comment for more details.
The feature requirements need to be narrowed down so that make info-boards-supported will indeed only list actually supported boards. That way, the CI will pass and users with incompatible boards will get a build time error with a message naming the missing feature.
|
|
||
|
|
| { | ||
| puts("Generated RIOT application: 'light_ws2812'"); | ||
| random_init(SEED); | ||
| while(1) { |
There was a problem hiding this comment.
| while(1) { | |
| while (1) { |
| for (uint8_t idx = 0; idx < NUM_LEDS; idx++) { | ||
| leds[idx] = (uint8_t)random_uint32(); | ||
| } |
There was a problem hiding this comment.
| for (uint8_t idx = 0; idx < NUM_LEDS; idx++) { | |
| leds[idx] = (uint8_t)random_uint32(); | |
| } | |
| random_bytes(leds, sizeof(leds)); |
| #define SEED 234 | ||
|
|
||
| #define NUM_LEDS 5 | ||
| uint8_t leds[NUM_LEDS] = { 0x00}; |
There was a problem hiding this comment.
| uint8_t leds[NUM_LEDS] = { 0x00}; | |
| static uint8_t leds[3 * NUM_LEDS] = { 0x00 }; |
Shouldn't there be three bytes per LED?
There was a problem hiding this comment.
Ah, yes you're right. Good catch.
| USEMODULE += ws281x_esp32 | ||
| endif | ||
| ifneq (,$(filter arch_arm,$(FEATURES_USED))) | ||
| USEMODULE += ws281x_arm |
There was a problem hiding this comment.
| USEMODULE += ws281x_arm | |
| USEMODULE += ws281x_light_ws2812 |
Maybe the module could be named after the pkg that provides the implementation? After all, light_ws2812 also contains an implementation for AVR MCUs, so one could use it there as well. (Even though I think that at least one would have to change the #include "light_ws2812_cortex.h" with some preprocessor magic to pick the header corresponding to the arch.)
|
Cool. GitHub swallowed my comment regarding the features required My point was that the package has some requirements, namely:
Some background regarding the timing behavior: The AVR backend that I implemented uses CPU cycle counting in very much the same way the My suggestion is to introduce a new feature, e.g. named |
| CFLAGS += -DLIGHT_WS2812_UC_STM32G0XX | ||
|
|
||
| CFLAGS += -DLIGHT_WS2812_GPIO_PIN=7 | ||
| CFLAGS += -DLIGHT_WS2812_GPIO_PORT=GPIOA |
There was a problem hiding this comment.
I wonder if it would make sense to provide an light_ws2812_params.h e.g. similar to https://github.com/RIOT-OS/RIOT/blob/master/drivers/sht3x/include/sht3x_params.h
The main advantage would be that there would always be a valid fall-back configuration (so that the CI can compile applications using the pkg) and the macros could be documented there and would pop up in Doxygen. An application could provide its own light_ws2812_params.h in the application folder (the build system makes sure that the application folder is searched first for header files, so that one can rely on their own params overwriting the defaults).
|
This seems to need rebase now. Please ping me, when I should take another look. |
|
@david-vankampen ping :) |
…sed) ws2812 package, and example app using it
8914991 to
2a6277a
Compare
|
@maribu rebased |
2a6277a to
89ec78f
Compare
89ec78f to
1b6738e
Compare
|
OK, I took a closer look at this PR. Right now, it will only add support for STM32F0 and STM32G0 MCU families. It would require to add and maintain glue code to allow accessing the GPIO registers for setting and clearing GPIOs for each new CPU family. This would also be largely a duplicate effort compared to the GPIO LL API, which also exposes access to the GPIO set and clear registers. However, the GPIO LL API provides the I think that #19891 is the better approach and would work directly for all STM32 families, if the STM32 timer driver would have the I'll try to give a Also note that there is #20218 as well, which (ab)uses SPI and DMA for bit-banging. That is IMO even better than |
|
Would #20646 be a viable alternative for you? |
Contribution description
Adding 3rd party lib reference of light_ws2812, and example that leverages it
Testing procedure
if you hook up a ws2811 or ws2812 LED array to the pin specified with the arguments
you should see a random pattern being played across them when you flash the included example.