Skip to content

Commit 56e6401

Browse files
committed
fix precision for aio labels
Signed-off-by: John Thornton <[email protected]>
1 parent 91cf70f commit 56e6401

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

flexgui/src/libflexgui/startup.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -554,18 +554,15 @@ def setup_status_labels(parent):
554554
if label in parent.children:
555555
parent.status_dio[label] = [item, i] # add label and stat
556556

557-
558-
559-
'''
560-
# check for analog and digital labels in ui FIXME precision for analog
561-
# these return 64 items each
562-
io_items = ['ain', 'aout', 'din', 'dout']
563-
parent.status_io = {}
557+
# aio ain_0_lb aout_0_lb aio[0] aout[0]
558+
parent.status_aio = {}
564559
for i in range(64):
565-
for item in io_items:
566-
if f'{item}_{i}_lb' in parent.children:
567-
parent.status_io[f'{item}_{i}'] = f'{item}_{i}_lb'
568-
'''
560+
for item in ['ain', 'aout']:
561+
label = f'{item}_{i}_lb'
562+
if label in parent.children:
563+
p = getattr(parent, f'{item}_{i}_lb').property('precision')
564+
p = p if p is not None else default_precision
565+
parent.status_aio[label] = [item, i, p] # add label, stat and precision
569566

570567
# check for spindle labels in the ui
571568
spindle_items = ['brake', 'direction', 'enabled', 'homed',

flexgui/src/libflexgui/status.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,9 @@ def update(parent):
299299
for key, value in parent.status_dio.items():
300300
getattr(parent, f'{key}').setText(f'{getattr(parent.status, f"{value[0]}")[value[1]]}')
301301

302-
303-
'''
304-
# i/o s.ain[0] FIXME precision
305-
for key, value in parent.status_io.items(): # up to 64 items
306-
# there might be more than one underscore
307-
if int(key.split('_')[-1]) > 9: # determine how many chars to strip
308-
key = key[0:-3]
309-
else:
310-
key = key[0:-2]
311-
getattr(parent, f'{value}').setText(f'{getattr(parent.status, f"{key}")[int(value[-4])]}')
312-
313-
# i/o s.aout[0] FIXME precision
314-
# i/o s.din[0]
315-
# i/o s.dout[0]
316-
'''
302+
# aio ain_0_lb aout_0_lb aio[0] aout[0]
303+
for key, value in parent.status_aio.items():
304+
getattr(parent, f'{key}').setText(f'{getattr(parent.status, f"{value[0]}")[value[1]]:.{value[2]}f}')
317305

318306
# spindle s.spindle[0]['brake']
319307
for key, value in parent.status_spindles.items():

0 commit comments

Comments
 (0)