def full_calibrate(self): timestamp = time.strftime('%m-%d_%H%M') fileName = "data\\dmc_calib_" + timestamp self.calibrate_both_spins(fileName) self.calibrate_all_straight(fileName) for i in range(2): serial.write("cmd write_motor_settings") print("!!!\nDone calibrating!\n!!!")
def full_calibrate(self): #first, calibrate droplet spin for one direction. This will give us motor sign and relative values for the three motors. #then calibrate directions 0, 2, and 4 (or 1, 3, and 5) timestamp = time.strftime('%m-%d_%H%M') fileName = "data\\dmc_calib_" + timestamp self.calibrate_both_spins(fileName) self.calibrate_all_straight(fileName) for i in range(2): serial.write("cmd write_motor_settings") print("!!!\nDone calibrating!\n!!!")
def process_and_transmit_line(line): byte_strs = [str(line[i])+str(line[i+1]) for i in range(1,len(line)-1,2)] byte_sum=0 for b in byte_strs: byte_sum+=int(b,16) byte_sum-=int(byte_strs[-1],16) if(format(0xFF&((0xFF^(byte_sum & 0xFF))+1),'02X') != byte_strs[-1]): print("checksum mismatch?") print("\t" + format(0xFF&((0xFF^(byte_sum & 0xFF))+1),'02X')) print("\t" + byte_strs[-1]) dat = ''.join([chr(int(b,16)) for b in byte_strs]) #print(dat) Serial.write(dat)
def stop_walk(): serial.write("cmd stop_walk")
def move_steps(direction, num_steps): serial.write("cmd move_steps %d %d"%(direction, num_steps))
def set_motors(direction, mot0val, mot1val, mot2val): serial.write("cmd set_motors %d %d %d %d"%(direction, mot0val, mot1val, mot2val)) #Once more, just to be sure. serial.write("cmd set_motors %d %d %d %d"%(direction, mot0val, mot1val, mot2val))
def set_led(r, g, b): serial.write("cmd set_led rgb %d %d %d"%(r, g, b))
def move_steps(direction, num_steps): serial.write("cmd move_steps %d %d" % (direction, num_steps))
def set_motors(direction, mot0val, mot1val, mot2val): serial.write("cmd set_motors %d %d %d %d" % (direction, mot0val, mot1val, mot2val)) #Once more, just to be sure. serial.write("cmd set_motors %d %d %d %d" % (direction, mot0val, mot1val, mot2val))
def set_led(r, g, b): serial.write("cmd set_led rgb %d %d %d" % (r, g, b))