libPlayingWithFusion 2022.01.12
Playing With Fusion driver library for FRC roboRIO
TMD37003.h
Go to the documentation of this file.
1#pragma once
2#include <algorithm>
3#include <chrono>
4#include <cstdint>
5#include <frc/I2C.h>
6#include <frc/util/Color.h>
7
8
9namespace frc {
10
11class TMD37003 {
12 public:
18 TMD37003(I2C::Port i2cPort);
19
20
29 void ConfigureColorSense(double alsIntegrationTime, int alsGain);
30
31
45 void ConfigureProximitySense(double proximitySampleTime, double proximityPulseLength, int numProximityPulses,
46 int proximityGain, int proximityLedCurrent);
47
48
67 void SetGain(double r, double g, double b, double c, double gamma);
68
69
75 Color GetColor();
76
77
83 double GetHue();
84
85
91 double GetSaturation();
92
93
98 double GetRed();
99
100
105 double GetGreen();
106
107
112 double GetBlue();
113
118 double GetAmbientLightLevel();
119
120
125 double GetProximity();
126
127
128 private:
129 const uint8_t m_deviceAddress = 0x39;
130 I2C m_port;
131 std::chrono::steady_clock::time_point lastRx;
132
133 bool m_alsSaturated;
134 bool m_proximitySaturated;
135 double m_r;
136 double m_g;
137 double m_b;
138 double m_c;
139 double m_proximity;
140
141 double m_alsIntegrationTime = 80;
142 double m_alsWaitTime = 0;
143 int m_alsGain = 4;
144 double m_proximitySampleTime = 20;
145 double m_proximityPulseLength = 0.008;
146 int m_numProximityPulses = 2;
147 int m_proximityGain = 2;
148 int m_proximityLedCurrent = 90;
149
150 double m_gamma = 1.0 / 2.2;
151 double m_rGain = 1.0 / 0.197;
152 double m_gGain = 1.0 / 0.126;
153 double m_bGain = 1.0 / 0.071;
154 double m_cGain = 1.0 / 0.340;
155
156 enum Reg {
157 ENABLE = 0x80,
158 ATIME = 0x81,
159 PRATE = 0x82,
160 WTIME = 0x83,
161 AILTL = 0x84,
162 AILTH = 0x85,
163 AIHTL = 0x86,
164 AIHTH = 0x87,
165 PILT = 0x88,
166 PIHT = 0x8A,
167 PERS = 0x8C,
168 CFG0 = 0x8D,
169 PCFG0 = 0x8E,
170 PCFG1 = 0x8F,
171 CFG1 = 0x90,
172 REVID = 0x91,
173 ID = 0x92,
174 STATUS = 0x93,
175 CDATAL = 0x94,
176 CDATAH = 0x95,
177 RDATAL = 0x96,
178 RDATAH = 0x97,
179 GDATAL = 0x98,
180 GDATAH = 0x99,
181 BDATAL = 0x9A,
182 BDATAH = 0x9B,
183 PDATA = 0x9C,
184 CFG2 = 0x9F,
185 CFG3 = 0xAB,
186 POFFSET_L = 0xC0,
187 POFFSET_H = 0xC1,
188 CALIB = 0xD7,
189 CALIBCFG = 0xD9,
190 CALIBSTAT = 0xDC,
191 INTENAB = 0xDD
192 };
193
194 void PushConfiguration();
195
196 void Read();
197};
198
199}
Definition: TMD37003.h:11
void ConfigureProximitySense(double proximitySampleTime, double proximityPulseLength, int numProximityPulses, int proximityGain, int proximityLedCurrent)
Definition: TMD37003.cpp:64
double GetBlue()
Definition: TMD37003.cpp:194
double GetGreen()
Definition: TMD37003.cpp:184
double GetHue()
Definition: TMD37003.cpp:120
double GetProximity()
Definition: TMD37003.cpp:213
void ConfigureColorSense(double alsIntegrationTime, int alsGain)
Definition: TMD37003.cpp:41
Color GetColor()
Definition: TMD37003.cpp:110
void SetGain(double r, double g, double b, double c, double gamma)
Definition: TMD37003.cpp:94
TMD37003(I2C::Port i2cPort)
Definition: TMD37003.cpp:12
double GetAmbientLightLevel()
Definition: TMD37003.cpp:203
double GetSaturation()
Definition: TMD37003.cpp:155
double GetRed()
Definition: TMD37003.cpp:174
Definition: CANVenom.h:10