annotate examples/d-box/DboxSensors.h @ 438:ad3f61134bb4 prerelease

More compatibility
author Giulio Moro <giuliomoro@yahoo.it>
date Sat, 18 Jun 2016 02:25:48 +0100
parents dbeed520b014
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 * DboxSensors.h
andrewm@0 3 *
andrewm@0 4 * Created on: May 19, 2014
andrewm@0 5 * Author: Victor Zappi
andrewm@0 6 */
andrewm@0 7
andrewm@0 8 #ifndef DBOXSENSORS_H_
andrewm@0 9 #define DBOXSENSORS_H_
andrewm@0 10
andrewm@0 11 #include <stdio.h>
andrewm@0 12 #include <sys/mount.h> // mount()
andrewm@0 13 #include <string.h> // strerror()
andrewm@0 14 #include <fstream> // fstream
andrewm@0 15 #include <iostream>
andrewm@0 16 #include <unistd.h> // usleep()
andrewm@0 17 #include <glob.h> // glob()
andrewm@0 18 #include <sys/time.h> // elapsed time
andrewm@0 19 #include <sys/stat.h> // mkdir()
andrewm@0 20 #include <algorithm> // reverse() [string...]
andrewm@0 21
andrewm@0 22 #include "I2c_TouchKey.h"
andrewm@0 23 #include "AnalogInput.h"
andrewm@68 24 #include <GPIOcontrol.h> // TODO wrap this into a class
andrewm@0 25
andrewm@0 26 /*---------------------------------------------------------------------------------------------------------------------------------------------------
andrewm@0 27 * This class retrieves data from all the connected sensors,
andrewm@0 28 * logs them
andrewm@0 29 * and exposes to the main only the values needed to synthesize sound
andrewm@0 30 *
andrewm@0 31 * The simple instrument has:
andrewm@0 32 *
andrewm@0 33 *
andrewm@0 34 *
andrewm@0 35 *---------------------------------------------------------------------------------------------------------------------------------------------------
andrewm@0 36 */
andrewm@0 37 class DboxSensors
andrewm@0 38 {
andrewm@0 39 public:
andrewm@15 40 int initSensors(int tk0_bus, int tk0_address, int tk1_bus, int tk1_address, int tk_file, int fsr_pin, int fsrmax, int sensorTypeToUse, int gpio0=-1, int gpio1=-1);
andrewm@0 41 int readSensors();
andrewm@0 42 int getTKTouchCount(int index);
andrewm@0 43 float *getTKXPositions(int index);
andrewm@0 44 float getTKYPosition(int index);
andrewm@0 45 float *getTKTouchSize(int index);
andrewm@0 46 double getFSRVAlue();
andrewm@0 47 int getDigitalIn(int index);
andrewm@0 48
andrewm@0 49 DboxSensors();
andrewm@0 50 ~DboxSensors();
andrewm@0 51
andrewm@0 52 private:
andrewm@15 53 int sensorType;
andrewm@0 54
andrewm@0 55 I2c_TouchKey TK0;
andrewm@0 56 int tk0_touchCnt;
andrewm@0 57 float tk0_touchPosX[5];
andrewm@0 58 float tk0_touchPosY;
andrewm@0 59 float tk0_touchSize[5];
andrewm@0 60
andrewm@0 61 I2c_TouchKey TK1;
andrewm@0 62 int tk1_touchCnt;
andrewm@0 63 float tk1_touchPosX[5];
andrewm@0 64 float tk1_touchPosY;
andrewm@0 65 float tk1_touchSize[5];
andrewm@0 66
andrewm@0 67 AnalogInput FSR;
andrewm@0 68 int fsr_pinNum;
andrewm@0 69 double fsr_read;
andrewm@0 70 int fsr_max;
andrewm@0 71
andrewm@0 72 unsigned int digitalIn[2];
andrewm@0 73 int fdDi[2];
andrewm@0 74 int gpio[2];
andrewm@0 75
andrewm@0 76 void resetSensorsData();
andrewm@0 77
andrewm@0 78 };
andrewm@0 79
andrewm@0 80
andrewm@0 81
andrewm@0 82 //--------------------------------------------------------------------------------
andrewm@0 83 // read interface
andrewm@0 84 inline int DboxSensors::getTKTouchCount(int index)
andrewm@0 85 {
andrewm@0 86 if(index==0)
andrewm@0 87 return tk0_touchCnt;
andrewm@0 88 else
andrewm@0 89 return tk1_touchCnt;
andrewm@0 90 }
andrewm@0 91
andrewm@0 92 inline float *DboxSensors::getTKXPositions(int index)
andrewm@0 93 {
andrewm@0 94 if(index==0)
andrewm@0 95 return tk0_touchPosX;
andrewm@0 96 else
andrewm@0 97 return tk1_touchPosX;
andrewm@0 98 }
andrewm@0 99
andrewm@0 100 inline float DboxSensors::getTKYPosition(int index)
andrewm@0 101 {
andrewm@0 102 if(index==0)
andrewm@0 103 return tk0_touchPosY;
andrewm@0 104 else
andrewm@0 105 return tk1_touchPosY;
andrewm@0 106 }
andrewm@0 107
andrewm@0 108 inline float *DboxSensors::getTKTouchSize(int index)
andrewm@0 109 {
andrewm@0 110 if(index==0)
andrewm@0 111 return tk0_touchSize;
andrewm@0 112 else
andrewm@0 113 return tk1_touchSize;
andrewm@0 114 }
andrewm@0 115
andrewm@0 116 inline double DboxSensors::getFSRVAlue()
andrewm@0 117 {
andrewm@0 118 return fsr_read;
andrewm@0 119 }
andrewm@0 120
andrewm@0 121 inline int DboxSensors::getDigitalIn(int index)
andrewm@0 122 {
andrewm@0 123 return digitalIn[index];
andrewm@0 124 }
andrewm@0 125 //--------------------------------------------------------------------------------
andrewm@0 126
andrewm@0 127
andrewm@0 128 #endif /* DBOXSENSORS_H_ */