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