Ejemplo n.º 1
0
    def __init__(self, clk=23, dt=24, sw=25):
        self.dt = dt
        self.clk = clk
        self.sw = sw

        # variables needed to make the rotary encoder work
        self.clkLastState = 0
        self.counter = 0
        self.switchState = 0

        # setup gpio pins, event callbacks
        self.setup_pins()

        # Initialize I2C bus.
        i2c = busio.I2C(board.SCL, board.SDA)
        # Initialize amplifier.
        self.__amp = adafruit_max9744.MAX9744(i2c)
        self.__amp.volume = 0
        self.__volume = 0
Ejemplo n.º 2
0
    def __init__(self,
                 i2c_bus,
                 mute_pin=None,
                 name="amp0",
                 interval=0.1,
                 *args,
                 **kwargs):
        Device.__init__(self, name=name, interval=interval, *args, **kwargs)

        import adafruit_max9744
        self.amp = adafruit_max9744.MAX9744(i2c_bus)

        self.amp.volume = 0

        self.mute = None
        if mute_pin:

            import digitalio

            self.mute = digitalio.DigitalInOut(mute_pin)
            self.mute.direction = digitalio.Direction.OUTPUT
Ejemplo n.º 3
0
#         amp.volume_up()
#     print("volume up")

# def down(pin):
#     for i in range(5):
#         amp.volume_down()
#     print("volume up")

# io.add_event_detect(23, io.FALLING, up, bouncetime=200)
# io.add_event_detect(24, io.FALLING, down, bouncetime=200)

# Initialize I2C bus.
i2c = busio.I2C(board.SCL, board.SDA)

# Initialize amplifier.
amp = adafruit_max9744.MAX9744(i2c)
# Optionally you can specify a different addres if you override the AD1, AD2
# pins to change the address.
# amp = adafruit_max9744.MAX9744(i2c, address=0x49)

# Setting the volume is as easy as writing to the volume property (note
# you cannot read the property so keep track of volume in your own code if
# you need it).
amp.volume = 0  # Volume is a value from 0 to 63 where 0 is muted/off and
# 63 is maximum volume.

# In addition you can call a function to instruct the amp to move up or down
# a single volume level.  This is handy if you just have up/down buttons in
# your project for volume:
# amp.volume_up()  # Increase volume by one level.