forked from etsinko/pymonoprice
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample.py
executable file
·64 lines (49 loc) · 1.62 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/local/bin/python3
#
# Running:
# ./example-async.py --help
# ./example.py --tty /dev/tty.usbserial-A501SGSZ
import argparse
from pyxantech import get_amp_controller
parser = argparse.ArgumentParser(description='Xantech RS232 client example')
parser.add_argument(
'--tty', help='/dev/tty to use (e.g. /dev/tty.usbserial-A501SGSZ)', required=True
)
parser.add_argument(
'--model', default='xantech8', help=f'model (e.g. xantech8, monoprice6)'
)
parser.add_argument(
'--baud',
type=int,
default=9600,
help='baud rate (9600, 14400, 19200, 38400, 57600, 115200)',
)
args = parser.parse_args()
serial_config = {'baudrate': args.baud}
zone = 1
amp = get_amp_controller(args.model, args.tty, serial_config_overrides=serial_config)
# save the status for all zones before modifying
zone_status = {}
for zone in range(1, 9):
zone_status[zone] = amp.zone_status(zone) # save current status for all zones
print(f'Zone {zone} status: {zone_status[zone]}')
amp.all_off()
exit
# for zone in range(1, 9):
# amp.set_power(zone, True)
# amp.set_mute(zone, False)
# print(f"Zone {zone} status: {amp.zone_status(zone)}")
source = 1
amp.set_source(1, source)
# restore zones back to their original states
for zone in range(1, 9):
amp.restore_zone(zone_status[zone])
def knight_rider(amp, number_of_times):
for _ in range(1, number_of_times + 1):
for zone in range(1, 9):
amp.set_power(zone, True)
amp.set_power(zone, False)
for zone in range(-7, -1):
amp.set_power(-1 * zone, True)
amp.set_power(-1 * zone, False)
# knight_rider(amp, 2)