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