USB
¶
-
class
pybpod_rotaryencoder_module.module_api.
RotaryEncoderModule
(serialport=None)[source]¶ Constructer of the RotaryEncoderModule object A a serial connection to the Rotary Encoder board is oppened at the construction of the object.
Variables: serialport (str) – PC serial port where the module is connect -
open
(serialport)[source]¶ Opens a serial connection to the Rotary Encoder board.
Variables: serialport (str) – PC serial port where the module is connect
-
enable_stream
()[source]¶ Enable the streaming of the position and the time measurements to the USB port.
-
disable_stream
()[source]¶ Disable the streaming of the position and the time measurements to the USB port.
-
set_prefix
(prefix)[source]¶ Variables: prefix (char) – One character to be used as prefix. Set 1-character prefix for module output stream.
-
set_thresholds
(thresholds)[source]¶ Set the thresholds values to trigger the events.
Variables: thresholds (list(int)) – List, in maximum, of 6 thresholds to trigger events.
-
set_position
(degrees)[source]¶ Set the current position in degrees.
Variables: degrees (int) – current position in degrees.
-
Usage example¶
from pybpod_rotaryencoder_module.module_api import RotaryEncoderModule
m = RotaryEncoderModule('/dev/ttyACM1')
m.start_logging()
m.enable_stream()
#print the first 100 outputs
count = 0
while count<100:
data = m.read_stream()
if len(data)==0:
continue
else:
count += 1
print(data)
m.disable_stream()
m.stop_logging()
m.set_zero_position()
m.close()