Tizen 2.0 Release
[adaptation/intel_mfld/sensor-plugins-mfld-blackbay.git] / src / compassprocessor.cpp
1 /* Medfield sensor plugins
2  * Copyright (C) 2013 Intel Corporation
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; version 2.1.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18
19 #include "compassprocessor.h"
20 #include "sensor_geomag.h"
21 #include "log.h"
22
23 CompassProcessor::CompassProcessor()
24 {
25      DbgPrint("");
26      mName = "magnetometer";
27      mInputEventCount = 4;
28      find_input_device_by_name("hmc5883");
29      BaseProcessor::find_device_from_udev("compass");
30      mSysfsPath += "/hmc5883";
31      mSupportedEvents.push_back(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
32 }
33
34 bool CompassProcessor::fill_values(unsigned int type, int &count,
35                                    data_unit_idx_t &unit, data_accuracy &accuracy)
36 {
37      if (type == GEOMAGNETIC_RAW_DATA_SET) {
38           count = 3;
39           unit = IDX_UNIT_MICRO_TESLA;
40           accuracy = ACCURACY_GOOD;
41           return true;
42      }
43
44      return false;
45 }
46
47 int CompassProcessor::get_property(unsigned int property_level,
48                                    base_property_struct &result)
49 {
50      strcpy(result.sensor_name, "hmc5883");
51      strcpy(result.sensor_vendor,"Honeywell");
52      if (property_level == GEOMAGNETIC_RAW_DATA_SET) {
53           result.sensor_unit_idx = IDX_UNIT_MICRO_TESLA;
54           result.sensor_min_range = 0;
55           result.sensor_max_range = 1000;
56           result.sensor_resolution = 1;
57      } else {
58           return -1;
59      }
60
61
62      return 0;
63 }