qtmobility/examples/sensors/accel/main.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
--- a/qtmobility/examples/sensors/accel/main.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/examples/sensors/accel/main.cpp	Mon May 03 13:18:40 2010 +0300
@@ -51,25 +51,12 @@
 public:
     bool filter(QAccelerometerReading *reading)
     {
-#if 0
-        QAccelerometerReading *lastReading = accelerometer->reading();
-        qDebug() << "acceleration: "
-                 << QString().sprintf("%0.2f (%0.2f) %0.2f (%0.2f) %0.2f (%0.2f)",
-                         reading->x(),
-                         lastReading->x() - reading->x(),
-                         reading->y(),
-                         lastReading->y() - reading->y(),
-                         reading->z(),
-                         lastReading->z() - reading->z());
-        return true; // so the last reading is available!
-#else
         qDebug() << "acceleration: "
                  << QString().sprintf("%0.2f %0.2f %0.2f",
                          reading->x(),
                          reading->y(),
                          reading->z());
         return false; // don't store the reading in the sensor
-#endif
     }
 };
 
@@ -79,16 +66,14 @@
 
     QAccelerometer sensor;
     accelerometer = &sensor;
-    if (!sensor.connect()) {
-        qWarning("No Accelerometer available!");
+    AccelerometerFilter filter;
+    sensor.addFilter(&filter);
+    sensor.start();
+
+    if (!sensor.isActive()) {
+        qWarning("Accelerometer didn't start!");
         return 1;
     }
-    AccelerometerFilter filter;
-    sensor.setSignalEnabled(false);
-    sensor.addFilter(&filter);
-    //sensor.setUpdatePolicy(QSensor::InfrequentUpdates);
-    sensor.setUpdateInterval(100); // as fast as the sensor can go!
-    sensor.start();
 
     return app.exec();
 }