void Sensor::initSensors() { sensGPIO.begin(1); //Address pins sensGPIO.pinMode(FRPIN, OUTPUT); sensGPIO.pinMode(LTRPIN, OUTPUT); sensGPIO.pinMode(LTLPIN, OUTPUT); sensGPIO.pinMode(FLPIN, OUTPUT); sensGPIO.pinMode(MRPIN, OUTPUT); sensGPIO.pinMode(MLPIN, OUTPUT); sensGPIO.pinMode(BRPIN, OUTPUT); sensGPIO.pinMode(BLPIN, OUTPUT); //-------Set all sensor select pins to high--------------- sensGPIO.writeGPIOA(0xFF); //Ultrasonic pins pinMode(A0, OUTPUT); pinMode(A1, INPUT); for (byte i = sC::FR; i < sC::invalid; i++) { SelectSensor(i); tsl.begin(TSL2561_ADDR_0); tsl.setTiming(TSL2561_GAIN_16X, TSL2561_INTEGRATIONTIME_14MS); tsl.setPowerUp(); } delay(14); _sensorInitComplete = true; }
//Polls all given sensors in the order specified. void Sensor::PollSensors(Sensor *sens, const sC::sensorNumber *order, const byte OrderLength){ if (_sensorInitComplete == false) { ERROR_PRINTLN("Please call initSensors() before attempting to poll"); return; } sC::sensorNumber currentSensorIndex = sC::FR; for (byte n = 0; n < OrderLength; n++) { currentSensorIndex = order[n]; SelectSensor(static_cast<byte>(currentSensorIndex)); SLASTVAL(currentSensorIndex, RVAL(currentSensorIndex)); sens[currentSensorIndex].GetReading(); SVAL(currentSensorIndex, sens[currentSensorIndex].tileWhite); } printbw(); }
// closes down all streams the restores to default configuration void KinectSensor::Close() { AutoLock lock(m_nuiLock); SelectSensor(false); }
// initialization HRESULT KinectSensor::Open() { AutoLock lock(m_nuiLock); return SelectSensor(true); }
// closes down all streams the restores to default configuration void KinectSensor::Close() { SelectSensor( false ); }
// initialization HRESULT KinectSensor::Open() { return SelectSensor( true ); }