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

Use this class when programming with a gyro sensor. More...

#include <vex_triport.h>

Inheritance diagram for vex::gyro:
vex::__tridevice vex::guido

Public Member Functions

 gyro (triport::port &port)
 Creates a new gyro object on the port specified in the parameter. More...
 
int32_t value (analogUnits units)
 Gets the value of the gyro sensor. More...
 
double value (rotationUnits units)
 Gets the value of the gyro sensor. More...
 
int32_t value (percentUnits units)
 Gets the value of the gyro sensor. More...
 
void startCalibration (int32_t value=0)
 Starts recalibration of the gyro. More...
 
void calibrate (int32_t value=0)
 
bool isCalibrating ()
 Returns true while the gyro sensor is performing a requested recalibration, changing to false once recalibration has completed. More...
 
void changed (void(*callback)(void))
 Calls a function when the gyro sensor value changes. More...
 
void resetAngle ()
 reset the gyro sensor angle to 0
 
void resetHeading ()
 reset the gyro sensor angle to 0
 
void resetRotation ()
 reset the gyro sensor absolute angle to 0
 
void resetAngle (double value, rotationUnits units)
 reset the gyro sensor angle to angle More...
 
void setHeading (double value, rotationUnits units)
 reset the gyro sensor angle to angle More...
 
double angle (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor. More...
 
double heading (rotationUnits units=rotationUnits::deg)
 Gets the angle of the gyro sensor. More...
 
double rotation (rotationUnits units=rotationUnits::deg)
 Gets the rotation (absolute angle) of the gyro sensor. More...
 
void setRotation (double value, rotationUnits units)
 set the gyro sensor rotation to angle More...
 

Public Attributes

mevent & CHANGED = _CHANGED
 

Detailed Description

Use this class when programming with a gyro sensor.

@prog_lang{block|cpp|pro}

Constructor & Destructor Documentation

◆ gyro()

vex::gyro::gyro ( triport::port port)

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

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

Parameters
portA reference to a three wire port.

Member Function Documentation

◆ angle()

double vex::gyro::angle ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the angle of the gyro sensor.

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

Implements vex::guido.

◆ changed()

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

Calls a function when the gyro sensor value changes.

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

Parameters
callbackA reference to a function.

◆ heading()

double vex::gyro::heading ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the angle of the gyro sensor.

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

Implements vex::guido.

◆ isCalibrating()

bool vex::gyro::isCalibrating ( )
virtual

Returns true while the gyro sensor is performing a requested recalibration, changing to false once recalibration has completed.

@prog_lang{pro} @drawer_cat{sensing} @block_sig{Gyro.isCalibrating()}

Returns
Returns true if gyro is still calibrating.

Implements vex::guido.

◆ resetAngle()

void vex::gyro::resetAngle ( double  value,
rotationUnits  units 
)

reset the gyro sensor angle to angle

Parameters
valueThe new angle for the gyro
unitsThe rotation unit for the angle

◆ rotation()

double vex::gyro::rotation ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the rotation (absolute angle) of the gyro sensor.

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

Implements vex::guido.

◆ setHeading()

void vex::gyro::setHeading ( double  value,
rotationUnits  units 
)
virtual

reset the gyro sensor angle to angle

Parameters
valueThe new heading for the gyro
unitsThe rotation unit for the angle

Implements vex::guido.

◆ setRotation()

void vex::gyro::setRotation ( double  value,
rotationUnits  units 
)
virtual

set the gyro sensor rotation to angle

Parameters
valueThe new absolute angle for the gyro
unitsThe rotation unit for the angle

Implements vex::guido.

◆ startCalibration()

void vex::gyro::startCalibration ( int32_t  value = 0)

Starts recalibration of the gyro.

@prog_lang{pro} @drawer_cat{action} @block_sig{Gyro.startCalibration()}

Parameters
value(Optional) Sets the amount of calibration time. By default, this parameter is zero.

◆ value() [1/3]

int32_t vex::gyro::value ( analogUnits  units)

Gets the value of the gyro sensor.

@prog_lang{cpp|pro} @drawer_cat{sensing} @block_sig{Gyro.value(vex::analogUnits::range8bit)}

Returns
Returns an integer that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

◆ value() [2/3]

int32_t vex::gyro::value ( percentUnits  units)
inline

Gets the value of the gyro sensor.

@prog_lang{block|cpp|pro} @drawer_cat{sensing} @block_sig{Gyro.value(percent)} @cpp_sig{Gyro.value(vex::percentUnits::pct)}

Returns
Returns an integer that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

◆ value() [3/3]

double vex::gyro::value ( rotationUnits  units)

Gets the value of the gyro sensor.

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

Returns
Returns an integer that represents the unit value specified by the parameter of the gyro sensor.
Parameters
unitsThe measurement unit for the gyro device.

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