Skip to content

Commit 92cf021

Browse files
author
neil.hamilton
committed
Update functionsExhibitions.py
1 parent 1ecb2bf commit 92cf021

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

picosdk/functionsExhibitions.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from math import floor, log2, log10
88
import shutil
99
import os
10+
import toml
1011

1112
def dataImporter(name):
1213

@@ -104,34 +105,31 @@ def BitEnumSelector(bits):
104105

105106
def saveConfigFile(channels, bits, sampleRate,captureLength, segments):
106107

107-
configValues = [channels, bits, sampleRate, captureLength, segments]
108+
# configValues = [channels, bits, sampleRate, captureLength, segments]
109+
data = {
110+
"Active Channels" : channels,
111+
"Scope Bit Resolution" : bits,
112+
"Sampling Rate (MHz)" : sampleRate,
113+
"Capture Length (Samples)" : captureLength,
114+
"Number of Capture Segments for Rapid Block" : segments,
115+
}
116+
# # Save the list to a text file
117+
with open('configValues.toml', 'w') as file:
118+
toml.dump(data,file)
108119

109-
# Save the list to a text file
110-
with open('configValues.txt', 'w') as file:
111-
# Write each element of the list on a new line
112-
for value in configValues:
113-
file.write(f"{value}\n")
114120

115121
return
116122

117123
def loadConfigValues():
118124

119-
restored_configValues = []
120-
121-
with open('configValues.txt', 'r') as file:
122-
for line in file:
123-
value = line.strip()
124-
# Convert to integer or float as necessary
125-
if '.' in value:
126-
restored_configValues.append(float(value))
127-
else:
128-
restored_configValues.append(int(value))
125+
with open('configValues.toml', 'r') as file:
126+
restored_configValues = toml.load(file)
129127

130-
channels = restored_configValues[0]
131-
bits = restored_configValues[1]
132-
sampleRate = restored_configValues[2]
133-
captureLength = restored_configValues[3]
134-
segments = restored_configValues[5]
128+
channels = int(restored_configValues["Active Channels"])
129+
bits = int(restored_configValues["Scope Bit Resolution"])
130+
sampleRate = float(restored_configValues["Sampling Rate (MHz)"])
131+
captureLength = int(float(restored_configValues["Capture Length (Samples)"]))
132+
segments = int(restored_configValues["Number of Capture Segments for Rapid Block"])
135133

136134
return channels, bits, sampleRate, captureLength, segments
137135

0 commit comments

Comments
 (0)