2 * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "pedometer.h"
18 #include "step_event.h"
22 pedometer::pedometer()
26 , m_pedometer_filter()
31 pedometer::~pedometer()
35 void pedometer::set_savitzky_filter(bool enable)
37 m_step_detection.set_use_savitzky(enable);
40 void pedometer::reset(void)
44 m_step_detection.reset();
45 m_pedometer_filter.reset();
49 bool pedometer::get_pedometer(timestamp_t timestamp, double acc, pedometer_info *info)
54 if (m_step_detection.get_step(timestamp, acc, &event)) {
55 if (event.m_timestamp != UNKNOWN_TIMESTAMP) {
57 m_total_length += event.m_step_length;
58 m_pedometer_filter.get_step(timestamp, event.m_step_length);
59 double speed = m_pedometer_filter.get_speed(timestamp);
60 info->timestamp = timestamp;
61 info->is_step_detected = true;
62 info->step_count = m_step_count;
63 info->step_length = event.m_step_length;
64 info->total_step_length = m_total_length;
65 info->step_speed = speed;
67 m_some_speed = speed != 0;
71 double speed = m_pedometer_filter.get_speed(timestamp);
74 info->timestamp = timestamp;
75 info->is_step_detected = true;
76 info->step_count = m_step_count;
77 info->step_length = 0;
78 info->total_step_length = m_total_length;