VEXcode Doxygen
Public Member Functions | Public Attributes | List of all members
vex::encoder Class Reference

Use this class when programming with an encoder. More...

#include <vex_triport.h>

Inheritance diagram for vex::encoder:
vex::__tridevice

Public Member Functions

 encoder (triport::port &port)
 Creates a new encoder object on the port specified in the parameter. More...
 
int32_t value ()
 Gets the value of the encoder. More...
 
 operator int ()
 
void resetRotation (void)
 Resets the rotation of the encoder to zero. More...
 
void setRotation (double val, rotationUnits units)
 Sets the rotation of the encoder to a specific value. More...
 
void setPosition (double val, rotationUnits units)
 
double rotation (rotationUnits units)
 Gets the rotation value of the encoder. More...
 
double position (rotationUnits units)
 
double velocity (velocityUnits units)
 Gets the velocity of the encoder. More...
 
void changed (void(*callback)(void))
 Calls a function when the encoder value changes. More...
 

Public Attributes

mevent & CHANGED = _CHANGED
 

Detailed Description

Use this class when programming with an encoder.

@prog_lang{block|cpp|pro}

Constructor & Destructor Documentation

◆ encoder()

vex::encoder::encoder ( triport::port port)

Creates a new encoder object on the port specified in the parameter.

@prog_lang{cpp|pro} @drawer_cat{constructor} @block_sig{vex::encoder Encoder = vex::encoder(Brain.ThreeWirePort.A);}

Parameters
portA reference to a three wire port.

Member Function Documentation

◆ changed()

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

Calls a function when the encoder value changes.

@prog_lang{pro} @drawer_cat{sensing} @block_sig{Encoder.changed(changedFunction);}

Parameters
callbackA reference to a function.

◆ resetRotation()

void vex::encoder::resetRotation ( void  )

Resets the rotation of the encoder to zero.

@prog_lang{block|cpp|pro} @drawer_cat{setting} @block_sig{Encoder.resetRotation();}

◆ rotation()

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

Gets the rotation value of the encoder.

@prog_lang{block|cpp|pro} @drawer_cat{sensing} @block_sig{Encoder.rotation(degrees)} @cpp_sig{Encoder.rotation(vex::rotationUnits::deg)}

Returns
Returns a double that represents the current rotation of the encoder.
Parameters
unitsThe measurement unit for the encoder device.

◆ setRotation()

void vex::encoder::setRotation ( double  val,
rotationUnits  units 
)

Sets the rotation of the encoder to a specific value.

@prog_lang{block|cpp|pro} @drawer_cat{setting} @block_sig{Encoder.setRotation(90, degrees);} @cpp_sig{Encoder.setRotation(90, vex::rotationUnits::deg);}

Parameters
valSets the amount of rotation.
unitsThe measurement unit for the rotation value.

◆ value()

int32_t vex::encoder::value ( )

Gets the value of the encoder.

@prog_lang{none} @drawer_cat{none} @block_sig{Encoder.value()}

Returns
Returns an integer that represents the value of the encoder device.

◆ velocity()

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

Gets the velocity of the encoder.

@prog_lang{block|cpp|pro} @drawer_cat{sensing} @block_sig{Encoder.velocity(rpm)} @cpp_sig{Encoder.velocity(vex::velocityUnits::rpm)}

Returns
Returns a double that represents the current velocity of the encoder.
Parameters
unitsThe measurement unit for the encoder device.

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