VEX IQ C++ API
Public Member Functions | List of all members
vex::sonar Class Reference

Sonar sensor device class. More...

Inherits vex::device.

Public Member Functions

 sonar (int32_t index)
 Creates a new sonar sensor object on the port specified in the parameter. More...
 
 ~sonar ()
 
void setMaximum (float distance, distanceUnits units)
 Sets the maximum distance (default 2.5m) More...
 
float distance (distanceUnits units)
 Gets the value of the sonar sensor. More...
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
 ~device ()
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 

Detailed Description

Sonar sensor device class.

Constructor & Destructor Documentation

◆ sonar()

vex::sonar::sonar ( int32_t  index)
inline

Creates a new sonar sensor object on the port specified in the parameter.

Parameters
indexto the brain port.

◆ ~sonar()

vex::sonar::~sonar ( )
inline

Member Function Documentation

◆ setMaximum()

void vex::sonar::setMaximum ( float  distance,
distanceUnits  units 
)

Sets the maximum distance (default 2.5m)

Parameters
distanceMaximum distance to be measured in units
unitsThe measurement unit for the sonar device.

◆ distance()

float vex::sonar::distance ( distanceUnits  units)

Gets the value of the sonar sensor.

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