Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemoran committed Nov 17, 2017
1 parent e567447 commit 8f73bd3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions calibrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,11 @@ def calculate_lin_reg_coeffs(x, y):


for index, int_pin in enumerate(int_pins):
id = input("Type the name of the sensor {} on pin {}: ".format(index, int_pin))

sensor = {
"id": "s"+str(index+1),
"id": id,
"index": index,
"int_pin": int_pin,
"create_csv": "off",
"resistor_value": 7.5,
Expand All @@ -117,6 +120,8 @@ def calculate_lin_reg_coeffs(x, y):
choice = input("F or value: ")

try:
choice = choice.replace(",",".")
print("Current selected: {}".format(choice))
real_current = float(choice)
test_data = {
"id": test_counter,
Expand All @@ -127,6 +132,9 @@ def calculate_lin_reg_coeffs(x, y):
if choice.upper() == "F":
print("")
break
else:
print("ERROR! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
raise

for sensor in sensor_list:
sensor["controller"].reset()
Expand All @@ -141,14 +149,15 @@ def calculate_lin_reg_coeffs(x, y):
elapsed = time() - start
done = True

sys.stdout.write("\033[F"*len(sensor_list))
sys.stdout.write("\033[F"*(len(sensor_list)+1))
for sensor in sensor_list:
# the exact output you're looking for:
elapsed_ticks = len(sensor["controller"].counter.ticks)
done = done and (elapsed_ticks >= ema_period)

sys.stdout.write("Sensor %s: [%-20s] %d%%\033[K\n" % (sensor["id"], '=' * min(int(elapsed_ticks / ema_period * 20), 20), min((elapsed_ticks / ema_period * 100), 100)))

print("Elapsed: {:5.1f} ({:3.0f}%)".format(time()-start, 100*(time()-start)/test_timeout))
sys.stdout.flush()

if time()-start > test_timeout:
Expand All @@ -170,6 +179,7 @@ def calculate_lin_reg_coeffs(x, y):

print(" -- Type again the real current value to begin a test")
value = input("Value: ")
value = value.replace(",", ".")
test_data["real_current"] = (test_data["real_current"] + float(value))/2
print(" -- Value for the real_current stored: {}".format(test_data["real_current"]))

Expand Down Expand Up @@ -211,7 +221,7 @@ def calculate_lin_reg_coeffs(x, y):

if save_data.upper() == 'Y' or save_data == '':
file_name = input("Please type the name of the file: ")
file_name += ".json"
file_name = "amp-o-meter/test_results/" + file_name + ".json"
with open(file_name, 'w') as json_file:
all_data = {
"test_timeout": test_timeout,
Expand Down

0 comments on commit 8f73bd3

Please sign in to comment.