Mercurial > hg > beaglert
annotate projects/d-box/I2c_TouchKey.h @ 0:8a575ba3ab52
Initial commit.
author | andrewm |
---|---|
date | Fri, 31 Oct 2014 19:10:17 +0100 |
parents | |
children | 901d205d1a3c |
rev | line source |
---|---|
andrewm@0 | 1 /* |
andrewm@0 | 2 * I2c.h |
andrewm@0 | 3 * |
andrewm@0 | 4 * Created on: Oct 14, 2013 |
andrewm@0 | 5 * Author: Victor Zappi |
andrewm@0 | 6 */ |
andrewm@0 | 7 |
andrewm@0 | 8 #ifndef I2CTK_H_ |
andrewm@0 | 9 #define I2CTK_H_ |
andrewm@0 | 10 |
andrewm@0 | 11 #include "../../include/I2c.h" |
andrewm@0 | 12 |
andrewm@0 | 13 #define NUM_BYTES_OLD 9 |
andrewm@0 | 14 #define NUM_BYTES_NEW 13 |
andrewm@0 | 15 |
andrewm@0 | 16 class I2c_TouchKey : public I2c |
andrewm@0 | 17 { |
andrewm@0 | 18 private: |
andrewm@0 | 19 bool isReady; |
andrewm@0 | 20 bool newSensor; |
andrewm@0 | 21 int numBytesToRead; |
andrewm@0 | 22 |
andrewm@0 | 23 // read NUM_BYTES bytes, which have to be properly parsed |
andrewm@0 | 24 char dataBuffer[NUM_BYTES_NEW]; |
andrewm@0 | 25 int bytesRead; |
andrewm@0 | 26 |
andrewm@0 | 27 int rawSliderPosition[5]; |
andrewm@0 | 28 int rawSliderPositionH; |
andrewm@0 | 29 |
andrewm@0 | 30 int touchCount; |
andrewm@0 | 31 float sliderSize[5]; |
andrewm@0 | 32 float sliderPosition[5]; |
andrewm@0 | 33 float sliderPositionH; |
andrewm@0 | 34 |
andrewm@0 | 35 |
andrewm@0 | 36 public: |
andrewm@0 | 37 int initTouchKey(bool useNewSensor = false); |
andrewm@0 | 38 int readI2C(); |
andrewm@0 | 39 int getTouchCount(); |
andrewm@0 | 40 float * getSlidersize(); |
andrewm@0 | 41 float * getSliderPosition(); |
andrewm@0 | 42 float getSliderPositionH(); |
andrewm@0 | 43 |
andrewm@0 | 44 bool ready() { return isReady; } |
andrewm@0 | 45 |
andrewm@0 | 46 I2c_TouchKey(); |
andrewm@0 | 47 ~I2c_TouchKey(); |
andrewm@0 | 48 |
andrewm@0 | 49 }; |
andrewm@0 | 50 |
andrewm@0 | 51 inline int I2c_TouchKey::getTouchCount() |
andrewm@0 | 52 { |
andrewm@0 | 53 return touchCount; |
andrewm@0 | 54 } |
andrewm@0 | 55 |
andrewm@0 | 56 inline float * I2c_TouchKey::getSlidersize() |
andrewm@0 | 57 { |
andrewm@0 | 58 return sliderSize; |
andrewm@0 | 59 } |
andrewm@0 | 60 |
andrewm@0 | 61 inline float * I2c_TouchKey::getSliderPosition() |
andrewm@0 | 62 { |
andrewm@0 | 63 return sliderPosition; |
andrewm@0 | 64 } |
andrewm@0 | 65 |
andrewm@0 | 66 inline float I2c_TouchKey::getSliderPositionH() |
andrewm@0 | 67 { |
andrewm@0 | 68 return sliderPositionH; |
andrewm@0 | 69 } |
andrewm@0 | 70 |
andrewm@0 | 71 |
andrewm@0 | 72 |
andrewm@0 | 73 |
andrewm@0 | 74 |
andrewm@0 | 75 #endif /* I2CTK_H_ */ |