Skip to content

Commit

Permalink
Update WS2812 docs and add APA102 docs (qmk#22106)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Brassel <[email protected]>
  • Loading branch information
2 people authored and mhamrah committed Feb 5, 2024
1 parent 7d43f65 commit 160326c
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions docs/ws2812_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ You can then call the WS2812 API by including `ws2812.h` in your code.

Add the following to your `config.h`:

<<<<<<< HEAD
<<<<<<< HEAD
|Define |Default |Description |
|-------------------|-----------------------|------------------------------------------------------------------------------------------------|
Expand All @@ -35,6 +36,8 @@ Add the following to your `config.h`:
|`WS2812_TRST_US` |`280` |The length of the reset phase in microseconds |
|`WS2812_BYTE_ORDER`|`WS2812_BYTE_ORDER_GRB`|The byte order of the RGB data |
=======
=======
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
| Define | Default | Description |
| ------------------- | ----------------------- | ------------------------------------------------------------------------------------------------ |
| `WS2812_DI_PIN` | *Not defined* | The GPIO pin connected to the DI pin of the first LED in the chain |
Expand All @@ -44,7 +47,21 @@ Add the following to your `config.h`:
| `WS2812_T0H` | `350` | The length of a "0" bit's high phase in nanoseconds |
| `WS2812_TRST_US` | `280` | The length of the reset phase in microseconds |
| `WS2812_BYTE_ORDER` | `WS2812_BYTE_ORDER_GRB` | The byte order of the RGB data |
<<<<<<< HEAD
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
=======
|Define |Default |Description |
|-------------------|-----------------------|------------------------------------------------------------------------------------------------|
|`WS2812_DI_PIN` |*Not defined* |The GPIO pin connected to the DI pin of the first LED in the chain |
|`WS2812_LED_COUNT` |*Not defined* |Number of LEDs in the WS2812 chain - automatically set when RGBLight or RGB Matrix is configured|
|`WS2812_TIMING` |`1250` |The total length of a bit (TH+TL) in nanoseconds |
|`WS2812_T1H` |`900` |The length of a "1" bit's high phase in nanoseconds |
|`WS2812_T0H` |`350` |The length of a "0" bit's high phase in nanoseconds |
|`WS2812_TRST_US` |`280` |The length of the reset phase in microseconds |
|`WS2812_BYTE_ORDER`|`WS2812_BYTE_ORDER_GRB`|The byte order of the RGB data |
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
### Timing Adjustment :id=timing-adjustment

Expand All @@ -64,19 +81,32 @@ If you find your LED colors are consistently swapped, you may need to change the
Where the byte order may be one of:
<<<<<<< HEAD
<<<<<<< HEAD
|Byte Order|Known Devices |
|----------|----------------------------|
|`GRB` |Most WS2812s, SK6812, SK6805|
|`RGB` |WS2812B-2020 |
|`BGR` |TM1812 |
=======
=======
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
| Byte Order | Known Devices |
| ---------- | ---------------------------- |
| `GRB` | Most WS2812s, SK6812, SK6805 |
| `RGB` | WS2812B-2020 |
| `BGR` | TM1812 |
<<<<<<< HEAD
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
=======
|Byte Order|Known Devices |
|----------|----------------------------|
|`GRB` |Most WS2812s, SK6812, SK6805|
|`RGB` |WS2812B-2020 |
|`BGR` |TM1812 |
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
## Driver Configuration :id=driver-configuration
Expand All @@ -102,17 +132,29 @@ WS2812_DRIVER = i2c

The following `#define`s apply only to the `i2c` driver:

<<<<<<< HEAD
<<<<<<< HEAD
|Define |Default|Description |
|--------------------|-------|---------------------------------|
|`WS2812_I2C_ADDRESS`|`0xB0` |The I2C address of the ATtiny85. |
|`WS2812_I2C_TIMEOUT`|`100` |The I2C timeout, in milliseconds.|
=======
=======
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
| Define | Default | Description |
| -------------------- | ------- | --------------------------------- |
| `WS2812_I2C_ADDRESS` | `0xB0` | The I2C address of the ATtiny85. |
| `WS2812_I2C_TIMEOUT` | `100` | The I2C timeout, in milliseconds. |
<<<<<<< HEAD
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
=======
|Define |Default|Description |
|--------------------|-------|---------------------------------|
|`WS2812_I2C_ADDRESS`|`0xB0` |The I2C address of the ATtiny85. |
|`WS2812_I2C_TIMEOUT`|`100` |The I2C timeout, in milliseconds.|
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
### PIO Driver :id=pio-driver

Expand Down Expand Up @@ -144,17 +186,29 @@ WS2812_DRIVER = spi

The following defines apply only to ARM devices:

<<<<<<< HEAD
<<<<<<< HEAD
|Define |Default |Description |
|------------|------------------------------|---------------------------------------------------------------------------------|
|`WS2812_T1L`|`(WS2812_TIMING - WS2812_T1H)`|The length of a "1" bit's low phase in nanoseconds (bitbang and PIO drivers only)|
|`WS2812_T0L`|`(WS2812_TIMING - WS2812_T0H)`|The length of a "0" bit's low phase in nanoseconds (bitbang and PIO drivers only)|
=======
=======
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
| Define | Default | Description |
| ------------ | ------------------------------ | --------------------------------------------------------------------------------- |
| `WS2812_T1L` | `(WS2812_TIMING - WS2812_T1H)` | The length of a "1" bit's low phase in nanoseconds (bitbang and PIO drivers only) |
| `WS2812_T0L` | `(WS2812_TIMING - WS2812_T0H)` | The length of a "0" bit's low phase in nanoseconds (bitbang and PIO drivers only) |
<<<<<<< HEAD
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
=======
|Define |Default |Description |
|------------|------------------------------|---------------------------------------------------------------------------------|
|`WS2812_T1L`|`(WS2812_TIMING - WS2812_T1H)`|The length of a "1" bit's low phase in nanoseconds (bitbang and PIO drivers only)|
|`WS2812_T0L`|`(WS2812_TIMING - WS2812_T0H)`|The length of a "0" bit's low phase in nanoseconds (bitbang and PIO drivers only)|
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
### Push-Pull and Open Drain :id=push-pull-open-drain

Expand Down Expand Up @@ -184,6 +238,7 @@ Depending on the ChibiOS board configuration, you may need to enable SPI at the

The following `define`s apply only to the `spi` driver:

<<<<<<< HEAD
<<<<<<< HEAD
|Define |Default |Description |
|--------------------------------|-------------|-------------------------------------------------------------------------------|
Expand All @@ -194,6 +249,8 @@ The following `define`s apply only to the `spi` driver:
|`WS2812_SPI_DIVISOR` |`16` |The divisor used to adjust the baudrate |
|`WS2812_SPI_USE_CIRCULAR_BUFFER`|*Not defined*|Enable a circular buffer for improved rendering |
=======
=======
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
| Define | Default | Description |
| -------------------------------- | ------------- | ------------------------------------------------------------------------------- |
| `WS2812_SPI_DRIVER` | `SPID1` | The SPI driver to use |
Expand All @@ -202,7 +259,20 @@ The following `define`s apply only to the `spi` driver:
| `WS2812_SPI_SCK_PAL_MODE` | `5` | The SCK pin alternative function to use - required for F072 and possibly others |
| `WS2812_SPI_DIVISOR` | `16` | The divisor used to adjust the baudrate |
| `WS2812_SPI_USE_CIRCULAR_BUFFER` | *Not defined* | Enable a circular buffer for improved rendering |
<<<<<<< HEAD
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
=======
|Define |Default |Description |
|--------------------------------|-------------|-------------------------------------------------------------------------------|
|`WS2812_SPI_DRIVER` |`SPID1` |The SPI driver to use |
|`WS2812_SPI_MOSI_PAL_MODE` |`5` |The MOSI pin alternative function to use |
|`WS2812_SPI_SCK_PIN` |*Not defined*|The SCK pin - required for F072 and possibly others |
|`WS2812_SPI_SCK_PAL_MODE` |`5` |The SCK pin alternative function to use - required for F072 and possibly others|
|`WS2812_SPI_DIVISOR` |`16` |The divisor used to adjust the baudrate |
|`WS2812_SPI_USE_CIRCULAR_BUFFER`|*Not defined*|Enable a circular buffer for improved rendering |
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
#### Setting the Baudrate :id=arm-spi-baudrate

Expand All @@ -228,6 +298,7 @@ To enable the circular buffer, add the following to your `config.h`:

The following `#define`s apply only to the PIO driver:

<<<<<<< HEAD
<<<<<<< HEAD
|Define |Default |Description |
|---------------------|-------------|---------------------------------------|
Expand All @@ -237,6 +308,16 @@ The following `#define`s apply only to the PIO driver:
| --------------------- | ------------- | --------------------------------------- |
| `WS2812_PIO_USE_PIO1` | *Not defined* | Use the PIO1 peripheral instead of PIO0 |
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
| Define | Default | Description |
| --------------------- | ------------- | --------------------------------------- |
| `WS2812_PIO_USE_PIO1` | *Not defined* | Use the PIO1 peripheral instead of PIO0 |
=======
|Define |Default |Description |
|---------------------|-------------|---------------------------------------|
|`WS2812_PIO_USE_PIO1`|*Not defined*|Use the PIO1 peripheral instead of PIO0|
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
### PWM Driver :id=arm-pwm-driver

Expand All @@ -254,6 +335,7 @@ Depending on the ChibiOS board configuration, you may need to enable PWM at the

The following `#define`s apply only to the `pwm` driver:

<<<<<<< HEAD
<<<<<<< HEAD
|Define |Default |Description |
|---------------------------------|--------------------|------------------------------------------------------------------------------------------|
Expand All @@ -265,6 +347,8 @@ The following `#define`s apply only to the `pwm` driver:
|`WS2812_DMAMUX_ID` |*Not defined* |The DMAMUX configuration for `TIMx_UP` - only required if your MCU has a DMAMUX peripheral|
|`WS2812_PWM_COMPLEMENTARY_OUTPUT`|*Not defined* |Whether the PWM output is complementary (`TIMx_CHyN`) |
=======
=======
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
| Define | Default | Description |
| --------------------------------- | -------------------- | ------------------------------------------------------------------------------------------ |
| `WS2812_PWM_DRIVER` | `PWMD2` | The PWM driver to use |
Expand All @@ -274,7 +358,21 @@ The following `#define`s apply only to the `pwm` driver:
| `WS2812_DMA_CHANNEL` | `2` | The DMA Channel for `TIMx_UP` |
| `WS2812_DMAMUX_ID` | *Not defined* | The DMAMUX configuration for `TIMx_UP` - only required if your MCU has a DMAMUX peripheral |
| `WS2812_PWM_COMPLEMENTARY_OUTPUT` | *Not defined* | Whether the PWM output is complementary (`TIMx_CHyN`) |
<<<<<<< HEAD
>>>>>>> b1dbb92641 (Update WS2812 docs and add APA102 docs (#22106))
=======
=======
|Define |Default |Description |
|---------------------------------|--------------------|------------------------------------------------------------------------------------------|
|`WS2812_PWM_DRIVER` |`PWMD2` |The PWM driver to use |
|`WS2812_PWM_CHANNEL` |`2` |The PWM channel to use |
|`WS2812_PWM_PAL_MODE` |`2` |The pin alternative function to use |
|`WS2812_DMA_STREAM` |`STM32_DMA1_STREAM2`|The DMA Stream for `TIMx_UP` |
|`WS2812_DMA_CHANNEL` |`2` |The DMA Channel for `TIMx_UP` |
|`WS2812_DMAMUX_ID` |*Not defined* |The DMAMUX configuration for `TIMx_UP` - only required if your MCU has a DMAMUX peripheral|
|`WS2812_PWM_COMPLEMENTARY_OUTPUT`|*Not defined* |Whether the PWM output is complementary (`TIMx_CHyN`) |
>>>>>>> a931e6d7bd (Update WS2812 docs and add APA102 docs (#22106))
>>>>>>> ffccc46cbe (Update WS2812 docs and add APA102 docs (#22106))
?> Using a complementary timer output (`TIMx_CHyN`) is possible only for advanced-control timers (1, 8 and 20 on STM32), and the `STM32_PWM_USE_ADVANCED` option in `mcuconf.h` must be set to `TRUE`. Complementary outputs of general-purpose timers are not supported due to ChibiOS limitations.

Expand Down

0 comments on commit 160326c

Please sign in to comment.