@@ -44,6 +44,7 @@ def __init__(self, MainWindow):
44
44
self .startButton .clicked .connect (self .monitor )
45
45
self .rescanMidiButton .clicked .connect (self .rescanMidi )
46
46
self .MainWindow .update_ui_signal .connect (self .update_ui )
47
+ self .MainWindow .update_statusbar_signal .connect (self .update_statusbar )
47
48
self .midiDeviceComboBoxes = [
48
49
self .midiDevice0ComboBox ,
49
50
self .midiDevice1ComboBox ,
@@ -102,13 +103,18 @@ def __init__(self, MainWindow):
102
103
# make sure the midi device combo boxes are populated
103
104
self .rescanMidi ()
104
105
106
+ # statusbar text elements
107
+ self .connected = "not connected"
108
+ self .signal_quality = "unknown signal quality"
109
+ self .update_statusbar ()
105
110
106
111
def monitor (self ):
107
112
"""
108
113
start/stop button
109
114
"""
110
115
if self .running :
111
- print "SWITCH OFF"
116
+ self .connected = "Not connected"
117
+ self .signal_quality = "unknown signal quality"
112
118
for i ,mo in enumerate (self .midiOut ):
113
119
bytemsg = self .notequeue .clear_notes (i )
114
120
for msg in bytemsg :
@@ -117,7 +123,8 @@ def monitor(self):
117
123
self .h .serial_close ()
118
124
self .running = False
119
125
else :
120
- print "SWITCH ON"
126
+ self .connected = "Connected"
127
+ self .signal_quality = "unknown signal quality"
121
128
self .running = True
122
129
self .h = None
123
130
import serial
@@ -132,9 +139,21 @@ def monitor(self):
132
139
self .h .raw_wave_handlers .append (self .raw_wave_handler )
133
140
self .h .meditation_handlers .append (self .handle_meditation_event )
134
141
self .h .attention_handlers .append (self .handle_attention_event )
142
+ self .h .poor_signal_handlers .append (self .handle_poor_signal )
143
+ self .h .good_signal_handlers .append (self .handle_good_signal )
135
144
else :
136
145
self .running = False
137
146
147
+ self .update_statusbar ()
148
+
149
+ def handle_poor_signal (self , headset , value ):
150
+ self .signal_quality = "poor signal quality {0}%" .format (value )
151
+ self .MainWindow .update_statusbar_signal .emit ()
152
+
153
+ def handle_good_signal (self , headset , value ):
154
+ self .signal_quality = "good signal quality"
155
+ self .MainWindow .update_statusbar_signal .emit ()
156
+
138
157
def rescanMidi (self ):
139
158
"""
140
159
list all recognized midi devices
@@ -320,6 +339,9 @@ def update_ui(self):
320
339
self .eyeblink_counter += 1
321
340
#print "BLINK {0}".format(self.eyeblink_counter)
322
341
342
+ def update_statusbar (self ):
343
+ self .statusbar .showMessage ("{0} - {1}" .format (self .connected ,self .signal_quality ))
344
+
323
345
class MainWindowWithCustomSignal (QtGui .QMainWindow ):
324
346
"""
325
347
specialized QtGui.MainWindow
@@ -328,6 +350,7 @@ class MainWindowWithCustomSignal(QtGui.QMainWindow):
328
350
(needed to update ui from callback function called from different thread)
329
351
"""
330
352
update_ui_signal = QtCore .pyqtSignal ()
353
+ update_statusbar_signal = QtCore .pyqtSignal ()
331
354
332
355
def __init__ (self , * args , ** kwargs ):
333
356
super (MainWindowWithCustomSignal , self ).__init__ (* args , ** kwargs )
0 commit comments