RCServo

class brainstem.stem.RCServo(module, index)[source]

Provides RCServo functionality on certain modules.

This entity is only available on certain modules. The RCServoClass can be used to interpret and control RC Servo signals and motors via the digital pins.

Useful Constants:
  • SERVO_DEFAULT_POSITION (128)

  • SERVO_DEFAULT_MIN (64)

  • SERVO_DEFAULT_MAX (192)

getEnable()[source]

Get the enable status of the servo channel.

If the enable status is 0 the servo channel is disabled, if the status is 1 the channel is enabled.

Returns

Result object, containing NO_ERROR and servo enable status

or a non zero Error code.

Return type

Result

getPosition()[source]

Get the position of the servo channel.

Default configuration: 1ms = 64 and 2ms = 192

Returns

Result object, containing NO_ERROR and the servo position

or a non zero Error code.

Return type

Result

getReverse()[source]

Get the reverse status of the channel.

0 = not reversed, 1 = reversed

Returns

Result object, containing NO_ERROR and the reverse status

or a non zero Error code.

Return type

Result

setEnable(enable)[source]

Enable the servo channel.

Param:

enable (bool): The state to be set. 0 is disabled, 1 is enabled

Returns

Return NO_ERROR on success, or one of the common sets of return error codes on failure.

Return type

Result.error

setPosition(position)[source]

Set the position of the servo channel.

Param:

position (int): The position to be set. With the default configuration 64 = a 1ms pulse and 192 = a 2ms pulse.

Returns

Return NO_ERROR on success, or one of the common sets of return error codes on failure.

Return type

Result.error

setReverse(reverse)[source]

Se the output to be reverse on the servo channel.

Param:

reverse (bool): Reverse mode: 0 = not reversed, 1 = reversed. ie: setPosition of 64 would actually apply 192 tot he servo output; however, getPosition will return 64.

Returns

Return NO_ERROR on success, or one of the common sets of return error codes on failure.

Return type

Result.error