API reference

class maestro.Maestro(dev: usb.core.Device, timeout=5000)

A Maestro servo controller.

You shouldn’t instantiate this class directly. Instead you should use one of the following class methods:

property channel_count

The number of available channels on this servo controller.

classmethod for_device(dev: usb.core.Device, **kwargs)maestro.Maestro

Returns a Maestro instance for the given pyusb Device.

classmethod get_all() → Iterable[maestro.Maestro]

Returns an iterator over all connected Maestro devices.

classmethod get_by_serial_number(serial_number)

Get a currently-connected Maestro device by its serial number.

Raises

maestro.exceptions.NoMaestroAvailable – if no Maestro is available.

classmethod get_one()maestro.Maestro

Get a currently-connected Maestro device.

If more than one is connected, it is undefined as to which device is returned.

Raises

maestro.exceptions.NoMaestroAvailable – if no Maestro is available.

property serial_number

The self-reported serial number for this device.

You may use this later as an argument to Maestro.get_by_serial_number() to ensure you connect to the same device again, in the case where multiple Maestro devices are connected.

Channels

class maestro.channel.Channel(maestro: maestro.Maestro, index: int, mode: ChannelMode)

A channel on a Maestro servo controller.

property mode

The mode of this channel.

Type

ChannelMode

property neutral

This option specifies the target value, in microseconds, that corresponds to 127 (neutral) for 8-bit commands.

property position

Where the servo controller believes this servo to be currently positioned.

Note that this is where the servo is currently being told to be, which will not necessarily be the target if speed and/or acceleration are non-zero.

The position is specified in milliseconds (ms).

Type

int

property target

The current target position, in ms.

Type

int

property value

The value read by this input, in the range [0, 1023].

The inputs on channels 0–11 are analogue: their values range from 0 to 1023, representing voltages from 0 to Vcc V. The inputs on channels 12–23 are digital: their values are either exactly 0 or exactly 1023.

Type

int

Enums

These are used as parameters and return values for various methods.

class maestro.enums.ChannelMode(value)

Channel mode.

Servo = 0

The channel is a servo.

ServoMultiplied = 1

This value is defined within the Maestro Control Centre, but unused.

It is not recommended to use this channel mode, as its purpose is unclear.

Output = 2

The channel is an output.

Output channels are controlled with a value in the range [0, 1023], which maps onto the range [0, Vcc] volts.

Input = 3

The channel is an input.

The value is in the range [0, 1), corresponding to the input voltage range [0, Vcc] volts.

class maestro.enums.USCParameter(value)

Constants for getting and setting Maestro parameters.

Initialized = 0
ServosAvailable = 1
ServoPeriod = 2
SerialMode = 3
SerialTimeout = 6
ChannelModes0To3 = 12
ChannelModes4To7 = 13
ChannelModes8To11 = 14
ChannelModes12To15 = 15
ChannelModes16To19 = 16
ChannelModes20To23 = 17
ServoMultiplier = 26
ServoHomeBase = 30
ServoMinBase = 32
ServoMaxBase = 33
ServoNeutralBase = 34
ServoRangeBase = 36
ServoSpeedBase = 37
ServoAccelerationBase = 38
class maestro.enums.Request(value)

Constants for Maestro USB control requests.

See The Maestro USB control protocol for more details about control requests.

GetRawParameter = 129
SetRawParameter = 130
GetVariablesMicroMaestro = 131
SetServoVariable = 132
SetTarget = 133
ClearErrors = 134
GetVariablesMiniMaestro = 135
GetStack = 136
GetCallStack = 137
SetPWM = 138
Reinitialize = 144
EraseScript = 160
WriteScript = 161
SetScriptDone = 162
RestartScriptAtSubroutine = 163
RestartScriptAtSubroutineWithParameter = 164
RestartScript = 165
StartBootloader = 255

Exceptions

exception maestro.exceptions.MaestroException

Base class for all Maestro-related exceptions.

exception maestro.exceptions.NoMaestroAvailable

Exception for when a Maestro device was requested, but none is available.