def main(): # # changeDalekTurnSettings(1) # head_controller.leds_change_color(head_controller.leds_color['red']) head_controller.head_move_to_center() fw_mag = spi.get_mag() print("center mag:{}" .format(fw_mag)) time.sleep(1) # # print("3") # head_controller.head_move_left_90deg() # time.sleep(2) # left_mag = spi.get_mag() # print("left mag:{}" .format(left_mag)) # time.sleep(.5) # # head_controller.head_move_right_90deg() # # time.sleep(2) # # right_mag = spi.get_mag() # # print("left mag:{}" .format(right_mag)) # head_controller.head_move_to_center() # time.sleep(1) # # head_controller.leds_change_color(head_controller.leds_color['white']) # # DalekTurn(176) # # DalekTurn(354) # turnspeed = 60 # print("mag:{}" .format(spi.get_mag())) # drive.spinLeft(turnspeed) # print(turnspeed) # time.sleep(1) # drive.spinLeft(turnspeed-20) # print(turnspeed-20) # time.sleep(1) # print("mag:{}" .format(spi.get_mag())) Compass = spi.SensorData() # Compass = spi.CompassData() Compass.start() turnspeed = 50 while Compass.compass > (145+5): # while Compass.data > (145+5): drive.spinLeft(turnspeed) # print(turnspeed) time.sleep(.2) # time.sleep(5) dri # drive.spinLeft(turnspeed-10) # # print(turnspeed) # time.sleep(1) # drive.spinLeft(turnspeed-20) print(Compass.compass) # time.sleep(1) # time.sleep(5) dri drive.stop() print("Stop") time.sleep(1) print(Compass.compass) Compass.stop_running()
def getMag(): drive.stop() time.sleep(DalekTurnSettings['sleepTime']) currentMag = -1 # ensure we get a valid reading must be between 0 and 360 while not (0 <= currentMag <= 360): currentMag = spi.get_mag() return currentMag
def getMag(): drive.stop() time.sleep(DalekTurnSettings['sleepTime']) currentMag = -1 # ensure we get a valid reading must be between 0 and 360 while not (0 <= currentMag <= 360): currentMag = spi.get_mag() # print("---getStartingMag:{}".format(currentMag)) return currentMag