qmk_firmware icon indicating copy to clipboard operation
qmk_firmware copied to clipboard

[Core] Allow custom timings for WS2812 PIO driver

Open KarlK90 opened this issue 3 years ago • 3 comments

Description

Allows setting of custom WS2812 timings using the defines found in ws2812.h, it also uses these timings as it's default now. Furthermore the reset timing is now applied correctly before starting a new transfer. Due to implementation details the waiting times are rounded to 50ns intervals.

WS2812 default timings

Period Time
WS2812_T1H 900ns
WS2812_T1L 350ns
WS2812_T0H 350ns
WS2812_T0L 900ns
RESET 280us

T1H + T1L

image

T0H + T0L

image

Reset

image

SK6812 timings

Period Time
WS2812_T1H 500ns
WS2812_T1L 450ns
WS2812_T0H 400ns
WS2812_T0L 750ns
RESET 80us

T1H + T1L

image

T0H + T0L

image

Reset

Deviation from 80us due to the driver choosing the longer T0H + T0L or T1H + T1L period which is irregular in this case.

image

Types of Changes

  • [x] Core
  • [x] Bugfix
  • [x] New feature
  • [x] Enhancement/optimization
  • [ ] Keyboard (addition or update)
  • [ ] Keymap/layout/userspace (addition or update)
  • [x] Documentation

Issues Fixed or Closed by This PR

Checklist

  • [x] My code follows the code style of this project: C, Python
  • [x] I have read the PR Checklist document and have made the appropriate changes.
  • [x] My change requires a change to the documentation.
  • [x] I have updated the documentation accordingly.
  • [x] I have read the CONTRIBUTING document.
  • [ ] I have added tests to cover my changes.
  • [x] I have tested the changes and verified that they work and don't break anything (as well as I can manage).

KarlK90 avatar Aug 12 '22 11:08 KarlK90

CC: @xyzz @jepler

KarlK90 avatar Aug 12 '22 12:08 KarlK90

Yay ARRAY_SIZE

jepler avatar Aug 14 '22 19:08 jepler

@sigprof If you happen to have some spare time I would like your opinion on this implementation :slightly_smiling_face:

KarlK90 avatar Sep 11 '22 16:09 KarlK90

Tested and running stable since ~2 months on my RP2040 keyboard

KarlK90 avatar Nov 08 '22 09:11 KarlK90