save calibration by default

This commit is contained in:
Brendan Haines 2020-03-02 22:18:32 -07:00
parent 5ae0707162
commit e4cc932d1a

View File

@ -38,9 +38,15 @@ servos[1].throttle = 0
servos[2].throttle = 0 servos[2].throttle = 0
# Initialize calibration # Initialize calibration
# TODO: save cal and load from file by default try:
white_cal = [0]*8 white_cal = np.loadtxt('cal_white.txt')
black_cal = [5]*8 except FileNotFoundError:
white_cal = [0]*8
try:
black_cal = np.loadtxt('cal_black.txt')
except FileNotFoundError:
black_cal = [5]*8
def get_reflectivity(chan): def get_reflectivity(chan):
global mux_io global mux_io
@ -157,11 +163,13 @@ def update_plots(attrname=None, old=None, new=None):
def cal_white(attrname=None, old=None, new=None): def cal_white(attrname=None, old=None, new=None):
global white_cal global white_cal
white_cal = [get_reflectivity(c) for c in range(8)] white_cal = [get_reflectivity(c) for c in range(8)]
np.savetxt('cal_white.txt', white_cal)
update_plots() update_plots()
def cal_black(attrname=None, old=None, new=None): def cal_black(attrname=None, old=None, new=None):
global black_cal global black_cal
black_cal = [get_reflectivity(c) for c in range(8)] black_cal = [get_reflectivity(c) for c in range(8)]
np.savetxt('cal_black.txt', black_cal)
update_plots() update_plots()
def start_controller(attrname=None, old=None, new=None): def start_controller(attrname=None, old=None, new=None):