5897cde5aa359457c6211c6aeeba0c28f86e5199
[adaptation/intel_mfld/sensor-plugins-mfld-blackbay.git] / inc / accelprocessor.h
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  * Lesser General Public License for more details.
12  *
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-1301  USA
16  */
17
18 #ifndef ACCELPROCESSOR_H
19 #define ACCELPROCESSOR_H
20
21 #include "baseprocessor.h"
22 #define AXES 3
23
24 class AccelProcessor : public BaseProcessor {
25 public:
26      AccelProcessor();
27      virtual bool fill_values(unsigned int type, int &count,
28                               data_unit_idx_t &unit, data_accuracy &accuracy);
29
30      virtual int get_property(unsigned int property_level, base_property_struct &result);
31
32      virtual void process_input_events(const std::vector <input_event *> &events);
33
34 private:
35      void calculateOrientation();
36      void calculateLinearAcceleration();
37      double linear_acc[AXES];
38      double gravity[AXES];
39      /**Last readed X acceleration*/
40      float mX;
41
42      /**Last readed Y acceleration*/
43      float mY;
44
45      /**Last readed Z acceleration*/
46      float mZ;
47
48      /**Calculated pitch*/
49      float mBeta;
50
51      /**Calculated theta*/
52      float mGamma;
53
54      float mAngle;
55
56      /** Current rotation_*/
57      rotation_event mRotation;
58 };
59
60 #endif