drivers/ws281x: add VT100 backend for native#12793
Conversation
|
Meh, it looks like there is currently no way to have two disjunctive |
|
You can use features optional and in the second recursive round of dependency resolution the optional feature becomes used, if it is available |
drivers/Makefile.dep
Outdated
| USEMODULE += ws281x_atmega | ||
| endif | ||
| # fall back to VT100 terminal output if no other | ||
| # backend is availiable. |
There was a problem hiding this comment.
| # backend is availiable. | |
| # backend is available. |
drivers/Makefile.dep
Outdated
| USEMODULE += xtimer | ||
| endif | ||
|
|
||
| ifneq (,$(filter ws281x_vt100,$(USEMODULE))) |
There was a problem hiding this comment.
This block should be moved to drivers/Makefile.include
There was a problem hiding this comment.
But it looks so out of place there. 😮
There was a problem hiding this comment.
The idea of the Makefile.dep is to set/resolve the dependencies of a module in the build. Makefile.include should contain code for setting build configuration variables. For me, CFLAGS is a build configuration variable, so it should be in drivers/Makefile.include.
git grep gives an opposite result as what I just said but I think the already existing CFLAGS defined in Makefile.dep should be moved in Makefile.include.
There was a problem hiding this comment.
I think the cleanest option would be to have those defines in a header file. Via CFLAGS, those defines are available for every module and compilation unit, even though they are only needed for the ws281x module.
I see to options for using a header file for this:
a) A common header, let's say ws281x_backend.h, which uses #ifdef MODULE_WS281X_<BACKEND> to provide the required defines.
b) A separated ws281x_backend.h for each backend located at drivers/ws281x/include/<BACKEND_NAME>/ws281x_backend.h. And Makefile.include is used to add drivers/ws281x/include/<BACKEND_NAME> to INCLUDES for the used backend.
There was a problem hiding this comment.
The simpler the better - I prefer option a).
But then How about just using the |
|
Like this: ifneq (,$(filter ws281x,$(USEMODULE)))
FEATURES_OPTIONAL += arch_avr8 arch_native
ifeq (,$(filter ws281x_%,$(USEMODULE)))
ifneq (,$(filter arch_avr8,$(FEATURES_USED)))
USEMODULE += ws281x_atmega
endif
ifneq (,$(filter arch_avr8,$(FEATURES_USED)))
USEMODULE += ws281x_vt100
endif
USEMODULE += xtimer
endif |
|
You need to overwrite the |
tests/driver_ws281x/Makefile
Outdated
| @@ -1,4 +1,4 @@ | |||
| BOARD ?= atmega328p | |||
| BOARD ?= native | |||
There was a problem hiding this comment.
How about adding:
ifneq (native,$(BOARD))
FEATURES_REQUIRED := arch_avr8
endifThere was a problem hiding this comment.
That's what I tried first.
The problem is that Murdock then parsed the file differently than make would (not sure which script is responsible for it) and ended up building it for all platforms, ignoring the conditional FEATURES_REQUIRED.
There was a problem hiding this comment.
Murdock uses make info-boards-supported to get the list of supported boards. In the worst case, we would need to add FEATURES_PROVIDED += ws281x_backend to cpu/atmega_common/Makefile.features and to cpu/native/Makefile.features and require that... But I'm not really thrilled but that idea.
There was a problem hiding this comment.
The problem is that Murdock then parsed the file differently than
makewould (not sure which script is responsible for it) and ended up building it for all platforms, ignoring the conditionalFEATURES_REQUIRED.
No, the issue is that the main application Makefile always gets fully evaluated before info-boards-supported, independent of Murdock.
So the if native: require avr thing needs to be somewhere in Makefile.dep. (It seems weird to begin with, though though. 😉 )
There was a problem hiding this comment.
So the
if native: require avrthing needs to be somewhere in Makefile.dep. (It seems weird to begin with, though though. )
That will work for native, but what if we add that SPI backed?
Testing the contents of FEATURES_PROVIDED is not allowed and I'd rather not maintain a BOARD_PROVIDES_SPI list shiver
5c2aa25 to
0657fd3
Compare
maribu
left a comment
There was a problem hiding this comment.
ACK. Code looks good and the animations work quite well on the terminal :-D
|
I think I finally worked up the review backlog I was carrying around :-) |
To quickly iterate on animations it is handy to being able to simulate the output on native. This adds a VT100 terminal backend to the ws281x driver that outputs the colors straight to the terminal.
f6a3583 to
d80d42a
Compare
|
Thank you for all the reviews! 😄 |
Also add an additional newline before each test title to improve the rendering on native console output.
This brings the backend-dependant init() function in line with `WS281X_HAVE_PREPARE_TRANSMISSION` and `WS281X_HAVE_END_TRANSMISSION`.
d80d42a to
11d7727
Compare
Contribution description
To quickly iterate on animations it is handy to being able to simulate the output on native.
This adds a VT100 terminal backend to the ws281x driver that outputs the colors straight to the terminal.
It should work with any sufficiently modern terminal emulator.
Testing procedure
run
tests/driver_ws281xonnative.Issues/PRs references