Home | History | Annotate | Download | only in libsensors
      1 /*
      2  * Copyright (C) 2011 Samsung
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include <fcntl.h>
     18 #include <errno.h>
     19 #include <math.h>
     20 #include <poll.h>
     21 #include <unistd.h>
     22 #include <dirent.h>
     23 #include <sys/select.h>
     24 #include <cutils/log.h>
     25 #include <pthread.h>
     26 
     27 #include "PressureSensor.h"
     28 
     29 /*
     30  * The BMP driver gives pascal values.
     31  * It needs to be changed into hectoPascal
     32  */
     33 #define PRESSURE_HECTO (1.0f/100.0f)
     34 
     35 PressureSensor::PressureSensor()
     36     : SamsungSensorBase(NULL, "barometer", ABS_PRESSURE)
     37 {
     38     mPendingEvent.sensor = ID_PR;
     39     mPendingEvent.type = SENSOR_TYPE_PRESSURE;
     40 }
     41 
     42 bool PressureSensor::handleEvent(input_event const *event) {
     43     mPendingEvent.pressure = event->value * PRESSURE_HECTO;
     44     return true;
     45 }
     46