VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex_distance.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* */
3/* Copyright (c) Innovation First 2019, All rights reserved. */
4/* */
5/* Module: vex_distance.h */
6/* Author: James Pearman */
7/* Created: 26 May 2020 */
8/* */
9/* Revisions: */
10/* V1.00 TBD - Initial release */
11/* */
12/*----------------------------------------------------------------------------*/
13
14#ifndef VEX_DISTANCE_CLASS_H
15#define VEX_DISTANCE_CLASS_H
16
17/*-----------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace vex {
26 class distance : public device {
27 private:
28 enum class tEventType {
29 EVENT_DISTANCE_CHANGED = 0,
30 };
31
32 public:
37 distance( int32_t index );
38 ~distance();
39
40 bool installed();
41 int32_t value();
42
43
49 double objectDistance( distanceUnits units );
50
55 sizeType objectSize( void );
56
61 int32_t objectRawSize( void );
62
67 double objectVelocity( void );
68
73 bool isObjectDetected( void );
74
79 void changed( void (* callback)(void) );
80
81 private:
82 uint32_t _distance;
83 uint32_t _size;
84 float _velocity;
85
86 int32_t _lastpolltimeSize;
87 int32_t _lastpolltimeVelocity;
88 int16_t _pollinterval;
89
90 bool pollValidSize( bool bSave );
91 bool pollValidVelocity( bool bSave );
92 };
93};
94
95#endif // VEX_DISTANCE_CLASS_H
Use the distance class to control the distance sensor.
bool isObjectDetected(void)
check for object in range of the distance sensor
sizeType objectSize(void)
Gets an estimate of the detected object size.
double objectDistance(distanceUnits units)
Gets the detected object distance.
distance(int32_t index)
Creates a new distance sensor object on the port specified.
int32_t objectRawSize(void)
Gets an estimate of the detected object size.
double objectVelocity(void)
Gets an estimate of the detected object velocity.
void changed(void(*callback)(void))
Calls a function when the distance value changes.
Bumper switch device class
Definition vex_brain.h:24