PIO WS2812 example - bug in `pattern_fade()`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 28/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- c
- Domain
- embedded-iot
Research direction
Start in pio/ws2812/ws2812_parallel.c at pattern_fade(), especially lines 96-97, and trace how slow_t and level are used afterward. Compare the current pixel output with the intended fade behavior and confirm the intended operator with project maintainers. Done means the example no longer alternates only between black and 0x010101 and the expected behavior is documented by a focused check.
Written by the indexing model from the issue text.
Description
This bug is found at the start of the function, pattern_fade():
-
Line 96 sets
slow_tto a value that depends on the second function parameter. This makes sense.
https://github.com/raspberrypi/pico-examples/blob/33854562cd08398c4b48bb1ed7fa022c2177076d/pio/ws2812/ws2812_parallel.c#L96 -
Line 97, however, sets
slow_tto a fixed, constant value of 8 (variablelevelis defined at line 88, never modified).
https://github.com/raspberrypi/pico-examples/blob/33854562cd08398c4b48bb1ed7fa022c2177076d/pio/ws2812/ws2812_parallel.c#L97
If I followed it correctly, the current code results in alternately setting all pixels to RGB 0x000000 (black), or setting all pixels to RGB 0x010101. Clearly not the intended behavior.
Most likely, line 97 was intended to be an operator that modified the existing value, such as any of:
slow_t += level;
slow_t -= level;
slow_t *= level;
slow_t /= level;
slow_t <<= level;
slow_t >>= level;
Unfortunately, I am note 100% sure what the intended result was.
My best guess? It's an attempt to add half the potential error, so integer division / masking later makes calculating the error amount easier.
slow_t += level; // increase provided value by half of (1 << shift)?
@kilograham ... any ideas who would know the intended results here, and might confirm the intended behavior here?
Thanks!
- Dominant language
- C
- Stars
- 3.9k
- Forks
- 1k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/pico-examples
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
raspberrypi/pico-examples#788 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
raspberrypi/pico-examples#780 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
raspberrypi/pico-examples#262 · 2 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
raspberrypi/pico-examples#224 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
raspberrypi/pico-examples#783 ·
All issues in raspberrypi/pico-examples
Similar issues
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarbourMasters/Shipwright#7229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
riscv-software-src/riscv-isa-sim#2435 · 1 comment ·
-
bug Self Built Image SNAPSHOT Supported Device target/ramips
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100