コード例 #1
0
ファイル: main.py プロジェクト: cbohley/Robotic-Arm-Widget
 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)
コード例 #2
0
ファイル: main.py プロジェクト: beebopenguin/PerpetualMotion
    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
コード例 #3
0
def toggle_magnet():
    global ON
    if ON:
        cyprus.set_servo_position(2, 0.5)
    else:
        cyprus.set_servo_position(2, 1)
    ON = not ON
コード例 #4
0
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
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
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)
コード例 #8
0
 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)
コード例 #9
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()
コード例 #10
0
 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()
コード例 #11
0
    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")
コード例 #12
0
ファイル: main.py プロジェクト: cbohley/Robotic-Arm-Widget
 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()
コード例 #13
0
ファイル: main.py プロジェクト: beebopenguin/PerpetualMotion
 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")
コード例 #14
0
 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)
コード例 #15
0
    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
コード例 #16
0
 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"
コード例 #17
0
 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)
コード例 #18
0
 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
コード例 #19
0
 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)
コード例 #20
0
 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()
コード例 #21
0
 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
コード例 #22
0
 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)
コード例 #23
0
 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")
コード例 #24
0
    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)
コード例 #25
0
 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
コード例 #26
0
 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
コード例 #27
0
 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
コード例 #28
0
 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")
コード例 #29
0
ファイル: main.py プロジェクト: jassiel/Ex-7-Hardware-Startup
 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()
コード例 #30
0
    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