def toggleMagnet(self): print("Process magnet here") self.magnet = not self.magnet if self.magnet: cyprus.set_servo_position(2, 1) else: cyprus.set_servo_position(2, .5)
def auto(self): print("Run through one cycle of the perpetual motion machine") if axis1.isBusy(): s0.softStop() if s0.get_position_in_units() == 56.5: s0.goHome() elif s0.get_position_in_units() != 0.0: axis1.goUntilPress(0, 0, 5000) elif s0.get_position_in_units() == 0.0: cyprus.set_servo_position(2, 0.5) sleep(2) cyprus.set_servo_position(2, 0) self.toggleRamp() while 1: if cyprus.read_gpio() == 6: print("metal detector signal read") cyprus.set_motor_speed(1, self.staircaseSpeed.value) self.toggleRamp() while 1: if s0.read_switch() == True: sleep(5 / self.staircaseSpeed.value) cyprus.set_motor_speed(1, 0) s0.free_all() return return
def toggle_magnet(): global ON if ON: cyprus.set_servo_position(2, 0.5) else: cyprus.set_servo_position(2, 1) ON = not ON
def toggle_gate(): global OPEN if OPEN: cyprus.set_servo_position(2, 0.05) else: cyprus.set_servo_position(2, 0.5) OPEN = not OPEN
def is_it_on(): if cyprus.read_gpio() & 0b0001: cyprus.set_servo_speed(1, 0) sleep(0.05) else: cyprus.set_servo_position(1, 0) sleep(0.05)
def initialize(): ramp.free() ramp.set_speed(3.5) cyprus.initialize() cyprus.setup_servo(2) cyprus.set_motor_speed(1, 0) cyprus.set_servo_position(2, 0)
def auto(self): ramp.set_speed(3.5) cyprus.set_servo_position(2, 0) cyprus.set_motor_speed(1, 0) Clock.schedule_once(lambda dt: self.move_ramp(), 0.01) Clock.schedule_once(lambda dt: self.part2(), 9) Clock.schedule_once(lambda dt: self.part3(), 18)
def toggle_gate(self): if self.check_text('gate') == 'Off': self.gate.text = "Close Gate" cyprus.set_servo_position(2, 0.5) elif self.check_text('gate') == 'On': self.gate.text = "Open Gate" cyprus.set_servo_position(2, 0)
def cyprus_setup(self): global servo_state servo_state = 0 cyprus.initialize() cyprus.setup_servo(1) cyprus.set_servo_position(1, 0) sleep(0.2) self.start_cyprus_thread()
def ramp_up(self): cyprus.initialize() cyprus.setup_servo(1) for i in range(2, 4, 6, 8, 10): cyprus.set_servo_speed(1, i/10.0) sleep(4) cyprus.set_servo_position(1, 0.5) cyprus.close()
def toggleGate(self): self.gate = not self.gate if self.gate: cyprus.set_servo_position(2, .48) else: cyprus.set_servo_position(2, 0) print("Open and Close gate here")
def initialize(self): print("Home arm and turn off magnet") cyprus.initialize() cyprus.setup_servo(1) cyprus.setup_servo(2) cyprus.set_servo_position(2, .5) cyprus.set_pwm_values(1, period_value=100000, compare_value=0, compare_mode=cyprus.LESS_THAN_OR_EQUAL) self.homeArm()
def toggleGate(self): global pos if pos == 0: pos = 0.5 cyprus.set_servo_position(2, pos) else: pos = 0 cyprus.set_servo_position(2, pos) print("Open and Close gate here")
def servoThread(self): global servo while servo: if (cyprus.read_gpio() & 0b0001): sleep(.1) if (cyprus.read_gpio() & 0b0001): cyprus.set_servo_position(1, 0) else: cyprus.set_servo_position(1, 1)
def openGate(self): global CLOSE if CLOSE: cyprus.set_servo_position(2, 0.5) CLOSE = False else: cyprus.set_servo_position(2, 0) CLOSE = True
def flip(self): if cyprus.read_gpio() & 0B0001: time.sleep(.05) if cyprus.read_gpio() & 0B0001: cyprus.set_servo_position(1, 1) self.ids.flip.text = "180 Degrees" else: cyprus.set_servo_position(1, 0) self.ids.flip.text = "0 Degrees"
def limit_switch(self): cyprus.initialize() cyprus.setup_servo(1) def isGPIO_P6_HIGH(self): return (cyprus.read_gpio() & 0b0001) == 1 if isGPIO_P6_HIGH(self): cyprus.set_servo_position(1, 0) else: cyprus.set_servo_position(1, 1)
def toggleGate(self): print("Open and Close gate here") global onGate if not onGate: cyprus.set_servo_position(2, 0.5) onGate = True else: cyprus.set_servo_position(2, 0) onGate = False
def newFlip(self): global cyprusState if cyprusState: cyprus.set_servo_position(1, 1) print(cyprusState) cyprusState = False else: cyprus.set_servo_position(1, 0) cyprusState = True print(cyprusState)
def exit_program(): """ Quit the program. This should free all steppers and do any cleanup necessary :return: None """ cyprus.set_servo_position(1, .5) cyprus.close() spi.close() GPIO.cleanup() quit()
def toggleGate(self): global gate_count if gate_count % 2 == 0: self.gate.text = "Close Gate" cyprus.set_servo_position(2, 0.5) sleep(0.1) else: self.gate.text = "Open Gate" cyprus.set_servo_position(2, 0.25) sleep(0.1) gate_count += 1
def servo_change(self): if self.get_servo_state() == 0: global servo_state servo_state = 0 cyprus.set_servo_position(1, 0) sleep(0.05) elif self.get_servo_state() == 1: global servo_state servo_state = 1 cyprus.set_servo_position(1, 1) sleep(0.05)
def bs(self): global x while x: if(cyprus.read_gpio() & 0b0001): sleep(.1) if (cyprus.read_gpio() & 0b0001): cyprus.set_servo_position(1, 0) print("a") else: cyprus.set_servo_position(1, 1) print("f")
def servoMotorBinaryState(self): cyprus.initialize() cyprus.setup_servo(2) while True: if cyprus.read_gpio() & 0b0001: cyprus.set_servo_position(2, 0) # close gate sleep(1) else: cyprus.set_servo_position(2, .7) # open gate sleep(1)
def servoPressed(self): global pos cyprus.initialize( ) # initialize the RPiMIB and establish communication cyprus.setup_servo( 2) # sets up P4 on the RPiMIB as a RC servo style output if pos: cyprus.set_servo_position(1, 0) pos = False else: cyprus.set_servo_position(1, 1) pos = True
def pressed(self): """ Function called on button touch event for button with id: testButton :return: None """ global togServo if (togServo == 1): cyprus.set_servo_position(1, 0) togServo = 0 # 2 specifies port P5, i is a float that specifies speed else: cyprus.set_servo_position(1, 1) togServo = 1
def gamerrise(self): global b b = 1 global speder speder = 0 cyprus.set_servo_position(1,.5) while(b<=200): speder = .5 + .5 * b/200 print("%s" % speder) cyprus.set_pwm_values(1, period_value=100000, compare_value=50000, compare_mode=cyprus.LESS_THAN_OR_EQUAL) cyprus.set_servo_position(1, speder) sleep(.1) b = b + 1
def bs2(self): global x2 while x2: if (cyprus.read_gpio() & 0b0001): sleep(.1) if (cyprus.read_gpio() & 0b0001): cyprus.set_pwm_values(1, period_value=100000, compare_value=50000, compare_mode=cyprus.LESS_THAN_OR_EQUAL) cyprus.set_servo_position(1, 1) print("r") else: cyprus.set_servo_position(1, .5) print("b")
def servo_binary(self): global bcount cyprus.initialize() if bcount % 2 == 0: self.servooo.text = "0 Deg" cyprus.set_servo_position(1, 0) sleep(0.1) else: self.servooo.text = "180 Deg" cyprus.set_servo_position(1, 1) sleep(0.1) bcount += 1 cyprus.close()
def setMagnet(self): global OFF if OFF: cyprus.set_servo_position(2, 1) print("magnet has grabbed") self.ids.magnetControl.text = "Magnet Off" OFF = False else: cyprus.set_servo_position(2, 0.5) print("magnet has released") self.ids.magnetControl.text = "Magnet On" OFF = True