LineItem.__init__(self, item_id, name, protocol)
        self._motor_index = motor_index

    @parlay_command()
    def spin(self, speed):
        """
        Move the motor at a constant speed, between -9 and 9.  Negative speed causes motor to spin in reverse.
        :param speed: speed to move
        :type speed int
        :return: none
        """
        speed = int(speed)
        if speed > 9 or speed < -9:
            raise ValueError("Speed outside range")
        direction = "f" if speed >= 0 else "r"
        self.send_raw_data("{}{}{}".format(self._motor_index, direction, abs(speed)))
        return self.wait_for_data()

    @parlay_command()
    def stop(self):
        """
        Stop the motor
        :return: none
        """
        return self.spin(0)


if __name__ == "__main__":

    start()
Ejemplo n.º 2
0
import parlay
from parlay.protocols.elite import EliteArmProtocol
from parlay.protocols.leapmotion import protocol

parlay.start()
Ejemplo n.º 3
0
def main():
    start()
Ejemplo n.º 4
0
                                      "DESCRIPTION":
                                      "Unsupported command {}".format(cmd)
                                  })

    def spin(self, speed):
        """
        Move the motor at a constant speed, between -9 and 9.  Negative speed causes motor to spin in reverse.
        :param speed: speed to move
        :type speed int
        :return: none
        """
        speed = int(speed)
        if speed > 9 or speed < -9:
            raise ValueError("Speed outside range")
        direction = "f" if speed >= 0 else "r"
        data = "{}{}{}".format(self._motor_index, direction, abs(speed))

        self._protocol.sendLine(data)

    def stop(self):
        """
        Stop the motor
        :return: none
        """
        return self.spin(0)


if __name__ == "__main__":

    start()
from parlay import start, local_item, ParlayCommandItem, parlay_command
from parlay.utils import sleep


@local_item(auto_connect=True)
class Item1(ParlayCommandItem):
    @parlay_command()
    def slow_command_1(self):
        sleep(5)
        return "Command 1 Completed!"

    @parlay_command()
    def delete_me(self):
        return "Boo!"


@local_item(auto_connect=True)
class Item2(ParlayCommandItem):
    @parlay_command()
    def slow_command_2(self):
        sleep(5)
        return "Command 2 Completed!"

    @parlay_command()
    def delete_me(self):
        return "Boo!"


if __name__ == "__main__":
    start(open_browser=False)  # you can avoid launching your web browser
@local_item(auto_connect=True)
class Item1(ParlayCommandItem):

    @parlay_command()
    def slow_command_1(self):
        sleep(5)
        return "Command 1 Completed!"

    @parlay_command()
    def delete_me(self):
        return "Boo!"


@local_item(auto_connect=True)
class Item2(ParlayCommandItem):

    @parlay_command()
    def slow_command_2(self):
        sleep(5)
        return "Command 2 Completed!"

    @parlay_command()
    def delete_me(self):
        return "Boo!"


if __name__ == "__main__":
    start(open_browser=False)  # you can avoid launching your web browser

Ejemplo n.º 7
0
def main():
    start()