sensord: enable samsung pedometer sensor for fused location
[platform/core/system/sensord.git] / src / sensor / pedometer / pedometer.h
1 /*
2  *  Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
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 #ifndef __PEDOMETER_H__
18 #define __PEDOMETER_H__
19
20 #include "common.h"
21 #include "step_detection.h"
22 #include "pedometer_info.h"
23 #include "pedometer_speed_filter.h"
24
25 /************************************************************************
26  * stores pedometer engine state.
27  */
28 class pedometer {
29 public:
30         pedometer();
31         ~pedometer();
32
33         /************************************************************************
34          * enables/disables savitzky filter.
35          */
36         void set_savitzky_filter(bool enable);
37
38         /************************************************************************
39          * resets {@link pedometer} object to initial state.
40          */
41         void reset(void);
42
43         /************************************************************************
44          * called on new acceleration event.
45          *
46          * @param info
47          *            result of pedometer algorithm. valid only it method returns true.
48          * @param timestamp
49          *            timestamp of acceleration event in ns.
50          * @param acc
51          *            vertical component of global acceleration.
52          *
53          * @result
54          *            true if new step event was detected.
55          */
56         bool get_pedometer(timestamp_t timestamp, double acc, pedometer_info *info);
57
58 private:
59         /** detects step and estimates step length. */
60         step_detection m_step_detection;
61
62         /** sum of lengths all steps from start. */
63         double m_total_length;
64
65         /** number of steps from start. */
66         long long m_step_count;
67
68         /** estimates current speed from step length. */
69         pedometer_speed_filter m_pedometer_filter;
70
71         /** some non zero speed was detected. */
72         bool m_some_speed;
73 };
74
75 #endif /* __PEDOMETER_H__ */