-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand-line-serial-remote.py
executable file
·78 lines (64 loc) · 1.94 KB
/
command-line-serial-remote.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import curses
import serial
serialDevice = '/dev/ttyACM0'
#serialDevice = '/dev/ttyS2'
commands = []
#with open('Yamaha_other.txt') as f:
# lines = f.read().splitlines()
#
#for line in lines:
# line = line.strip().split()
# try:
# if (line[1][0] == "0"):
# commands.append(line)
# except:
# pass
##print line
##print commands
##exit()
commandIndex = 0;
yamaha = {
'pre': 'nec ',
'keys': {
curses.KEY_UP: '0x5EA1B946', # YAMAHA_MENU_UP
curses.KEY_DOWN: '0x5EA139C6', # YAMAHA_MENU_DOWN
curses.KEY_LEFT: '0x5EA1F906', # YAMAHA_MENU_LEFT
curses.KEY_RIGHT: '0x5EA17986', # YAMAHA_MENU_RIGHT
10: '0x5EA17B84', # YAMAHA_MENU_ENTER
ord('\\'):'0x5EA155AA', # YAMAHA_MENU_RETURN
ord('s'): '0x5EA121DE', # YAMAHA_MENU_ON_SCREEN
ord('a'): '0x5EA1D628', # YAMAHA_MENU_OPTION
ord('/'): '0x5EA138C7', # mute
ord('.'): '0x5EA158A7', # volume up
ord(','): '0x5EA1D827', # volume down
ord('p'): '0x7e817e81', # power on
ord('o'): '0x7e81fe01', # power off
ord('k'): '0x5EA16A95', # YAMAHA_DSP_EFFECT_ONOFF // straight / 7chan
ord('l'): '0x5EA131CE', # YAMAHA_2CH_7CH // 2ch/7ch stereo
#ord(''): '', #
},
}
controller = yamaha
def sendCommand(stdscr, command, message=""):
ser = serial.Serial(serialDevice, 9600, timeout=0, write_timeout=0)
ser.write(command)
stdscr.addstr(2, 0, command + " :message: " + message + " ")
ser.close()
stdscr = curses.initscr()
curses.cbreak()
stdscr.keypad(1)
stdscr.addstr(0,0,"Hit 'q' to quit")
stdscr.refresh()
key = ''
while key != ord('q'):
key = stdscr.getch()
if key == ord(' '):
sendCommand(stdscr, '... ')
else:
try:
sendCommand(stdscr, controller['pre'] + controller['keys'][key])
except:
pass
stdscr.refresh()
curses.endwin()