I2c_TouchKey.h
1 /*
2  * I2c.h
3  *
4  * Created on: Oct 14, 2013
5  * Author: Victor Zappi
6  */
7 
8 #ifndef I2CTK_H_
9 #define I2CTK_H_
10 
11 #include <I2c.h>
12 
13 // #define NUM_BYTES_OLD 9
14 // #define NUM_BYTES_NEW 13
15 
16 #define MAX_SENSOR_BYTES 20
17 
18 enum {
19  kSensorTypeTouchKey = 0,
20  kSensorTypeDBox1 = 1,
21  kSensorTypeDBox2 = 2
22 };
23 
24 static const int kSensorBytes[3] = {9, 13, 20};
25 
26 class I2c_TouchKey : public I2c
27 {
28 private:
29  bool isReady;
30  int sensorType;
31  int numBytesToRead;
32 
33  // read NUM_BYTES bytes, which have to be properly parsed
34  char dataBuffer[MAX_SENSOR_BYTES];
35  int bytesRead;
36 
37  int rawSliderPosition[5];
38  int rawSliderPositionH;
39 
40  int touchCount;
41  float sliderSize[5];
42  float sliderPosition[5];
43  float sliderPositionH;
44 
45 
46 public:
47  int initTouchKey(int sensorTypeToUse = kSensorTypeTouchKey);
48  int readI2C();
49  int getTouchCount();
50  float * getSlidersize();
51  float * getSliderPosition();
52  float getSliderPositionH();
53 
54  bool ready() { return isReady; }
55 
56  I2c_TouchKey();
57  ~I2c_TouchKey();
58 
59 };
60 
61 inline int I2c_TouchKey::getTouchCount()
62 {
63  return touchCount;
64 }
65 
66 inline float * I2c_TouchKey::getSlidersize()
67 {
68  return sliderSize;
69 }
70 
71 inline float * I2c_TouchKey::getSliderPosition()
72 {
73  return sliderPosition;
74 }
75 
76 inline float I2c_TouchKey::getSliderPositionH()
77 {
78  return sliderPositionH;
79 }
80 
81 
82 
83 
84 
85 #endif /* I2CTK_H_ */
Definition: I2c.h:28
Definition: I2c_TouchKey.h:26