robert@464: /* robert@464: * DboxSensors.h robert@464: * robert@464: * Created on: May 19, 2014 robert@464: * Author: Victor Zappi robert@464: */ robert@464: robert@464: #ifndef DBOXSENSORS_H_ robert@464: #define DBOXSENSORS_H_ robert@464: robert@464: #include robert@464: #include // mount() robert@464: #include // strerror() robert@464: #include // fstream robert@464: #include robert@464: #include // usleep() robert@464: #include // glob() robert@464: #include // elapsed time robert@464: #include // mkdir() robert@464: #include // reverse() [string...] robert@464: robert@464: #include "I2c_TouchKey.h" robert@464: #include "AnalogInput.h" robert@464: #include // TODO wrap this into a class robert@464: robert@464: /*--------------------------------------------------------------------------------------------------------------------------------------------------- robert@464: * This class retrieves data from all the connected sensors, robert@464: * logs them robert@464: * and exposes to the main only the values needed to synthesize sound robert@464: * robert@464: * The simple instrument has: robert@464: * robert@464: * robert@464: * robert@464: *--------------------------------------------------------------------------------------------------------------------------------------------------- robert@464: */ robert@464: class DboxSensors robert@464: { robert@464: public: robert@464: 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); robert@464: int readSensors(); robert@464: int getTKTouchCount(int index); robert@464: float *getTKXPositions(int index); robert@464: float getTKYPosition(int index); robert@464: float *getTKTouchSize(int index); robert@464: double getFSRVAlue(); robert@464: int getDigitalIn(int index); robert@464: robert@464: DboxSensors(); robert@464: ~DboxSensors(); robert@464: robert@464: private: robert@464: int sensorType; robert@464: robert@464: I2c_TouchKey TK0; robert@464: int tk0_touchCnt; robert@464: float tk0_touchPosX[5]; robert@464: float tk0_touchPosY; robert@464: float tk0_touchSize[5]; robert@464: robert@464: I2c_TouchKey TK1; robert@464: int tk1_touchCnt; robert@464: float tk1_touchPosX[5]; robert@464: float tk1_touchPosY; robert@464: float tk1_touchSize[5]; robert@464: robert@464: AnalogInput FSR; robert@464: int fsr_pinNum; robert@464: double fsr_read; robert@464: int fsr_max; robert@464: robert@464: unsigned int digitalIn[2]; robert@464: int fdDi[2]; robert@464: int gpio[2]; robert@464: robert@464: void resetSensorsData(); robert@464: robert@464: }; robert@464: robert@464: robert@464: robert@464: //-------------------------------------------------------------------------------- robert@464: // read interface robert@464: inline int DboxSensors::getTKTouchCount(int index) robert@464: { robert@464: if(index==0) robert@464: return tk0_touchCnt; robert@464: else robert@464: return tk1_touchCnt; robert@464: } robert@464: robert@464: inline float *DboxSensors::getTKXPositions(int index) robert@464: { robert@464: if(index==0) robert@464: return tk0_touchPosX; robert@464: else robert@464: return tk1_touchPosX; robert@464: } robert@464: robert@464: inline float DboxSensors::getTKYPosition(int index) robert@464: { robert@464: if(index==0) robert@464: return tk0_touchPosY; robert@464: else robert@464: return tk1_touchPosY; robert@464: } robert@464: robert@464: inline float *DboxSensors::getTKTouchSize(int index) robert@464: { robert@464: if(index==0) robert@464: return tk0_touchSize; robert@464: else robert@464: return tk1_touchSize; robert@464: } robert@464: robert@464: inline double DboxSensors::getFSRVAlue() robert@464: { robert@464: return fsr_read; robert@464: } robert@464: robert@464: inline int DboxSensors::getDigitalIn(int index) robert@464: { robert@464: return digitalIn[index]; robert@464: } robert@464: //-------------------------------------------------------------------------------- robert@464: robert@464: robert@464: #endif /* DBOXSENSORS_H_ */