CSonar is used to control VEX ultrasonic range modules, catalog number 276-2155. More...
#include <sonar.h>
Public Member Functions | |
| CSonar (unsigned int inputPort, unsigned int outputPort) | |
| Constructor for a sonar module. | |
| ~CSonar () | |
| int | Fire (bool wait=false) |
| Fire the sonar "chirp". | |
| int | GetVal () |
| Get the distnce value in inches. | |
| int | RegisterCallback (void(*callback)(unsigned int inputPort, int val)) |
| Set a callback routine that get called when an echo is received. | |
| int | UnregisterCallback () |
| Remove the callback routine. | |
CSonar is used to control VEX ultrasonic range modules, catalog number 276-2155.
Up to 8 modules can be used with the VEXPro controller. See CSonarController for methods that control the automated firing of multiple sonar modules (sonar arrays).
| CSonar::CSonar | ( | unsigned int | inputPort, | |
| unsigned int | outputPort | |||
| ) |
Constructor for a sonar module.
| inputPort | the digital port number of the "INPUT" connector of the sonar module. Can be 0 through 15 corresponding to digital connector 1 through 16, respectively. | |
| outputPort | the digital port number of the "OUTPUT" connector of the sonar module. Can be 0 through 15 corresponding to digital connector 1 through 16, respectively. |
| CSonar::~CSonar | ( | ) |
| int CSonar::Fire | ( | bool | wait = false |
) |
Fire the sonar "chirp".
| wait | if false (default), this method will not wait until the echo is received. If true, this method will wait until the echo is received before returning. |
| int CSonar::GetVal | ( | ) |
Get the distnce value in inches.
| int CSonar::RegisterCallback | ( | void(*)(unsigned int inputPort, int val) | callback | ) |
Set a callback routine that get called when an echo is received.
| callback | the routine you wish to be called. This routine returns the inputPort number -- the same number passed to the constructor -- and the distance value in inches. |
| int CSonar::UnregisterCallback | ( | ) |
Remove the callback routine.
After calling this method, the callback routine set from RegisterCallback will not be called again.
1.7.1