VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex::sonar Class Reference
Inheritance diagram for vex::sonar:
vex::device

Public Member Functions

 sonar (int32_t index)
 Creates a new sonar sensor object on the port specified in the parameter.
 
bool installed ()
 
int32_t value ()
 Gets the value of the sonar sensor.
 
void setMaximum (double distance, distanceUnits units)
 
double distance (distanceUnits units)
 Gets the value of the sonar sensor.
 
bool foundObject ()
 Gets an object is present in front of the sonar sensor.
 
void objectDetected (void(*callback)(void))
 Calls a function when the sonar detect an object.
 
void changed (void(*callback)(void))
 Calls a function when the sonar value changes.
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
IQ_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
int32_t readDigitalPin ()
 
int32_t readAnalogPin ()
 

Additional Inherited Members

- Protected Member Functions inherited from vex::device
void setPollInterval (int32_t value)
 
bool pollValid (bool bSave)
 
- Protected Attributes inherited from vex::device
int16_t _index
 

Detailed Description

Definition at line 26 of file vex_sonar.h.

Constructor & Destructor Documentation

◆ sonar()

vex::sonar::sonar ( int32_t index)

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

Parameters
portindex to the brain port.

Member Function Documentation

◆ changed()

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

Calls a function when the sonar value changes.

Parameters
callbackA reference to a function.

◆ distance()

double 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.

◆ foundObject()

bool vex::sonar::foundObject ( )

Gets an object is present in front of the sonar sensor.

Returns
Returns a boolean that will be true if the sonar sensor is detecting an object.

◆ installed()

bool vex::sonar::installed ( )
virtual

Reimplemented from vex::device.

◆ objectDetected()

void vex::sonar::objectDetected ( void(* callback )(void))

Calls a function when the sonar detect an object.

Parameters
callbackA reference to a function.

◆ value()

int32_t vex::sonar::value ( )
virtual

Gets the value of the sonar sensor.

Returns
Returns an integer that represents the distance to the largest object in mm

Reimplemented from vex::device.


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