-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pico: add "neopixel" led support (WS2812) #841
Open
Cpasjuste
wants to merge
5
commits into
32blit:master
Choose a base branch
from
Cpasjuste:microboy
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+82
−1
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d13a0d1
gitignore: use wildcard for cmake build directories
Cpasjuste deec004
pico: add "neopixel" led support (WS2812)
Cpasjuste e432a02
pico: set default "neopixel" rgb led (WS2812) value to off at init_led
Cpasjuste d2d5f7f
pico: add "neopixel" led support (WS2812) fix 1
Cpasjuste 5198471
pico: add "neopixel" led support (WS2812) fix 2
Cpasjuste File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ bld/ | |
build/ | ||
build.stm32/ | ||
build.mingw/ | ||
cmake-build-debug/ | ||
cmake-build-*/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
[Ll]og/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
; | ||
; Copyright (c) 2020 Raspberry Pi (Trading) Ltd. | ||
; | ||
; SPDX-License-Identifier: BSD-3-Clause | ||
; | ||
|
||
.program ws2812 | ||
.side_set 1 | ||
|
||
.define public T1 2 | ||
.define public T2 5 | ||
.define public T3 3 | ||
|
||
.lang_opt python sideset_init = pico.PIO.OUT_HIGH | ||
.lang_opt python out_init = pico.PIO.OUT_HIGH | ||
.lang_opt python out_shiftdir = 1 | ||
|
||
.wrap_target | ||
bitloop: | ||
out x, 1 side 0 [T3 - 1] ; Side-set still takes place when instruction stalls | ||
jmp !x do_zero side 1 [T1 - 1] ; Branch on the bit we shifted out. Positive pulse | ||
do_one: | ||
jmp bitloop side 1 [T2 - 1] ; Continue driving high, for a long pulse | ||
do_zero: | ||
nop side 0 [T2 - 1] ; Or drive low, for a short pulse | ||
.wrap | ||
|
||
% c-sdk { | ||
#include "hardware/clocks.h" | ||
|
||
static inline void ws2812_program_init(PIO pio, uint sm, uint offset, uint pin, float freq, bool rgbw) { | ||
|
||
pio_gpio_init(pio, pin); | ||
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true); | ||
|
||
pio_sm_config c = ws2812_program_get_default_config(offset); | ||
sm_config_set_sideset_pins(&c, pin); | ||
sm_config_set_out_shift(&c, false, true, rgbw ? 32 : 24); | ||
sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); | ||
|
||
int cycles_per_bit = ws2812_T1 + ws2812_T2 + ws2812_T3; | ||
float div = clock_get_hz(clk_sys) / (freq * cycles_per_bit); | ||
sm_config_set_clkdiv(&c, div); | ||
|
||
pio_sm_init(pio, sm, offset, &c); | ||
pio_sm_set_enabled(pio, sm, true); | ||
} | ||
%} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a comment on the actual change, but I've just noticed that the previous three lines are duplicated with line 340/341... (except that one has a wildcard)