コード例 #1
0
ファイル: quasar_objects.py プロジェクト: Woz4tetra/Atlas
class StepperCommand(Command):
    def __init__(self, command_id):
        super().__init__(command_id, 'i16')

        self.delimiter_pin = pyb.Pin("Y2", pyb.Pin.IN, pyb.Pin.PULL_UP)

        self.stepper = Stepper(200, "Y3", "Y4", "Y5", "Y6")
        self.stepper.set_speed(25)

        self.calibrate()

    def callback(self, steps):
        self.stepper.step(steps)

    def calibrate(self):
        # print("calibrating stepper")
        # print(self.delimiter_pin.value())
        # while self.delimiter_pin.value():
        #     self.stepper.step(20)
        #     print(self.delimiter_pin.value())
        #
        # self.stepper.step(100)  # center steering
        # print("calibrated!")
        print("Skipping calibration")

    def reset(self):
        # recalibrate with delimiter
        self.calibrate()
コード例 #2
0
class StepperCommand(Command):
    def __init__(self, command_id):
        super().__init__(command_id, 'i16')

        self.delimiter_pin = pyb.Pin("Y1", pyb.Pin.IN, pyb.Pin.PULL_UP)

        self.stepper = Stepper(200, 25, "Y3", "Y4", "Y5", "Y6")

    def callback(self, steps):
        self.stepper.step(steps)

    def calibrate(self):
        print("Calibrating stepper... ", end="")
        while not self.delimiter_pin.value():
            self.stepper.step(-5)

        pyb.delay(10)  # if this isn't here the stepper won't switch directions

        self.stepper.step(150)  # center the steering
        print("done!")

    def reset(self):
        # recalibrate with delimiter
        self.calibrate()
コード例 #3
0
ファイル: stepper_test.py プロジェクト: Woz4tetra/Atlas
import pyb
from libraries.stepper import Stepper

stepper = Stepper(200, "Y3", "Y4", "Y5", "Y6")
stepper.set_speed(25)

while True:
    steps = int(input("steps: "))
    stepper.step(steps)
    pyb.delay(500)
コード例 #4
0
import pyb
from libraries.stepper import Stepper

stepper = Stepper(200, 25, "Y3", "Y4", "Y5", "Y6")

while True:
    steps = int(input("steps: "))
    stepper.step(steps)
    pyb.delay(500)