VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex_sonar.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* */
3/* Copyright (c) Innovation First 2017, All rights reserved. */
4/* */
5/* Module: vex_sonar.h */
6/* Author: James Pearman */
7/* Created: 7 July 2017 */
8/* */
9/* Revisions: */
10/* V1.00 TBD - Initial release */
11/* */
12/*----------------------------------------------------------------------------*/
13
14#ifndef VEX_SONAR_CLASS_H
15#define VEX_SONAR_CLASS_H
16
17/*-----------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22/*-----------------------------------------------------------------------------*/
24/*-----------------------------------------------------------------------------*/
25namespace vex {
26 class sonar : public device {
27
28 public:
33 sonar( int32_t index );
34 ~sonar();
35
36 bool installed();
37
42 int32_t value();
43
44 // settings
45 void setMaximum( double distance, distanceUnits units );
46
52 double distance( distanceUnits units );
53
58 bool foundObject();
59
64 void objectDetected( void (* callback)(void) );
65
70 void changed( void (* callback)(void) );
71
72 // action
73
74 private:
75 uint8_t _eventId_1;
76 uint32_t _maxdistance;
77 uint32_t _mindistance;
78 uint32_t _distance;
79
80 enum class tEventType {
81 EVENT_OBJECT = 1,
82 EVENT_CHANGED = 2
83 };
84
85 void setMinimum( double distance, distanceUnits units );
86 void setFilter( uint32_t value );
87 void setBrightnessThreshold( uint32_t value );
88
89 uint32_t distanceToRaw( double distance, distanceUnits units );
90 double rawToDistance( uint32_t raw, distanceUnits units );
91 };
92};
93
94#endif // VEX_SONAR_CLASS_H
Use the distance class to control the distance sensor.
void objectDetected(void(*callback)(void))
Calls a function when the sonar detect an object.
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 changed(void(*callback)(void))
Calls a function when the sonar value changes.
sonar(int32_t index)
Creates a new sonar sensor object on the port specified in the parameter.
int32_t value()
Gets the value of the sonar sensor.
Bumper switch device class
Definition vex_brain.h:24