VEXcode Doxygen
Public Types | Public Member Functions | Protected Member Functions | List of all members
vex::rotation Class Reference

Use the rotation class to control absolute encoder devices. More...

#include <vex_rotation.h>

Inheritance diagram for vex::rotation:
vex::device

Public Types

enum  tEventType { EVENT_ANGLE_CHANGED = 0 }
 

Public Member Functions

 rotation (int32_t index, bool reverse=false)
 Creates a new rotation object on the port specified. More...
 
bool installed ()
 
int32_t value ()
 
void setReversed (bool value)
 Sets the encoder mode to "reverse", position and angle will change in the opposite direction. More...
 
double angle (rotationUnits units=rotationUnits::deg)
 Gets the angle of the absolute encoder. More...
 
void resetPosition (void)
 Resets the position of the absolute encoder to the value of zero.
 
void setPosition (double value, rotationUnits units)
 Sets the value of the absolute encoder to the value specified in the parameter. More...
 
double position (rotationUnits units)
 Gets the current position of the absolute encoder. More...
 
double velocity (velocityUnits units)
 Gets the current velocity of the absolute encoder. More...
 
void changed (void(*callback)(void))
 Calls a function when the encoder value changes. More...
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
V5_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
uint32_t timestamp ()
 

Protected Member Functions

int32_t status ()
 recover abs encoder raw status
 
double temperature ()
 recover abs encoder temperature in deg C
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 
int32_t _threadID
 

Detailed Description

Use the rotation class to control absolute encoder devices.

Constructor & Destructor Documentation

◆ rotation()

vex::rotation::rotation ( int32_t  index,
bool  reverse = false 
)

Creates a new rotation object on the port specified.

Parameters
indexThe port index for this rotation sensor. The index is zero-based.

Member Function Documentation

◆ angle()

double vex::rotation::angle ( rotationUnits  units = rotationUnits::deg)

Gets the angle of the absolute encoder.

Returns
Returns a double that represents the unit value specified by the parameter of the encoder sensor.
Parameters
unitsThe measurement unit for the encoder device.

◆ changed()

void vex::rotation::changed ( void(*)(void)  callback)

Calls a function when the encoder value changes.

Parameters
callbackA reference to a function.

◆ position()

double vex::rotation::position ( rotationUnits  units)

Gets the current position of the absolute encoder.

Returns
Returns a double that represents the current position of the encoder in the units defined in the parameter.
Parameters
unitsThe measurement unit for the position.

◆ setPosition()

void vex::rotation::setPosition ( double  value,
rotationUnits  units 
)

Sets the value of the absolute encoder to the value specified in the parameter.

Parameters
valueSets the current position of the absolute encoder.
unitsThe measurement unit for the position value.

◆ setReversed()

void vex::rotation::setReversed ( bool  value)

Sets the encoder mode to "reverse", position and angle will change in the opposite direction.

Parameters
valueIf set to true, the encoder counts in reverse

◆ velocity()

double vex::rotation::velocity ( velocityUnits  units)

Gets the current velocity of the absolute encoder.

Returns
Returns a double that represents the current velocity of the encoder in the units defined in the parameter.
Parameters
unitsThe measurement unit for the velocity.

The documentation for this class was generated from the following file: