Skip to content

Commit

Permalink
Updates demos to require port and cLibVersion.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared committed May 5, 2023
1 parent 9f15d5b commit c79936e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
14 changes: 6 additions & 8 deletions demos/demo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
print(msg)


# We begin by creating an instance of the Device class. By default,
# flexsea will attempt to find the connected device for you. It will
# also use a default value for the baud rate and version of the pre-
# compiled C library, both of which are set in flexsea.config. You
# can override these values by setting the appropriate keyword
# arguments in the constructor. If you have more than one device
# connected, you should manually specify the port for each
device = Device()
# We begin by creating an instance of the Device class. It will
# use a default value for the baud rate and log level. The C library
# version and device port must be manually specified.
cLibVersion = input("Please enter cLibVersion: ")
port = input("Please enter the device port: ")
device = Device(port=port, cLibVersion=cLibVersion)


# Once instantiated, we have to establish a connection between the
Expand Down
6 changes: 4 additions & 2 deletions demos/demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@


# Instantiate and connect to the device; see demo1.py
device = Device()
cLibVersion = input("Please enter cLibVersion: ")
port = input("Please enter the device port: ")
device = Device(port=port, cLibVersion=cLibVersion)
device.open()


Expand All @@ -48,7 +50,7 @@
# some offset. The motor position is given in "ticks", and the
# conversion between ticks and degrees depends on the device. For an
# actpack, the conversion is 350 degrees = 16384 ticks
offset = 10000
offset = 1000
pos0 = data["mot_ang"]
positions = [pos0, pos0 + offset]

Expand Down
4 changes: 3 additions & 1 deletion demos/demo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def clear() -> None:


# Instantiate and connect to device; see demo1.py
device = Device()
cLibVersion = input("Please enter cLibVersion: ")
port = input("Please enter the device port: ")
device = Device(port=port, cLibVersion=cLibVersion)
device.open()


Expand Down
6 changes: 4 additions & 2 deletions demos/demo4.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@


# Instantiate and connect to the device; see demo1.py
device = Device()
cLibVersion = input("Please enter cLibVersion: ")
port = input("Please enter the device port: ")
device = Device(port=port, cLibVersion=cLibVersion)
device.open()


Expand All @@ -39,7 +41,7 @@


# Set positions
offset = 7500
offset = 1000
pos0 = data["mot_ang"]
positions = [pos0, pos0 + offset]

Expand Down
10 changes: 3 additions & 7 deletions demos/demo5.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Demo 5: High Speed
Runs the motor at a high speed, demonstrating how to:
* Control which version of the pre-compiled C library is used
"""
# pylint: disable=duplicate-code

Expand All @@ -23,11 +21,9 @@
print(msg)


# Instantiate and connect to the device; see demo1.py
# Here we see that we can change which version of the pre-compiled C
# library is used by passing in a semantic version string to the
# `cLibVersion` keyword argument
device = Device(cLibVersion="9.1.0")
cLibVersion = input("Please enter cLibVersion: ")
port = input("Please enter the device port: ")
device = Device(port=port, cLibVersion=cLibVersion)
device.open()


Expand Down
4 changes: 3 additions & 1 deletion demos/demo6.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def send_command(
# get_device
# ============================================
def get_device(frequency: int) -> Device:
device = Device()
cLibVersion = input("Please enter cLibVersion: ")
port = input("Please enter the device port: ")
device = Device(port=port, cLibVersion=cLibVersion)
device.open()
device.start_streaming(frequency)

Expand Down

0 comments on commit c79936e

Please sign in to comment.