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
12# Initialize I2C bus.
13i2c = busio.I2C(board.SCL, board.SDA)
14
15# Initialize amplifier.
16amp = adafruit_max9744.MAX9744(i2c)
17# Optionally you can specify a different addres if you override the AD1, AD2
18# pins to change the address.
19# amp = adafruit_max9744.MAX9744(i2c, address=0x49)
20
21# Setting the volume is as easy as writing to the volume property (note
22# you cannot read the property so keep track of volume in your own code if
23# you need it).
24amp.volume = 31  # Volume is a value from 0 to 63 where 0 is muted/off and
25# 63 is maximum volume.
26
27# In addition you can call a function to instruct the amp to move up or down
28# a single volume level.  This is handy if you just have up/down buttons in
29# your project for volume:
30amp.volume_up()  # Increase volume by one level.
31
32amp.volume_down()  # Decrease volume by one level.