QS60SensorApiAccelerometer::QS60SensorApiAccelerometer(QSensor *sensor) : QSensorBackend(sensor) , m_nativeSensor(NULL) , m_sampleFactor(0.0f) { TRAPD(err, findAndCreateNativeSensorL()); if(err != KErrNone) { sensorStopped(); sensorError(err); } setReading<QAccelerometerReading>(&m_reading); // http://www.st.com/stonline/products/literature/ds/12726/lis302dl.pdf // That 3D accelerometer inside N95 , N93i or N82 is from STMicroelectronics (type LIS302DL). // http://wiki.forum.nokia.com/index.php/Nokia_Sensor_APIs. // Sensor is set to 100Hz 2G mode and no public interface to switch it to 8G // 2G - mode addDataRate(100, 100); addOutputRange(-22.418, 22.418, 0.17651); setDescription(QLatin1String("lis302dl")); //Synbian interface gives values between -680 - 680 m_sampleFactor = this->sensor()->outputRanges()[0].maximum / 680.0f; }
void BbOrientationSensor::additionalDeviceInit() { // When querying the OS service for the range, it gives us the angles, which we don't need. // So set the possible enum values of QOrientationReading::Orientation as the output range here. // By returning false in addDefaultRange(), we skip setting the range from the OS service in the // base class. addOutputRange(0, 6, 1); }
meegoals::meegoals(QSensor *sensor) : meegosensorbase(sensor) { initSensor<ALSSensorChannelInterface>(m_initDone); setReading<QAmbientLightReading>(&m_reading); // metadata setDescription(QLatin1String("ambient light intensity given as 5 pre-defined levels")); addOutputRange(0, 5, 1); addDataRate(10,10); }
meegoirproximitysensor::meegoirproximitysensor(QSensor *sensor) : meegosensorbase(sensor) { initSensor<ProximitySensorChannelInterface>(m_initDone); setReading<QIRProximityReading>(&m_reading); setDescription(QLatin1String("reflectance as percentage (%) of maximum")); addOutputRange(0, 100, 1); addDataRate(10,10); rangeMax = QFile::exists(RM680_PS)?255:1023; }
SensorfwTapSensor::SensorfwTapSensor(QSensor *sensor) : SensorfwSensorBase(sensor), m_initDone(false), m_isOnceStarted(false) { init(); setReading<QTapReading>(&m_reading); addOutputRange(QTapReading::Undefined, QTapReading::Z_Both, 1); addDataRate(10,10); //TODO: fix this when we know better sensor->setDataRate(10);//set a default rate }
/** * Overriding this method in rotation sensor to hard code value of * mesurement range from -180 to 180 as Qt wants * Symbian provides measurement range from 0 to 359 */ void CRotationSensorSym::GetMeasurementrangeAndAccuracy() { TReal accuracy = 0; TSensrvProperty accuracyProperty; TRAPD(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdChannelAccuracy, ESensrvSingleProperty, accuracyProperty)); if(err == KErrNone) { accuracyProperty.GetValue(accuracy); } // Hard coding values -180 and 180 as Qt expects y and z axis // values range from -180 to 180. addOutputRange(KMinimumRange, KMaximumRange, accuracy); }
void SensorfwSensorBase::setRanges(qreal correctionFactor) { if (!m_sensorInterface) return; QList<DataRange> ranges = m_sensorInterface->getAvailableDataRanges(); for (int i = 0, l = ranges.size(); i < l; i++) { DataRange range = ranges.at(i); qreal rangeMin = range.min * correctionFactor; qreal rangeMax = range.max * correctionFactor; qreal resolution = range.resolution * correctionFactor; addOutputRange(rangeMin, rangeMax, resolution); } }
testsensorimpl::testsensorimpl(QSensor *sensor) : QSensorBackend(sensor) { setReading<TestSensorReading>(&m_reading); setDescription("sensor description"); addOutputRange(0, 1, 0.5); addOutputRange(0, 2, 1); QString doThis = sensor->property("doThis").toString(); if (doThis == "rates(0)") { setDataRates(0); } else if (doThis == "rates(nodef)") { TestSensor *acc = new TestSensor(this); setDataRates(acc); delete acc; } else if (doThis == "rates") { TestSensor *acc = new TestSensor(this); acc->connectToBackend(); setDataRates(acc); delete acc; } else { addDataRate(100, 100); } reading(); }
n900accelerometer::n900accelerometer(QSensor *sensor) : n900filebasedsensor(sensor) { setReading<QAccelerometerReading>(&m_reading); // According to the kernel driver, this runs at 100 or 400Hz // but we can't change the rate because we don't run as root. // The hardware seems to run at 100Hz by default so report that. // Report 1-100Hz so the app can poll less frequently if it wants to. addDataRate(1, 100); // According to the kernel driver this reports +- 2G or +- 8G (with lower accuracy) // but we can't change the range because we don't run as root. // The hardware seems to run at +- 2G by default so report that. addOutputRange(-22.418, 22.418, 0.17651); // 2G setDescription(QLatin1String("lis302dl")); }
void CSensorBackendSym::GetMeasurementrangeAndAccuracy() { /* In QT Mobility measurement range and accuracy are coupled together to form the output range where as, in Symbian accuracy and measurement range are independent properties. To solve the QT requirement, the mapping used is as follows 1. If symbian provides only one accuracy, use this with all the measurement ranges 2. If there are n accuracies and n measurement ranges, map linearly (n:n) 3. If there are n accuracies and n+x measurement ranges, then the mapping will be n:n for each n measurement ranges and accuracies KAccuracyInvalid : for each n+x measurement ranges */ TReal accuracy = 0; RSensrvPropertyList accuracyList; TInt err; TRAP(err, iBackendData.iSensorChannel->GetAllPropertiesL(KSensrvPropIdChannelAccuracy, accuracyList)); if(err == KErrNone) { // If only one accuracy value present set value to accuracy if(accuracyList.Count() == 1) { if(accuracyList[0].PropertyType() == ESensrvIntProperty) { TInt intAccuracy; accuracyList[0].GetValue(intAccuracy); accuracy = intAccuracy; } else if(accuracyList[0].PropertyType() == ESensrvRealProperty) { accuracyList[0].GetValue(accuracy); } } // If more than one accuracy values present set accuracy to invalid else { accuracy = KAccuracyInvalid; } } //Scale TSensrvProperty scale_prop; TReal scale=1; TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdChannelScale, KSensrvItemIndexNone, scale_prop)); if(err == KErrNone) { if(scale_prop.PropertyType() == ESensrvIntProperty) { TInt intScale; scale_prop.GetValue(intScale); scale = intScale; } else if(scale_prop.PropertyType() == ESensrvRealProperty) { scale_prop.GetValue(scale); } TReal scaleMultiplier; Math::Pow(scaleMultiplier, 10, scale); scale = scaleMultiplier; } //measurement minimum & maximum TSensrvProperty measurerange_prop; TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, measurerange_prop)); if(err == KErrNone) { if(measurerange_prop.GetArrayIndex() == ESensrvSingleProperty) { TReal measureMin, measureMax, value; if(measurerange_prop.PropertyType() == ESensrvIntProperty) { TInt intMin, intMax; measurerange_prop.GetMinValue(intMin); measurerange_prop.GetMaxValue(intMax); measureMin = intMin; measureMax = intMax; } else if(measurerange_prop.PropertyType() == ESensrvRealProperty) { measurerange_prop.GetMinValue(measureMin); measurerange_prop.GetMaxValue(measureMax); } //Set output as range addOutputRange(measureMin*scale, measureMax*scale, accuracy); } //if list has more than one item, data rate will be having descrete values, agreed with DS team else if(measurerange_prop.GetArrayIndex() == ESensrvArrayPropertyInfo) { TReal measureMin, measureMax; TInt min, max, index; if(measurerange_prop.PropertyType() == ESensrvIntProperty) { measurerange_prop.GetMinValue(min); measurerange_prop.GetMaxValue(max); measurerange_prop.GetValue(index); } else if(measurerange_prop.PropertyType() == ESensrvRealProperty) { TReal realMin, realMax, realValue; measurerange_prop.GetMinValue(realMin); measurerange_prop.GetMaxValue(realMax); measurerange_prop.GetValue(realValue); min = realMin; max = realMax; index = realValue; } for(int i=min; i<=max; i++) { TRAP(err, iBackendData.iSensorChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, i, measurerange_prop)); if(err == KErrNone) { if(measurerange_prop.PropertyType() == ESensrvIntProperty) { TInt intMeasureMin, intMeasureMax; measurerange_prop.GetMinValue(intMeasureMin); measurerange_prop.GetMaxValue(intMeasureMax); measureMin = intMeasureMin; measureMax = intMeasureMax; } else if(measurerange_prop.PropertyType() == ESensrvRealProperty) { measurerange_prop.GetMinValue(measureMin); measurerange_prop.GetMaxValue(measureMax); } // If only one accuracy value is present set same accuracy for all if(accuracy != KAccuracyInvalid) { addOutputRange(measureMin*scale, measureMax*scale, accuracy); } // If more than one accuracy values are there then map them linearly else { if(accuracyList.Count() > (i - min)) { accuracyList[i].GetValue(accuracy); addOutputRange(measureMin*scale, measureMax*scale, accuracy); } else { // If less accuracy values are present than measurement ranges then // set invalid accuracy for rest of measument ranges addOutputRange(measureMin*scale, measureMax*scale, KAccuracyInvalid); } } } } } } }