39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include "maemo6rotationsensor.h" |
42 #include "maemo6rotationsensor.h" |
43 |
43 |
44 const char *maemo6rotationsensor::id("maemo6.rotationsensor"); |
44 char const * const maemo6rotationsensor::id("maemo6.rotationsensor"); |
45 bool maemo6rotationsensor::m_initDone = false; |
45 bool maemo6rotationsensor::m_initDone = false; |
46 |
46 |
47 maemo6rotationsensor::maemo6rotationsensor(QSensor *sensor) |
47 maemo6rotationsensor::maemo6rotationsensor(QSensor *sensor) |
48 : maemo6sensorbase(sensor) |
48 : maemo6sensorbase(sensor) |
49 { |
49 { |
|
50 const QString sensorName = "rotationsensor"; |
|
51 initSensor<RotationSensorChannelInterface>(sensorName, m_initDone); |
|
52 |
|
53 if (m_sensorInterface){ |
|
54 if (!(QObject::connect(m_sensorInterface, SIGNAL(dataAvailable(const XYZ&)), |
|
55 this, SLOT(slotDataAvailable(const XYZ&))))) |
|
56 qWarning() << "Unable to connect "<< sensorName; |
|
57 } |
|
58 else |
|
59 qWarning() << "Unable to initialize "<<sensorName; |
50 setReading<QRotationReading>(&m_reading); |
60 setReading<QRotationReading>(&m_reading); |
51 |
61 // metadata |
52 if (!m_initDone) { |
62 addDataRate(1, 130); // 43 Hz |
53 qDBusRegisterMetaType<XYZ>(); |
63 addOutputRange(-179, 180, 1); |
54 |
64 setDescription(QLatin1String("Measures x, y, and z axes rotation in degrees")); |
55 initSensor<RotationSensorChannelInterface>("rotationsensor"); |
|
56 |
|
57 if (m_sensorInterface) |
|
58 QObject::connect(static_cast<RotationSensorChannelInterface*>(m_sensorInterface), SIGNAL(dataAvailable(const XYZ&)), this, SLOT(slotDataAvailable(const XYZ&))); |
|
59 else |
|
60 qWarning() << "Unable to initialize rotation sensor."; |
|
61 |
|
62 // metadata |
|
63 addDataRate(23, 23); // 23Hz |
|
64 sensor->setDataRate(23); |
|
65 addOutputRange(-179, 180, 1); |
|
66 setDescription(QLatin1String("Measures x, y, and z axes rotation in degrees")); |
|
67 |
|
68 m_initDone = true; |
|
69 } |
|
70 sensor->setProperty("hasZ", true); |
65 sensor->setProperty("hasZ", true); |
71 } |
66 } |
72 |
67 |
73 void maemo6rotationsensor::slotDataAvailable(const XYZ& data) |
68 void maemo6rotationsensor::slotDataAvailable(const XYZ& data) |
74 { |
69 { |