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
close()[source]

Closes the serial connection to the Rotary Encoder board.

enable_evt_transmission()[source]

Enable the transmission of the events.

disable_evt_transmission()[source]

Disable the transmission of the events.

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.

read_stream()[source]

Read the data being streamed through the USB port.

enable_logging()[source]

Enable the logging to the SD Card.

disable_logging()[source]

Disable the logging to the SD Card.

get_logged_data()[source]

Retreave the logged data in the SD Card.

current_position()[source]

Retreave the current position.

set_zero_position()[source]

Set current rotary encoder position to zero.

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.
set_wrappoint(wrap_point)[source]

Set wrap point (number of tics in a half-rotation)

Variables:wrap_point (int) – number of tics in a half-rotation.
enable_thresholds(thresholds)[source]

Enable the thresholds.

Variables:thresholds (list(boolean)) – list of 6 booleans indicating which thresholds are active to trigger events.

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()