|
@@ -162,6 +162,7 @@ class Handler:
|
162
|
162
|
self.serial_port = None
|
163
|
163
|
self.voltage = None
|
164
|
164
|
self.current = None
|
|
165
|
+ self.giveback = None
|
165
|
166
|
self.selectlist = None
|
166
|
167
|
|
167
|
168
|
def on_pdb_window_realize(self, *args):
|
|
@@ -183,6 +184,7 @@ class Handler:
|
183
|
184
|
# Get voltage and current widgets
|
184
|
185
|
voltage = self.builder.get_object("voltage-combobox")
|
185
|
186
|
current = self.builder.get_object("current-spinbutton")
|
|
187
|
+ giveback = self.builder.get_object("giveback-toggle")
|
186
|
188
|
|
187
|
189
|
self.serial_port = serport
|
188
|
190
|
|
|
@@ -195,7 +197,14 @@ class Handler:
|
195
|
197
|
|
196
|
198
|
# Get voltage and current from device and load them into the GUI
|
197
|
199
|
for line in tmpcfg:
|
198
|
|
- if line.startswith(b'v:'):
|
|
200
|
+ if line.startswith(b'flags:'):
|
|
201
|
+ line = line.split()[1:]
|
|
202
|
+ try:
|
|
203
|
+ line.index(b'GiveBack')
|
|
204
|
+ giveback.set_active(True)
|
|
205
|
+ except:
|
|
206
|
+ giveback.set_active(False)
|
|
207
|
+ elif line.startswith(b'v:'):
|
199
|
208
|
v = line.split()[1]
|
200
|
209
|
if v == b'5.00':
|
201
|
210
|
voltage.set_active_id('voltage-five')
|
|
@@ -266,21 +275,25 @@ class Handler:
|
266
|
275
|
# Get voltage and current widgets
|
267
|
276
|
voltage = self.builder.get_object("voltage-combobox")
|
268
|
277
|
current = self.builder.get_object("current-spinbutton")
|
|
278
|
+ giveback = self.builder.get_object("giveback-toggle")
|
269
|
279
|
|
270
|
280
|
# Remember the loaded settings
|
271
|
281
|
self.voltage = voltage.get_active_id()
|
272
|
282
|
self.current = current.get_value()
|
|
283
|
+ self.giveback = giveback.get_active()
|
273
|
284
|
|
274
|
285
|
def _set_save_button_visibility(self):
|
275
|
286
|
"""Show the save button if there are new settings to save"""
|
276
|
287
|
# Get relevant widgets
|
277
|
288
|
voltage = self.builder.get_object("voltage-combobox")
|
278
|
289
|
current = self.builder.get_object("current-spinbutton")
|
|
290
|
+ giveback = self.builder.get_object("giveback-toggle")
|
279
|
291
|
rev = self.builder.get_object("header-sink-save-revealer")
|
280
|
292
|
|
281
|
293
|
# Set visibility
|
282
|
294
|
rev.set_reveal_child(voltage.get_active_id() != self.voltage
|
283
|
|
- or current.get_value() != self.current)
|
|
295
|
+ or current.get_value() != self.current
|
|
296
|
+ or giveback.get_active() != self.giveback)
|
284
|
297
|
|
285
|
298
|
def on_voltage_combobox_changed(self, combo):
|
286
|
299
|
window = self.builder.get_object("pdb-window")
|
|
@@ -304,6 +317,15 @@ class Handler:
|
304
|
317
|
except:
|
305
|
318
|
self.on_header_sink_back_clicked(None)
|
306
|
319
|
|
|
320
|
+ def on_giveback_toggle_toggled(self, toggle):
|
|
321
|
+ window = self.builder.get_object("pdb-window")
|
|
322
|
+ try:
|
|
323
|
+ pdb_send_message(self.serial_port, 'toggle_giveback', window)
|
|
324
|
+
|
|
325
|
+ self._set_save_button_visibility()
|
|
326
|
+ except:
|
|
327
|
+ self.on_header_sink_back_clicked(None)
|
|
328
|
+
|
307
|
329
|
class Application(Gtk.Application):
|
308
|
330
|
|
309
|
331
|
def __init__(self, *args, **kwargs):
|