Introduction

Documentation Status Discord Build Status

CircuitPython module for the TLC59711 16-bit 12 channel LED PWM driver.

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Usage Example

See examples/tlc59711_simpletest.py for a demo of the usage.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

Building locally

To build this library locally you’ll need to install the circuitpython-build-tools package.

python3 -m venv .env
source .env/bin/activate
pip install circuitpython-build-tools

Once installed, make sure you are in the virtual environment:

source .env/bin/activate

Then run the build:

circuitpython-build-bundles --filename_prefix adafruit-circuitpython-tlc59711 --library_location .

Sphinx documentation

Sphinx is used to build the documentation based on rST files and comments in the code. First, install dependencies (feel free to reuse the virtual environment from above):

python3 -m venv .env
source .env/bin/activate
pip install Sphinx sphinx-rtd-theme

Now, once you have the virtual environment activated:

cd docs
sphinx-build -E -W -b html . _build/html

This will output the documentation to docs/_build/html. Open the index.html in your browser to view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to locally verify it will pass.

Table of Contents

Simple test

Ensure your device works with this simple test.

examples/tlc59711_simpletest.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Simple demo of the TLC59711 16-bit 12 channel LED PWM driver.
# Shows setting channel values in a few ways.
# Author: Tony DiCola
import board
import busio

import adafruit_tlc59711


# Define SPI bus connected to chip.  You only need the clock and MOSI (output)
# line to use this chip.
spi = busio.SPI(board.SCK, MOSI=board.MOSI)

# Define the TLC59711 instance.
leds = adafruit_tlc59711.TLC59711(spi)
# Optionally you can disable the auto_show behavior that updates the chip
# as soon as any channel value is written.  The default is True/on but you can
# disable and explicitly call show to control when updates happen for better
# animation or atomic RGB LED updates.
#leds = adafruit_tlc59711.TLC59711(spi, auto_show=False)

# There are a couple ways to control the channels of the chip.
# The first is using an interface like a strip of NeoPixels.  Index into the
# class for the channel and set or get its R, G, B tuple value.  Note the
# component values are 16-bit numbers that range from 0-65535 (off to full
# brightness).  Remember there are only 4 channels available too (0 to 3).
# For example set channel 0 (R0, G0, B0) to half brightness:
leds[0] = (32767, 32767, 32767)
# Dont forget to call show if you disabled auto_show above.
#leds.show()

# Or to set channel 1 to full red only (green and blue off).
leds[1] = (65535, 0, 0)

# You can also explicitly control each R0, G0, B0, R1, B1, etc. channel
# by getting and setting its 16-bit value directly with properties.
# For example set channel 2 to full green (i.e. G2 to maximum):
leds.g2 = 65535
# Again don't forget to call show if you disabled auto_show above.
#leds.show()

# The chip also supports global brightness channels to change the red, green,
# blue colors of all 4 channels at once.  These are 7-bit values that range
# from 0-127.  Get and set them with the red_brightness, green_brightness,
# and blue_brightness properties and again be sure to call show if you
# disabled auto_show.
# For example set the red channel to half brightness globally.
leds.red_brightness = 63
# Don't forget to call show if you disabled auto_show above.
#leds.show()

adafruit_tlc59711

CircuitPython module for the TLC59711 16-bit 12 channel LED PWM driver. See examples/simpletest.py for a demo of the usage.

  • Author(s): Tony DiCola

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_tlc59711.TLC59711(spi, *, auto_show=True)[source]

TLC59711 16-bit 12 channel LED PWM driver. This chip is designed to drive 4 RGB LEDs with 16-bit PWM control of each LED. The class has an interface much like that of NeoPixels with attribute access to the 4 RGB channels (note they are 16-bit values). Or you can access each independent channel by name (r0, g0, b0, r1, b1, etc.) as properties for fine-grained control.

Parameters:
  • spi (SPI) – An instance of the SPI bus connected to the chip. The clock and MOSI/outout must be set, the MISO/input is unused.
  • auto_show (bool) – This is a boolean that defaults to True and indicates any change to a channel value will instantly be written to the chip. You might wish to set this to false if you desire to perform your own atomic operations of channel values. In that case call the show function after making updates to channel state.
blue_brightness

The blue brightness for all channels (i.e. B0, B1, B2, and B3). This is a 7-bit value from 0-127.

green_brightness

The green brightness for all channels (i.e. G0, G1, G2, and G3). This is a 7-bit value from 0-127.

red_brightness

The red brightness for all channels (i.e. R0, R1, R2, and R3). This is a 7-bit value from 0-127.

show()[source]

Write out the current LED PWM state to the chip. This is only necessary if auto_show was set to false in the initializer.

Indices and tables