adafruit_tpa2016

CircuitPython driver for TPA2016 Class D Amplifier.

  • Author(s): Kattni Rembor

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_tpa2016.TPA2016(i2c_bus: I2C)

Driver for the TPA2016 class D amplifier.

Parameters:

i2c_bus (busio.I2C) – The I2C bus the TPA2016 is connected to.

amplifier_shutdown

Amplifier shutdown. Amplifier is disabled if True. Defaults to False. If True, device is in software shutdown, e.g. control, bias and oscillator are inactive.

property attack_time: int

The attack time. This is the minimum time between gain decreases. Set to 1 - 63 where 1 = 0.1067ms and the time increases 0.1067ms with each step, for a maximum of 6.722ms. Defaults to 5, or 0.5335ms.

This example sets the attack time to 1, or 0.1067ms.

import adafruit_tpa2016
import busio
import board

i2c = busio.I2C(board.SCL, board.SDA)
tpa = adafruit_tpa2016.TPA2016(i2c)

tpa.attack_time = 1
compression_ratio

The compression ratio.

Ratio settings are: 1:1. 2:1, 4:1, 8:1. Settings options are: COMPRESSION_1_1, COMPRESSION_2_1, COMPRESSION_4_1, COMPRESSION_8_1. Defaults to 4:1.

This example sets the compression ratio to 2:1.

import adafruit_tpa2016
import busio
import board

i2c = busio.I2C(board.SCL, board.SDA)
tpa = adafruit_tpa2016.TPA2016(i2c)

tpa.compression_ratio = tpa.COMPRESSION_2_1
property fixed_gain: int

The fixed gain of the amplifier in dB. If compression is enabled, fixed gain is adjustable from –28 to 30. If compression is disabled, fixed gain is adjustable from 0 to 30.

The following example sets the fixed gain to -16dB.

import adafruit_tpa2016
import busio
import board

i2c = busio.I2C(board.SCL, board.SDA)
tpa = adafruit_tpa2016.TPA2016(i2c)

tpa.fixed_gain = -16
property hold_time: int

The hold time. This is the minimum time between attack and release. Set to 0 - 63 where 0 = disabled, and the time increases 0.0137ms with each step, for a maximum of 0.8631ms. Defaults to 0, or disabled.

This example sets hold time to 1, or 0.0137ms.

import adafruit_tpa2016
import busio
import board

i2c = busio.I2C(board.SCL, board.SDA)
tpa = adafruit_tpa2016.TPA2016(i2c)

tpa.hold_time = 1
property max_gain: int

The max gain in dB. Must be between 18 and 30.

noise_gate_enable

NoiseGate function enable. Enabled by default. Can only be enabled when compression ratio is NOT 1:1. To disable, set to False.

noise_gate_threshold

Noise Gate threshold in mV.

Noise gate settings are 1mV, 4mV, 10mV, and 20mV. Settings options are NOISE_GATE_1, NOISE_GATE_4, NOISE_GATE_10, NOISE_GATE_20. Only functional when compression ratio is NOT 1:1. Defaults to 4mV.

This example sets the noise gate threshold to 10mV.

import adafruit_tpa2016
import busio
import board

i2c = busio.I2C(board.SCL, board.SDA)
tpa = adafruit_tpa2016.TPA2016(i2c)

tpa.noise_gate_threshold = tpa.NOISE_GATE_10
output_limiter_disable

Output limiter disable.

Enabled by default when compression ratio is NOT 1:1. Can only be disabled if compression ratio is 1:1. To disable, set to True.

property output_limiter_level: float

The output limiter level in dBV. Must be between -6.5 and 9, set in increments of 0.5.

property release_time: int

The release time. This is the minimum time between gain increases. Set to 1 - 63 where 1 = 0.0137ms, and the time increases 0.0137ms with each step, for a maximum of 0.8631ms. Defaults to 11, or 0.1507ms.

This example sets release time to 1, or 0.0137ms.

import adafruit_tpa2016
import busio
import board

i2c = busio.I2C(board.SCL, board.SDA)
tpa = adafruit_tpa2016.TPA2016(i2c)

tpa.release_time = 1
reset_Fault_l

Over-current event on left channel indicated by returning True. Reset by setting to False.

reset_fault_r

Over-current event on right channel indicated by returning True. Reset by setting to False.

reset_thermal

Thermal software shutdown indicated by returning True. Reset by setting to False.

speaker_enable_l

Enables left speaker. Defaults to enabled. Set to False to disable.

speaker_enable_r

Enables right speaker. Defaults to enabled. Set to False to disable.