MBot Software Library  v1.0
An API documentation to mbot_firmware repository
Functions
Encoder

Functions to use the encoders. More...

Collaboration diagram for Encoder:

Functions

int mbot_encoder_init ()
 Initializes the encoder counters for channels 1-3. This also resets the encoder position to 0. More...
 
int mbot_encoder_cleanup ()
 Stops the encoder counters. Recommended to be called at the end of the program. More...
 
int mbot_encoder_read_delta (uint8_t ch)
 Reads the current delta of an encoder channel. More...
 
int mbot_encoder_read_count (uint8_t ch)
 Reads the current count of an encoder channel. The count is a signed 32-bit integer that wraps around at +- 2^31. More...
 
int mbot_encoder_write (uint8_t ch, int pos)
 Sets the current position of an encoder channel. Typically used to reset a counter to 0, but can set an arbitrary position. More...
 

Detailed Description

Functions to use the encoders.

<mbot/encoder/encoder.h>

Function Documentation

◆ mbot_encoder_cleanup()

int mbot_encoder_cleanup ( )

Stops the encoder counters. Recommended to be called at the end of the program.

Returns
int Returns 0 on success or -1 on failure.

◆ mbot_encoder_init()

int mbot_encoder_init ( )

Initializes the encoder counters for channels 1-3. This also resets the encoder position to 0.

Returns
int Returns 0 on success or -1 on failure

◆ mbot_encoder_read_count()

int mbot_encoder_read_count ( uint8_t  ch)

Reads the current count of an encoder channel. The count is a signed 32-bit integer that wraps around at +- 2^31.

Parameters
chThe channel to read from
Returns
int Returns the current count (signed 32-bit integer) or -1 if there is a problem.

◆ mbot_encoder_read_delta()

int mbot_encoder_read_delta ( uint8_t  ch)

Reads the current delta of an encoder channel.

Parameters
chThe channel to read from
Returns
int Returns the current delta (signed 32-bit integer) or -1 if there is a problem.

◆ mbot_encoder_write()

int mbot_encoder_write ( uint8_t  ch,
int  pos 
)

Sets the current position of an encoder channel. Typically used to reset a counter to 0, but can set an arbitrary position.

Parameters
chThe channel to write to
posThe position to set
Returns
int Returns 0 on success, -1 on failure