WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
HiTechnicColorSensor.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef __HiTechnicColorSensor_h__
8 #define __HiTechnicColorSensor_h__
9 
10 #include "SensorBase.h"
11 #include "LiveWindow/LiveWindowSendable.h"
12 
13 class I2C;
14 
27 {
28 public:
29  enum tColorMode {kActive = 0, kPassive = 1, kRaw = 3};
30  typedef struct{
31  uint16_t red;
32  uint16_t blue;
33  uint16_t green;
34  }RGB;
35  explicit HiTechnicColorSensor(uint8_t moduleNumber);
36  virtual ~HiTechnicColorSensor();
37  uint8_t GetColor();
38  uint8_t GetRed();
39  uint8_t GetGreen();
40  uint8_t GetBlue();
41  RGB GetRGB();
42  uint16_t GetRawRed();
43  uint16_t GetRawGreen();
44  uint16_t GetRawBlue();
45  RGB GetRawRGB();
46  void SetMode(tColorMode mode);
47 
48 
49  //LiveWindowSendable interface
50  virtual std::string GetType();
51  virtual void InitTable(ITable *subtable);
52  virtual void UpdateTable();
53  virtual ITable* GetTable();
54  virtual void StartLiveWindowMode();
55  virtual void StopLiveWindowMode();
56 
57 private:
58  static const uint8_t kAddress = 0x02;
59  static const uint8_t kManufacturerBaseRegister = 0x08;
60  static const uint8_t kManufacturerSize = 0x08;
61  static const uint8_t kSensorTypeBaseRegister = 0x10;
62  static const uint8_t kSensorTypeSize = 0x08;
63  static const uint8_t kModeRegister = 0x41;
64  static const uint8_t kColorRegister = 0x42;
65  static const uint8_t kRedRegister = 0x43;
66  static const uint8_t kGreenRegister = 0x44;
67  static const uint8_t kBlueRegister = 0x45;
68  static const uint8_t kRawRedRegister = 0x43;
69  static const uint8_t kRawGreenRegister = 0x45;
70  static const uint8_t kRawBlueRegister = 0x47;
71 
72  int m_mode;
73  I2C* m_i2c;
74  ITable *m_table;
75 };
76 
77 #endif
78 
virtual void StopLiveWindowMode()
Definition: HiTechnicColorSensor.cpp:385
uint8_t GetColor()
Definition: HiTechnicColorSensor.cpp:79
Definition: HiTechnicColorSensor.h:30
uint16_t GetRawGreen()
Definition: HiTechnicColorSensor.cpp:242
uint8_t GetBlue()
Definition: HiTechnicColorSensor.cpp:157
RGB GetRGB()
Definition: HiTechnicColorSensor.cpp:184
RGB GetRawRGB()
Definition: HiTechnicColorSensor.cpp:297
Definition: SensorBase.h:20
uint8_t GetGreen()
Definition: HiTechnicColorSensor.cpp:131
uint8_t GetRed()
Definition: HiTechnicColorSensor.cpp:105
virtual void InitTable(ITable *subtable)
Definition: HiTechnicColorSensor.cpp:346
virtual void UpdateTable()
Definition: HiTechnicColorSensor.cpp:354
Definition: HiTechnicColorSensor.h:26
virtual ITable * GetTable()
Definition: HiTechnicColorSensor.cpp:369
Definition: I2C.h:22
void SetMode(tColorMode mode)
Definition: HiTechnicColorSensor.cpp:327
uint16_t GetRawBlue()
Definition: HiTechnicColorSensor.cpp:268
virtual void StartLiveWindowMode()
Definition: HiTechnicColorSensor.cpp:377
uint16_t GetRawRed()
Definition: HiTechnicColorSensor.cpp:216
virtual ~HiTechnicColorSensor()
Definition: HiTechnicColorSensor.cpp:64
HiTechnicColorSensor(uint8_t moduleNumber)
Definition: HiTechnicColorSensor.cpp:33