sensord: enable samsung pedometer sensor for fused location
[platform/core/system/sensord.git] / src / sensor / pedometer / step_detection.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 __STEP_DETECTION_H__
18 #define __STEP_DETECTION_H__
19
20 #include "average_filter.h"
21 #include "zero_crossing_step_detection.h"
22 #include "savitzky_golay_filter15.h"
23 #include "step_event.h"
24 #include "common.h"
25
26 /************************************************************************
27  * step detection engine state.
28  */
29 class step_detection {
30 public:
31         step_detection();
32         ~step_detection();
33
34         /************************************************************************
35          */
36         void set_peak_threshold(double threshold);
37
38         /************************************************************************
39          */
40         void set_use_savitzky(bool use_savitzky);
41
42         /************************************************************************
43          */
44         bool is_slow_step(void);
45
46         /************************************************************************
47          */
48         bool add_acc_sensor_values_average(
49                         timestamp_t timestamp, double acc, step_event* step);
50
51         /************************************************************************
52          */
53         bool add_acc_sensor_values_savitzky(
54                         timestamp_t timestamp, double acc, step_event* step);
55
56         /************************************************************************
57          */
58         bool get_step(timestamp_t timestamp, double acc, step_event* step);
59
60         /************************************************************************
61          * resets step_detection object to initial state.
62          */
63         void reset(void);
64
65 private:
66         average_filter m_average_filter;
67         average_filter m_average_gfilter;
68         zero_crossing_step_detection m_zero_crossing_up;
69         zero_crossing_step_detection m_zero_crossing_down;
70
71         savitzky_golay_filter15 m_zc_filter;
72         double m_peak_threshold;
73         bool m_use_savitzky;
74         timestamp_t m_last_step_timestamp;
75         bool m_zero_crossing_up_detected;
76         bool m_zero_crossing_down_detected;
77         double m_minimum_acceleration;
78         double m_maximum_acceleration;
79         bool m_is_slow_step_detected;
80 };
81
82 #endif /* __STEP_DETECTION_H__ */