VEXcode IQ C++ Unofficial documentation for version 3.0.4.1
Loading...
Searching...
No Matches
vex_optical.h
Go to the documentation of this file.
1/*----------------------------------------------------------------------------*/
2/* */
3/* Copyright (c) Innovation First 2019, All rights reserved. */
4/* */
5/* Module: vex_optical.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_OPTICAL_CLASS_H
15#define VEX_OPTICAL_CLASS_H
16
17/*-----------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace vex {
26 class optical : public device {
27 private:
28 int32_t _led_intensity;
29 int32_t _prox_threshold;
30 int32_t _last_hue;
31
32 enum class tEventType {
33 EVENT_OBJECT_FOUND = 0,
34 EVENT_OBJECT_LOST = 1,
35 EVENT_GESTURE_UP = 2,
36 EVENT_GESTURE_DOWN = 3,
37 EVENT_GESTURE_LEFT = 4,
38 EVENT_GESTURE_RIGHT = 5,
39 };
40
41 public:
47 optical( int32_t index, bool enableGesture = false );
48 ~optical();
49
50 bool installed();
51 int32_t value();
52
57 double hue();
58
63 double brightness( bool bRaw = false );
64
69 //vex::color color();
70
75 vex::colorType colorname();
76
82
87 void objectDetected( void (* callback)(void) );
88
93 void objectLost( void (* callback)(void) );
94
100 int32_t objectDetectThreshold( int32_t value = 0 );
101
106 void gestureUp( void (* callback)(void) );
107
112 void gestureDown( void (* callback)(void) );
113
118 void gestureLeft( void (* callback)(void) );
119
124 void gestureRight( void (* callback)(void) );
125
129 void setLight( ledState state );
130
134 void setLightPower( int32_t intensity, percentUnits units = percentUnits::pct );
135
139 class gesture {
140 friend vex::optical;
141
142 private:
143 uint8_t _udata;
144 uint8_t _ddata;
145 uint8_t _ldata;
146 uint8_t _rdata;
147 uint32_t _count;
148 gestureType _type;
149
150 public:
151 gesture();
152 ~gesture();
153
154 const uint8_t & udata = _udata;
155 const uint8_t & ddata = _ddata;
156 const uint8_t & ldata = _ldata;
157 const uint8_t & rdata = _rdata;
158 const uint32_t & count = _count;
159
160 const gestureType & type = _type;
161 };
162
166 void gestureEnable(void);
167
171 void gestureDisable(void);
172
177
181 class rgbc {
182 friend vex::optical;
183
184 public:
185 double red;
186 double green;
187 double blue;
188 double clear;
189
190 rgbc() : red(0), green(0), blue(0), clear(0) {}
191 ~rgbc() {}
192 };
193
197 optical::rgbc getRgb( bool bRawColor = true );
198
202 void integrationTime( double timeMs );
203
208
209 };
210};
211
212#endif // VEX_OPTICAL_CLASS_H
A class to collect all gesture detection data.
A class to hold raw or processed rgbc data.
Use the optical class to control the optical sensor.
Definition vex_optical.h:26
bool isNearObject()
Check to see if an object is detected by the optical sensor.
double brightness(bool bRaw=false)
Gets the brightness value detected by the optical sensor.
int32_t objectDetectThreshold(int32_t value=0)
sets the value of the detection threshold
void objectDetected(void(*callback)(void))
Calls a function when the optical sensor proximity sensor detects an object.
void gestureUp(void(*callback)(void))
Calls a function when the optical sensor gesture engine detects a movement down to up.
void gestureLeft(void(*callback)(void))
Calls a function when the optical sensor gesture engine detects a movement right to left.
void gestureRight(void(*callback)(void))
Calls a function when the optical sensor gesture engine detects a movement left to right.
void setLight(ledState state)
Turns the led on the optical sensor on or off.
double hue()
Gets the hue detected by the optical sensor.
optical(int32_t index, bool enableGesture=false)
Creates a new optical sensor object on the port specified.
void gestureEnable(void)
Enable gesture detection on the optical sensor.
vex::colorType colorname()
Gets the detected color as a fully saturated vex::color.
void gestureDisable(void)
Disable gesture detection on the optical sensor.
void setLightPower(int32_t intensity, percentUnits units=percentUnits::pct)
Set the intensity of the led on the optical sensor in percent.
void gestureDown(void(*callback)(void))
Calls a function when the optical sensor gesture engine detects a movement up to down.
void integrationTime(double timeMs)
set sensor integration time
optical::rgbc getRgb(bool bRawColor=true)
get raw or processed rgbc data. The default is raw.
double integrationTime()
get sensor integration time
optical::gesture getGesture()
get object with the most recent gesture detection data.
void objectLost(void(*callback)(void))
Calls a function when the optical sensor proximity sensor detects an object is missing.
Bumper switch device class
Definition vex_brain.h:24
gestureType
The defined units for optical sensor gesture types.
Definition vex_units.h:167