All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
vexmotor.c File Reference

Motor port driver. More...

#include <stdlib.h>
#include "ch.h"
#include "hal.h"
#include "vex.h"

Functions

void vexMotorInit ()
 Initialize the motors. More...
 
void vexMotorSet (int16_t index, int16_t value)
 Set motor to speed given by value. More...
 
int16_t vexMotorGet (int16_t index)
 Get the current commanded speed of a motor. More...
 
void vexMotorStopAll ()
 Stop all motors. More...
 
void vexMotorTypeSet (int16_t index, tVexMotorType type)
 Save motor type. More...
 
tVexMotorType vexMotorTypeGet (int16_t index)
 Get motor type. More...
 
void vexMotorDirectionSet (int16_t index, bool_t reversed)
 Save motor direction (reversed) flag. More...
 
bool_t vexMotorDirectionGet (int16_t index)
 Get motor reversed flag. More...
 
void vexMotorPositionSet (int16_t index, int32_t value)
 Set the current motor position. More...
 
int32_t vexMotorPositionGet (int16_t index)
 Get the current motor position. More...
 
void vexMotorPositionGetCallback (int16_t index, int32_t(*cb)(int16_t), int16_t port)
 Set the callback used to get motor position. More...
 
void vexMotorPositionSetCallback (int16_t index, void(*cb)(int16_t, int32_t), int16_t port)
 Set the callback used to set motor position. More...
 
void vexMotorEncoderIdCallback (int16_t index, int16_t(*cb)(int16_t), int16_t port)
 Set the callback used to get motor position. More...
 
int16_t vexMotorEncoderIdGet (int16_t index)
 Get the motor encoder id. More...
 
void vexMotorDebug (vexStream *chp, int argc, char *argv[])
 Command line debug of motors. More...
 

Detailed Description

Motor port driver.

Function Documentation

void vexMotorInit ( void  )

Initialize the motors.

void vexMotorSet ( int16_t  index,
int16_t  value 
)

Set motor to speed given by value.

Parameters
[in]indexThe motor index
[in]valueThe speed of the motor (-127 to 127)
Examples:
vexdefault.c.
int16_t vexMotorGet ( int16_t  index)

Get the current commanded speed of a motor.

Parameters
[in]indexThe motor index
Returns
The speed of the indexed motor (-127 to 127)
void vexMotorStopAll ( void  )

Stop all motors.

void vexMotorTypeSet ( int16_t  index,
tVexMotorType  type 
)

Save motor type.

Parameters
[in]indexThe motor index
[in]typeThe motor type
tVexMotorType vexMotorTypeGet ( int16_t  index)

Get motor type.

Parameters
[in]indexThe motor index
Returns
The motor type
void vexMotorDirectionSet ( int16_t  index,
bool_t  reversed 
)

Save motor direction (reversed) flag.

Parameters
[in]indexThe motor index
[in]reversedFlag indicating if the motor is reversed
Examples:
vexdefault.c.
bool_t vexMotorDirectionGet ( int16_t  index)

Get motor reversed flag.

Parameters
[in]indexThe motor index
Returns
bool indicating if the motor is reversed
void vexMotorPositionSet ( int16_t  index,
int32_t  value 
)

Set the current motor position.

Parameters
[in]indexThe motor index
[in]valueThe new motor position
Examples:
clawbot.c.
int32_t vexMotorPositionGet ( int16_t  index)

Get the current motor position.

Parameters
[in]indexThe motor index
Returns
The motor position
Examples:
clawbot.c.
void vexMotorPositionGetCallback ( int16_t  index,
int32_t(*)(int16_t)  cb,
int16_t  port 
)

Set the callback used to get motor position.

Parameters
[in]indexThe motor index
[in]cbfunction used to get motor position
[in]portA variable to send to the callback
void vexMotorPositionSetCallback ( int16_t  index,
void(*)(int16_t, int32_t)  cb,
int16_t  port 
)

Set the callback used to set motor position.

Parameters
[in]indexThe motor index
[in]cbfunction used to get motor position
[in]portA variable to send to the callback
void vexMotorEncoderIdCallback ( int16_t  index,
int16_t(*)(int16_t)  cb,
int16_t  port 
)

Set the callback used to get motor position.

Parameters
[in]indexThe motor index
[in]cbfunction used to get motor encoder id
[in]portA variable to send to the callback
int16_t vexMotorEncoderIdGet ( int16_t  index)

Get the motor encoder id.

Parameters
[in]indexThe motor index
Returns
The motor encoder id
Note
The encoder id is used to differentiate between encoder types
void vexMotorDebug ( vexStream chp,
int  argc,
char *  argv[] 
)

Command line debug of motors.

Parameters
[in]chpA pointer to a vexStream object
[in]argcThe number of command line arguments
[in]argvAn array of pointers to the command line args