39 ** |
39 ** |
40 ****************************************************************************/ |
40 ****************************************************************************/ |
41 |
41 |
42 #include "maemo6als.h" |
42 #include "maemo6als.h" |
43 |
43 |
44 const char *maemo6als::id("maemo6.als"); |
44 char const * const maemo6als::id("maemo6.als"); |
45 bool maemo6als::m_initDone = false; |
45 bool maemo6als::m_initDone = false; |
46 |
46 |
47 maemo6als::maemo6als(QSensor *sensor) |
47 maemo6als::maemo6als(QSensor *sensor) |
48 : maemo6sensorbase(sensor) |
48 : maemo6sensorbase(sensor) |
49 { |
49 { |
|
50 const QString sensorName = "alssensor"; |
|
51 initSensor<ALSSensorChannelInterface>(sensorName, m_initDone); |
|
52 |
|
53 |
|
54 if (m_sensorInterface){ |
|
55 if (!(QObject::connect(m_sensorInterface, SIGNAL(ALSChanged(const Unsigned&)), |
|
56 this, SLOT(slotDataAvailable(const Unsigned&))))) |
|
57 qWarning() << "Unable to connect "<< sensorName; |
|
58 } |
|
59 else |
|
60 qWarning() << "Unable to initialize "<<sensorName; |
50 setReading<QAmbientLightReading>(&m_reading); |
61 setReading<QAmbientLightReading>(&m_reading); |
51 if (!m_initDone) { |
62 // metadata |
52 initSensor<ALSSensorChannelInterface>("alssensor"); |
63 addDataRate(1, 1); // 1 Hz |
53 |
64 addOutputRange(0, 5, 1); |
54 if (m_sensorInterface) |
65 setDescription(QLatin1String("Measures ambient light intensity given as 5 pre-defined levels")); |
55 QObject::connect(static_cast<const ALSSensorChannelInterface*>(m_sensorInterface), SIGNAL(ALSChanged(const Unsigned&)), this, SLOT(slotDataAvailable(const Unsigned&))); |
|
56 else |
|
57 qWarning() << "Unable to initialize ambient light sensor."; |
|
58 |
|
59 // metadata |
|
60 addDataRate(1, 1); // 1Hz |
|
61 sensor->setDataRate(1); |
|
62 addOutputRange(0, 5, 1); |
|
63 setDescription(QLatin1String("Measures ambient light intensity given as 5 pre-defined levels")); |
|
64 |
|
65 m_initDone = true; |
|
66 } |
|
67 } |
66 } |
68 |
67 |
69 void maemo6als::slotDataAvailable(const Unsigned& data) |
68 void maemo6als::slotDataAvailable(const Unsigned& data) |
70 { |
69 { |
71 // Convert from integer to fixed levels |
70 // Convert from integer to fixed levels |