annotate projects/d-box/I2c_TouchKey.h @ 151:e9c9404e3d1f ClockSync

Pff partially working. No PID. When setting the audio clock on the bbb to 44098 the master and slave clock keep diverging instead of converging ...
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 22 Sep 2015 04:10:07 +0100
parents 59edd5780fef
children
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@68 11 #include <I2c.h>
andrewm@0 12
andrewm@15 13 // #define NUM_BYTES_OLD 9
andrewm@15 14 // #define NUM_BYTES_NEW 13
andrewm@15 15
andrewm@15 16 #define MAX_SENSOR_BYTES 20
andrewm@15 17
andrewm@15 18 enum {
andrewm@15 19 kSensorTypeTouchKey = 0,
andrewm@15 20 kSensorTypeDBox1 = 1,
andrewm@15 21 kSensorTypeDBox2 = 2
andrewm@15 22 };
andrewm@15 23
andrewm@15 24 static const int kSensorBytes[3] = {9, 13, 20};
andrewm@0 25
andrewm@0 26 class I2c_TouchKey : public I2c
andrewm@0 27 {
andrewm@0 28 private:
andrewm@0 29 bool isReady;
andrewm@15 30 int sensorType;
andrewm@0 31 int numBytesToRead;
andrewm@0 32
andrewm@0 33 // read NUM_BYTES bytes, which have to be properly parsed
andrewm@15 34 char dataBuffer[MAX_SENSOR_BYTES];
andrewm@0 35 int bytesRead;
andrewm@0 36
andrewm@0 37 int rawSliderPosition[5];
andrewm@0 38 int rawSliderPositionH;
andrewm@0 39
andrewm@0 40 int touchCount;
andrewm@0 41 float sliderSize[5];
andrewm@0 42 float sliderPosition[5];
andrewm@0 43 float sliderPositionH;
andrewm@0 44
andrewm@0 45
andrewm@0 46 public:
andrewm@15 47 int initTouchKey(int sensorTypeToUse = kSensorTypeTouchKey);
andrewm@0 48 int readI2C();
andrewm@0 49 int getTouchCount();
andrewm@0 50 float * getSlidersize();
andrewm@0 51 float * getSliderPosition();
andrewm@0 52 float getSliderPositionH();
andrewm@0 53
andrewm@0 54 bool ready() { return isReady; }
andrewm@0 55
andrewm@0 56 I2c_TouchKey();
andrewm@0 57 ~I2c_TouchKey();
andrewm@0 58
andrewm@0 59 };
andrewm@0 60
andrewm@0 61 inline int I2c_TouchKey::getTouchCount()
andrewm@0 62 {
andrewm@0 63 return touchCount;
andrewm@0 64 }
andrewm@0 65
andrewm@0 66 inline float * I2c_TouchKey::getSlidersize()
andrewm@0 67 {
andrewm@0 68 return sliderSize;
andrewm@0 69 }
andrewm@0 70
andrewm@0 71 inline float * I2c_TouchKey::getSliderPosition()
andrewm@0 72 {
andrewm@0 73 return sliderPosition;
andrewm@0 74 }
andrewm@0 75
andrewm@0 76 inline float I2c_TouchKey::getSliderPositionH()
andrewm@0 77 {
andrewm@0 78 return sliderPositionH;
andrewm@0 79 }
andrewm@0 80
andrewm@0 81
andrewm@0 82
andrewm@0 83
andrewm@0 84
andrewm@0 85 #endif /* I2CTK_H_ */