-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVisionColorSensor.h
43 lines (36 loc) · 1.07 KB
/
VisionColorSensor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef VisionColorSensor_h
#define VisionColorSensor_h
#include <Wire.h>
#include <ADJDS311.h>
#include "Arduino.h"
#define MIN3(x,y,z) ((y) <= (z) ? \
((x) <= (y) ? (x) : (y)) \
: \
((x) <= (z) ? (x) : (z)))
#define MAX3(x,y,z) ((y) >= (z) ? \
((x) >= (y) ? (x) : (y)) \
: \
((x) >= (z) ? (x) : (z)))
struct rgb_color {
unsigned char r, g, b; /* Channel intensities between 0 and 255 */
};
struct hsv_color {
unsigned char hue; /* Hue degree between 0 and 255 */
unsigned char sat; /* Saturation between 0 (gray) and 255 */
unsigned char val; /* Value between 0 (black) and 255 */
};
class VisionColorSensor {
private:
rgb_color getRgbColor();
hsv_color rgb_to_hsv(rgb_color rgb);
public:
hsv_color getHsvColor();
void initPin(int sensorPin);
boolean isPurple();
boolean isBlack();
boolean isClear();
private:
ADJDS311 colorSensor;
int sensorPin;
};
#endif