09-07-2019, 08:09 PM
I think I figured it out. Here is the recipe.
Then test communications
I tried @andrewewa code but could not get it to work so I wrote something from scratch and it indeed controls the Allo relay attenuator :-)
I'll have to defer integration into moOde until the 6.3.0 timeframe (October). One of the challenges is that the attenuator volume range is 64 steps while moOde knob is 100 steps.
-Tim
Code:
sudo apt-get -y install python-smbus i2c-tools libi2c-dev
sudo nano /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
i2c-dev
i2c-bcm2708
sudo reboot
Then test communications
Code:
sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 21 -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
I tried @andrewewa code but could not get it to work so I wrote something from scratch and it indeed controls the Allo relay attenuator :-)
Code:
# Attenuator volume range: 63 - 127 (64 steps)
# - 63 or less is mute
# - 64 is 0dB
# - 127 is -63dB
import smbus
import sys
program_version = "1.0"
bus_address = 0x21
bus = smbus.SMBus(1)
def main():
# Parse input args
if len(sys.argv) > 1:
if sys.argv[1] == "--version" or sys.argv[1] == "-v":
print("relay-attenuator.py version " + program_version)
sys.exit(0)
if len(sys.argv) > 2:
print("Too many arguments")
sys.exit(0)
else:
volume = int(sys.argv[1])
if volume <= 0:
volume = 63
elif volume >= 63:
volume = 64
else:
volume = 127 - volume
update_volume(volume)
def update_volume(volume):
print(volume)
bus.write_byte(bus_address, volume)
#
# Script starts here
#
if __name__ == '__main__':
main()
I'll have to defer integration into moOde until the 6.3.0 timeframe (October). One of the challenges is that the attenuator volume range is 64 steps while moOde knob is 100 steps.
-Tim
Enjoy the Music!
http://moodeaudio.org | http://twitter.com/MoodeAudio | http://github.com/moodeaudio
http://moodeaudio.org | http://twitter.com/MoodeAudio | http://github.com/moodeaudio