32#include <frc/util/Color.h>
33#include <hal/SimDevice.h>
108 RawColor(uint32_t r, uint32_t g, uint32_t b, uint32_t _ir)
245 enum class Register {
247 kProximitySensorLED = 0x01,
248 kProximitySensorPulses = 0x02,
249 kProximitySensorRate = 0x03,
250 kLightSensorMeasurementRate = 0x04,
251 kLightSensorGain = 0x05,
254 kProximityData = 0x08,
255 kDataInfrared = 0x0A,
261 enum class MainCtrlFields {
262 kProximitySensorEnable = 0x01,
263 kLightSensorEnable = 0x02,
268 uint8_t PSDataStatus : 1;
269 uint8_t PSInterruptStatus : 1;
270 uint8_t PSLogicStatus : 1;
271 uint8_t LSDataStatus : 1;
272 uint8_t LSInterruptStatus : 1;
273 uint8_t PowerOnStatus : 1;
277 bool Write(Register reg, uint8_t data) {
278 return m_i2c.Write(
static_cast<uint8_t
>(reg), data);
281 bool Read(Register reg,
int count, uint8_t* data) {
282 return m_i2c.Read(
static_cast<uint8_t
>(reg), count, data);
285 uint32_t To20Bit(uint8_t* val) {
286 return (
static_cast<uint32_t
>(val[0]) |
287 (
static_cast<uint32_t
>(val[1]) << 8) |
288 (
static_cast<uint32_t
>(val[2]) << 16)) &
292 uint16_t To11Bit(uint8_t* val) {
293 return (
static_cast<uint16_t
>(val[0]) |
294 (
static_cast<uint16_t
>(val[1]) << 8)) &
298 uint32_t Read20BitRegister(Register reg);
299 uint16_t Read11BitRegister(Register reg);
301 bool CheckDeviceID(
bool reportErrors);
302 void InitializeDevice();
303 MainStatus GetStatus();
305 static const double Cmatrix[9];
309 hal::SimDevice m_simDevice;
310 hal::SimDouble m_simR, m_simG, m_simB, m_simIR, m_simProx;
Definition: CIEColor.h:35
Definition: ColorSensorV3.h:44
LEDPulseFrequency
Definition: ColorSensorV3.h:48
bool IsConnected()
Definition: ColorSensorV3.cpp:209
ProximityResolution
Definition: ColorSensorV3.h:67
double GetIR()
Definition: ColorSensorV3.cpp:128
LEDCurrent
Definition: ColorSensorV3.h:56
ColorMeasurementRate
Definition: ColorSensorV3.h:93
ColorResolution
Definition: ColorSensorV3.h:84
bool HasReset()
Definition: ColorSensorV3.cpp:202
frc::Color GetColor()
Definition: ColorSensorV3.cpp:90
ProximityMeasurementRate
Definition: ColorSensorV3.h:74
RawColor GetRawColor()
Definition: ColorSensorV3.cpp:102
void ConfigureProximitySensor(ProximityResolution res, ProximityMeasurementRate rate)
Definition: ColorSensorV3.cpp:190
GainFactor
Definition: ColorSensorV3.h:46
ColorSensorV3 & operator=(ColorSensorV3 &&)=default
void ConfigureProximitySensorLED(LEDPulseFrequency freq, LEDCurrent current, uint8_t pulses)
Definition: ColorSensorV3.cpp:181
void SetGain(GainFactor gain)
Definition: ColorSensorV3.cpp:135
ColorSensorV3(ColorSensorV3 &&)=default
uint32_t GetProximity()
Definition: ColorSensorV3.cpp:83
ColorSensorV3(frc::I2C::Port port)
Definition: ColorSensorV3.cpp:62
void ConfigureColorSensor(ColorResolution res, ColorMeasurementRate rate)
Definition: ColorSensorV3.cpp:196
CIEColor GetCIEColor()
Definition: ColorSensorV3.cpp:120
Definition: SparkLowLevel.cpp:40
Definition: ColorSensorV3.h:103
uint32_t blue
Definition: ColorSensorV3.h:106
uint32_t red
Definition: ColorSensorV3.h:104
uint32_t ir
Definition: ColorSensorV3.h:107
uint32_t green
Definition: ColorSensorV3.h:105
RawColor(uint32_t r, uint32_t g, uint32_t b, uint32_t _ir)
Definition: ColorSensorV3.h:108