comparison projects/d-box/I2c_TouchKey.h @ 15:901d205d1a3c

Updated to latest PRU library; external PRU file no longer needed. Also catch SIGTERM as well as SIGINT to clean up gracefully.
author andrewm
date Sat, 07 Feb 2015 16:41:56 +0000
parents 8a575ba3ab52
children 59edd5780fef
comparison
equal deleted inserted replaced
14:06f93bef7dd2 15:901d205d1a3c
8 #ifndef I2CTK_H_ 8 #ifndef I2CTK_H_
9 #define I2CTK_H_ 9 #define I2CTK_H_
10 10
11 #include "../../include/I2c.h" 11 #include "../../include/I2c.h"
12 12
13 #define NUM_BYTES_OLD 9 13 // #define NUM_BYTES_OLD 9
14 #define NUM_BYTES_NEW 13 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};
15 25
16 class I2c_TouchKey : public I2c 26 class I2c_TouchKey : public I2c
17 { 27 {
18 private: 28 private:
19 bool isReady; 29 bool isReady;
20 bool newSensor; 30 int sensorType;
21 int numBytesToRead; 31 int numBytesToRead;
22 32
23 // read NUM_BYTES bytes, which have to be properly parsed 33 // read NUM_BYTES bytes, which have to be properly parsed
24 char dataBuffer[NUM_BYTES_NEW]; 34 char dataBuffer[MAX_SENSOR_BYTES];
25 int bytesRead; 35 int bytesRead;
26 36
27 int rawSliderPosition[5]; 37 int rawSliderPosition[5];
28 int rawSliderPositionH; 38 int rawSliderPositionH;
29 39
32 float sliderPosition[5]; 42 float sliderPosition[5];
33 float sliderPositionH; 43 float sliderPositionH;
34 44
35 45
36 public: 46 public:
37 int initTouchKey(bool useNewSensor = false); 47 int initTouchKey(int sensorTypeToUse = kSensorTypeTouchKey);
38 int readI2C(); 48 int readI2C();
39 int getTouchCount(); 49 int getTouchCount();
40 float * getSlidersize(); 50 float * getSlidersize();
41 float * getSliderPosition(); 51 float * getSliderPosition();
42 float getSliderPositionH(); 52 float getSliderPositionH();