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

Use this class when programming with an accelerometer sensor. More...

#include <vex_triport.h>

Inheritance diagram for vex::accelerometer:
vex::__tridevice

Public Member Functions

 accelerometer (triport::port &port, bool bHighSensitivity=false)
 Creates a new accelerometer object on the port specified in the parameter. More...
 
int32_t value (analogUnits units)
 Gets the value of the accelerometer. More...
 
int32_t value (percentUnits units)
 Gets the value of the accelerometer. More...
 
double acceleration ()
 Gets the value of the accelerometer in G. More...
 
void changed (void(*callback)(void))
 Calls a function when the accelerometer value changes. More...
 

Public Attributes

mevent & CHANGED = _CHANGED
 

Detailed Description

Use this class when programming with an accelerometer sensor.

@prog_lang{block|cpp|pro}

Constructor & Destructor Documentation

◆ accelerometer()

vex::accelerometer::accelerometer ( triport::port port,
bool  bHighSensitivity = false 
)

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

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

Parameters
portA reference to a three wire port.

Member Function Documentation

◆ acceleration()

double vex::accelerometer::acceleration ( )

Gets the value of the accelerometer in G.

Returns
Returns a double that represents the acceleration in G of the accelerometer sensor.

◆ changed()

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

Calls a function when the accelerometer value changes.

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

Parameters
callbackA reference to a function.

◆ value() [1/2]

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

Gets the value of the accelerometer.

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

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

◆ value() [2/2]

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

Gets the value of the accelerometer.

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

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

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