-
Notifications
You must be signed in to change notification settings - Fork 2
/
iiyama_shortcut.py
executable file
·88 lines (75 loc) · 2.85 KB
/
iiyama_shortcut.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
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue May 16 07:25:29 2017
@author: Mathieu Villion
"""
import sys
from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QMessageBox
from iiyama_x4071_lib import InputExtCode
from iiyama_x4071_lib import ONOFFCode
from iiyama_x4071_lib import X4071
from iiyama_x4071_lib import set_screen_size
class TimerMessageBox(QMessageBox):
def __init__(self, MessageStr, timeout=3, parent=None):
super(TimerMessageBox, self).__init__(parent)
self.setWindowTitle("X4071 control")
self.setStyleSheet(
"QLabel{min-width:500 px; font-size: 24px; color:red}")
self.time_to_wait = timeout
self.setText(MessageStr)
self.setStandardButtons(QMessageBox.NoButton)
self.timer = QTimer(self)
self.timer.setInterval(timeout*1000)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.close)
self.timer.start()
def closeEvent(self, event):
event.accept()
def main():
app = QApplication([])
Screen = X4071("/dev/ttyUSB0")
nArg = len(sys.argv)
Command = sys.argv[1]
if Command in ["mute"]:
if not Screen.send_remote(Command):
print("Command failed!")
(_, Value) = Screen.ext_get_from_name(Command)
MessageStr = "%s %s" % (Command, ONOFFCode[Value == 1])
if Command in ["pip_preset_on", "pip_preset_on3"]:
Input1 = InputExtCode[sys.argv[2]]
Screen.ext_get_set_from_name("input", Input1, 0.5)
Screen.ext_get_set_from_name("Audio input", 4, 0.5)
Screen.ext_get_set_from_name("PIP right", 1, 0.5)
Screen.ext_get_set_from_name("PIP bottom", 0, 0.5)
Screen.ext_get_set_from_name(
"PIP input", InputExtCode[sys.argv[3]], 0.5)
if Command in ["pip_preset_on3"]:
if Input1 == InputExtCode['HDMI1']:
set_screen_size("1920x2160")
Screen.ext_get_set_from_name("PIP PBP", 3, 1)
else:
if Input1 == InputExtCode['HDMI1']:
set_screen_size("3840x2160")
Screen.ext_get_set_from_name("PIP PBP", 1, 1)
MessageStr = Command
if Command in ["pip_preset_off"]:
Input1 = InputExtCode[sys.argv[2]]
if Input1 == InputExtCode['HDMI1']:
set_screen_size("3840x2160")
Screen.ext_get_set_from_name("PIP PBP", 0, 1.5)
Screen.ext_get_set_from_name("input", Input1, 0.5)
MessageStr = Command
elif Command in ["vol+", "vol-"]:
if not Screen.send_remote(Command):
print("Command failed!")
(_, Value) = Screen.ext_get_from_name("volume")
MessageStr = "Volume %d%%" % Value
messagebox = TimerMessageBox(MessageStr, 2)
messagebox.exec_()
app.quit()
print("Done")
if __name__ == '__main__':
main()