This commit is contained in:
tillraab 2019-10-01 15:12:06 +02:00
parent f884c0cb1d
commit 6061929d0d

View File

@ -92,6 +92,8 @@ def read_cfg(cfg_file, now, init_read=False):
samplerate = int(float(line.split(':')[-1].strip().replace('kHz', '')) * 1000)
elif "AIMaxVolt" in line:
max_v = float(line.split(':')[1].strip().replace('mV', ''))
elif 'Gain' in line:
gain = int(line.split(':')[1].strip())
channels = n_rows * n_cols
### alter information and re-write ###
@ -107,7 +109,7 @@ def read_cfg(cfg_file, now, init_read=False):
cfg_f.write(line)
cfg_f.close()
return channels, samplerate, n_cols, n_rows, max_v
return channels, samplerate, n_cols, n_rows, max_v, gain
# for line in cfg:
# if 'Columns1' in line:
@ -197,7 +199,7 @@ def main():
quit()
# read and edit config file
channels, rate, n_cols, n_rows, max_v = read_cfg(init_cfgfile, now)
channels, rate, n_cols, n_rows, max_v, gain = read_cfg(init_cfgfile, now)
LED1_pin = 11
LED2_pin = 13
@ -268,8 +270,16 @@ def main():
# Get a list of supported ranges and validate the range index.
ranges = ai_info.get_ranges(input_mode)
if range_index >= len(ranges):
range_index = len(ranges) - 1
int_ranges = []
for r in ranges:
int_ranges.append(int(r.name.replace('BIP', '').replace('VOLTS', '')))
for idx in np.argsort(int_ranges):
if max_v * gain / 1000 >= int_ranges[idx]:
range_index = idx
# if range_index >= len(ranges):
# range_index = len(ranges) - 1
embed()
quit()