adafruit_tlc5947
¶
CircuitPython module for the TLC5947 12-bit 24 channel LED PWM driver. See examples/simpletest.py for a demo of the usage.
- Author(s): Tony DiCola
Implementation Notes¶
Hardware:
- Adafruit 24-Channel 12-bit PWM LED Driver - SPI Interface - TLC5947 (Product ID: 1429)
Software and Dependencies:
- Adafruit CircuitPython firmware for the ESP8622 and M0-based boards: https://github.com/adafruit/circuitpython/releases
-
class
adafruit_tlc5947.
TLC5947
(spi, latch, *, auto_write=True)[source]¶ TLC5947 12-bit 24 channel LED PWM driver. Create an instance of this by passing in at least the following parameters:
Parameters: - spi – The SPI bus connected to the chip (only the SCK and MOSI lines are used, there is no MISO/input).
- latch – A DigitalInOut instance connected to the chip’s latch line.
Optionally you can specify:
Parameters: auto_write – This is a boolean that defaults to True and will automatically write out all the channel values to the chip as soon as a single one is updated. If you set to false to disable then you MUST call write after every channel update or when you deem necessary to update the chip state. -
class
PWMOut
(tlc5947, channel)[source]¶ Internal PWMOut class that mimics the behavior of CircuitPython’s PWMOut class but is associated with a channel on the TLC5947. You can get and set the instance’s duty_cycle property as a 16-bit PWM value (note there will be quantization errors as the TLC5947 is a 12-bit PWM chip, instead use the TLC5947 class item accessor notation for direct 12-bit raw PWM channel access). Note you cannot change the frequency as it is fixed by the TLC5947 to ~2.4-5.6 mhz.
-
duty_cycle
¶ Get and set the 16-bit PWM duty cycle value for this channel.
-
frequency
¶ Frequency of the PWM channel, note you cannot change this and cannot read its exact value (it varies from 2.4-5.6 mhz, see the TLC5947 datasheet).
-
-
create_pwm_out
(channel)[source]¶ Create an instance of a PWMOut-like class that mimics the built-in CircuitPython PWMOut class but is associated with the TLC5947 channel that is specified. This PWMOut class has a duty_cycle property which you can read and write with a 16-bit value to control the channel. Note there will be quantization error as the chip only supports 12-bit PWM, if this is problematic use the item accessor approach to update the raw 12-bit channel values.