1 /* Medfield sensor plugins
2 * Copyright (C) 2013 Intel Corporation
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.
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 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301USA
18 #include "gyroprocessor.h"
21 GyroProcessor::GyroProcessor()
26 find_input_device_by_name("gyro");
27 find_device_from_udev("gyro");
28 mSupportedEvents.push_back(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
31 bool GyroProcessor::fill_values(unsigned int type, int &count,
32 data_unit_idx_t &unit, data_accuracy &accuracy)
35 if (type == GYRO_BASE_DATA_SET) {
37 accuracy = ACCURACY_GOOD;
38 unit = IDX_UNDEFINED_UNIT;
42 DbgPrint("Values not processed");
46 int GyroProcessor::get_property(unsigned int property_level,
47 base_property_struct &result)
49 strcpy(result.sensor_name,"mpu3050");
50 strcpy(result.sensor_vendor,"invensense");
51 if (property_level == GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME) {
52 result.sensor_unit_idx = IDX_UNDEFINED_UNIT;
53 result.sensor_min_range = 0;
54 result.sensor_max_range = 1;
55 result.sensor_resolution = 0.001;
63 void GyroProcessor::process_input_events(const std::vector <input_event *> &events)
66 BaseProcessor::process_input_events(events);
68 //Sensor input all x and z values in negative from value
69 //expected from sensor framework
70 //and all axis as integer as integer (multiplied by 1000)
72 mValues[0] /= -1000.0;
74 mValues[2] /= -1000.0;