Functions to use the encoders.
More...
Functions to use the encoders.
<mbot/encoder/encoder.h>
◆ 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
-
ch | The 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
-
ch | The 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
-
ch | The channel to write to |
pos | The position to set |
- Returns
- int Returns 0 on success, -1 on failure