fix light sensor, remove debug code from the akm sensors

This commit is contained in:
Kolja Dummann 2011-07-01 22:43:41 +02:00
parent beed9bdd8a
commit c2ea1d7fbe
2 changed files with 6 additions and 16 deletions

View File

@ -28,7 +28,7 @@
#include <cutils/log.h>
#include "AkmSensor.h"
#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0
/*****************************************************************************/

View File

@ -28,6 +28,8 @@
#include "LightSensor.h"
// #define LOG_NDEBUG 0
/*****************************************************************************/
LightSensor::LightSensor()
@ -61,7 +63,7 @@ int LightSensor::setInitialState() {
if (!ioctl(data_fd, EVIOCGABS(EVENT_TYPE_LIGHT), &absinfo)) {
// make sure to report an event immediately
mHasPendingEvent = true;
mPendingEvent.light = indexToValue(absinfo.value);
mPendingEvent.light = absinfo.value;
}
return 0;
}
@ -135,8 +137,9 @@ int LightSensor::readEvents(sensors_event_t* data, int count)
if (type == EV_ABS) {
if (event->code == EVENT_TYPE_LIGHT) {
if (event->value != -1) {
LOGV("LightSensor: event (value=%d)", event->value);
// FIXME: not sure why we're getting -1 sometimes
mPendingEvent.light = indexToValue(event->value);
mPendingEvent.light = event->value;
}
}
} else if (type == EV_SYN) {
@ -155,16 +158,3 @@ int LightSensor::readEvents(sensors_event_t* data, int count)
return numEventReceived;
}
float LightSensor::indexToValue(size_t index) const
{
static const float luxValues[10] = {
10.0, 160.0, 225.0, 320.0, 640.0,
1280.0, 2600.0, 5800.0, 8000.0, 10240.0
};
const size_t maxIndex = sizeof(luxValues)/sizeof(*luxValues) - 1;
if (index > maxIndex)
index = maxIndex;
return luxValues[index];
}