Simple test
Ensure your device works with this simple test.
examples/mas9744_simpletest.py
1# SPDX-FileCopyrightText: 2018 Tony DiCola for Adafruit Industries
2# SPDX-License-Identifier: MIT
3
4# Simple demo of the MAX9744 20W class D amplifier I2C control.
5# This show how to set the volume of the amplifier.
6import board
7import busio
8
9import adafruit_max9744
10
11# Initialize I2C bus.
12i2c = busio.I2C(board.SCL, board.SDA)
13
14# Initialize amplifier.
15amp = adafruit_max9744.MAX9744(i2c)
16# Optionally you can specify a different addres if you override the AD1, AD2
17# pins to change the address.
18# amp = adafruit_max9744.MAX9744(i2c, address=0x49)
19
20# Setting the volume is as easy as writing to the volume property (note
21# you cannot read the property so keep track of volume in your own code if
22# you need it).
23amp.volume = 31 # Volume is a value from 0 to 63 where 0 is muted/off and
24# 63 is maximum volume.
25
26# In addition you can call a function to instruct the amp to move up or down
27# a single volume level. This is handy if you just have up/down buttons in
28# your project for volume:
29amp.volume_up() # Increase volume by one level.
30
31amp.volume_down() # Decrease volume by one level.