Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
DboxSensors.h
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 <GPIOcontrol.h> // TODO wrap this into a class
24 
25 /*---------------------------------------------------------------------------------------------------------------------------------------------------
26  * This class retrieves data from all the connected sensors,
27  * logs them
28  * and exposes to the main only the values needed to synthesize sound
29  *
30  * The simple instrument has:
31  *
32  *
33  *
34  *---------------------------------------------------------------------------------------------------------------------------------------------------
35  */
37 {
38 public:
39  int initSensors(int tk0_bus, int tk0_address, int tk1_bus, int tk1_address, int tk_file, int sensorTypeToUse, int gpio0=-1, int gpio1=-1);
40  int readSensors();
41  int getTKTouchCount(int index);
42  float *getTKXPositions(int index);
43  float getTKYPosition(int index);
44  float *getTKTouchSize(int index);
45  int getDigitalIn(int index);
46 
47  DboxSensors();
48  ~DboxSensors();
49 
50 private:
51  int sensorType;
52 
53  I2c_TouchKey TK0;
54  int tk0_touchCnt;
55  float tk0_touchPosX[5];
56  float tk0_touchPosY;
57  float tk0_touchSize[5];
58 
59  I2c_TouchKey TK1;
60  int tk1_touchCnt;
61  float tk1_touchPosX[5];
62  float tk1_touchPosY;
63  float tk1_touchSize[5];
64 
65  unsigned int digitalIn[2];
66  int fdDi[2];
67  int gpio[2];
68 
69  void resetSensorsData();
70 
71 };
72 
73 
74 
75 //--------------------------------------------------------------------------------
76 // read interface
77 inline int DboxSensors::getTKTouchCount(int index)
78 {
79  if(index==0)
80  return tk0_touchCnt;
81  else
82  return tk1_touchCnt;
83 }
84 
85 inline float *DboxSensors::getTKXPositions(int index)
86 {
87  if(index==0)
88  return tk0_touchPosX;
89  else
90  return tk1_touchPosX;
91 }
92 
93 inline float DboxSensors::getTKYPosition(int index)
94 {
95  if(index==0)
96  return tk0_touchPosY;
97  else
98  return tk1_touchPosY;
99 }
100 
101 inline float *DboxSensors::getTKTouchSize(int index)
102 {
103  if(index==0)
104  return tk0_touchSize;
105  else
106  return tk1_touchSize;
107 }
108 
109 inline int DboxSensors::getDigitalIn(int index)
110 {
111  return digitalIn[index];
112 }
113 //--------------------------------------------------------------------------------
114 
115 
116 #endif /* DBOXSENSORS_H_ */
Definition: I2c_TouchKey.h:26
Definition: DboxSensors.h:36