From c2ea1d7fbe14691c6656899c874bf6c038393154 Mon Sep 17 00:00:00 2001 From: Kolja Dummann Date: Fri, 1 Jul 2011 22:43:41 +0200 Subject: [PATCH] fix light sensor, remove debug code from the akm sensors --- libsensors/AkmSensor.cpp | 2 +- libsensors/LightSensor.cpp | 20 +++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/libsensors/AkmSensor.cpp b/libsensors/AkmSensor.cpp index 05cd1ba..c147bd6 100644 --- a/libsensors/AkmSensor.cpp +++ b/libsensors/AkmSensor.cpp @@ -28,7 +28,7 @@ #include #include "AkmSensor.h" -#define LOG_NDEBUG 0 +//#define LOG_NDEBUG 0 /*****************************************************************************/ diff --git a/libsensors/LightSensor.cpp b/libsensors/LightSensor.cpp index 7586c18..1d4f0e4 100644 --- a/libsensors/LightSensor.cpp +++ b/libsensors/LightSensor.cpp @@ -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]; -}