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

Motor port driver, macros and prototypes. More...

Go to the source code of this file.

Data Structures

struct  _vexMotor
 Holds data for a motor. More...
 

Macros

#define kVexMotorNormal   FALSE
 Motor command causes normal movement. More...
 
#define kVexMotorReversed   TRUE
 Motor command causes reversed movement. More...
 

Typedefs

typedef struct _vexMotor vexMotor
 Holds data for a motor. More...
 

Enumerations

enum  tVexMotorType { kVexMotorUndefined = 0, kVexMotor269, kVexMotor393T, kVexMotor393S }
 Motor types. More...
 
enum  tVexMotor {
  kVexMotor_None = -1, kVexMotor_1 = 0, kVexMotor_2 = 1, kVexMotor_3 = 2,
  kVexMotor_4 = 3, kVexMotor_5 = 4, kVexMotor_6 = 5, kVexMotor_7 = 6,
  kVexMotor_8 = 7, kVexMotor_9 = 8, kVexMotor_10 = 9, kVexMotorNum
}
 Motor port numbers. More...
 

Functions

void vexMotorInit (void)
 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 (void)
 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 vexMotorDebug (vexStream *chp, int argc, char *argv[])
 Command line debug of motors. 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...
 

Detailed Description

Motor port driver, macros and prototypes.

Macro Definition Documentation

#define kVexMotorNormal   FALSE

Motor command causes normal movement.

Examples:
clawbot.c, vexdefault.c, and vexuser.c.
#define kVexMotorReversed   TRUE

Motor command causes reversed movement.

Examples:
clawbot.c, and vexdefault.c.

Typedef Documentation

typedef struct _vexMotor vexMotor

Holds data for a motor.

Enumeration Type Documentation

Motor types.

Enumerator
kVexMotorUndefined 
kVexMotor269 
kVexMotor393T 
kVexMotor393S 
enum tVexMotor

Motor port numbers.

Enumerator
kVexMotor_None 
kVexMotor_1 
kVexMotor_2 
kVexMotor_3 
kVexMotor_4 
kVexMotor_5 
kVexMotor_6 
kVexMotor_7 
kVexMotor_8 
kVexMotor_9 
kVexMotor_10 
kVexMotorNum 

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)
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
bool_t vexMotorDirectionGet ( int16_t  index)

Get motor reversed flag.

Parameters
[in]indexThe motor index
Returns
bool indicating if the motor is reversed
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
void vexMotorPositionSet ( int16_t  index,
int32_t  value 
)

Set the current motor position.

Parameters
[in]indexThe motor index
[in]valueThe new motor position
int32_t vexMotorPositionGet ( int16_t  index)

Get the current motor position.

Parameters
[in]indexThe motor index
Returns
The motor position
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