Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
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  bool setup(int sensorType);
57  void cleanup();
58 
59  I2c_TouchKey();
60  I2c_TouchKey(int sensorType);
61  ~I2c_TouchKey();
62 
63 };
64 
65 inline int I2c_TouchKey::getTouchCount()
66 {
67  return touchCount;
68 }
69 
70 inline float * I2c_TouchKey::getSlidersize()
71 {
72  return sliderSize;
73 }
74 
75 inline float * I2c_TouchKey::getSliderPosition()
76 {
77  return sliderPosition;
78 }
79 
80 inline float I2c_TouchKey::getSliderPositionH()
81 {
82  return sliderPositionH;
83 }
84 
85 
86 
87 
88 
89 #endif /* I2CTK_H_ */
Definition: I2c.h:23
Definition: I2c_TouchKey.h:26