nRF Connect SDK API 3.3.99
Loading...
Searching...
No Matches
ema.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef ACCEL_TO_ANGLE_FILTER_EMA_H_
8#define ACCEL_TO_ANGLE_FILTER_EMA_H_
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
15
34#define ACCEL_TO_ANGLE_FILTER_EMA_DEFINE(_instance_name, _odr_hz, _tau_s) \
35 BUILD_ASSERT(_odr_hz > 0.0f, \
36 "The output data rate has to be greater than 0"); \
37 BUILD_ASSERT(_tau_s > 0.0f, \
38 "The time constant has to be greater than 0"); \
39 static struct accel_to_angle_ema_ctx _instance_name##_ctx = { \
40 .odr_hz = _odr_hz, \
41 .tau_s = _tau_s, \
42 .alpha = 0.0f, \
43 }; \
44 \
45 static ACCEL_TO_ANGLE_FILTER_DEFINE( \
46 _instance_name, \
47 &_instance_name##_ctx, \
48 filter_ema_data_process_request, \
49 filter_ema_data_clean_request \
50 )
51
79
90
100
103#ifdef __cplusplus
104}
105#endif
106
107#endif /* ACCEL_TO_ANGLE_FILTER_EMA_H_ */
void filter_ema_data_process_request(void *ctx, struct accel_to_angle_accel_data *data)
Filter EMA.
void filter_ema_data_clean_request(void *ctx)
Clean up the EMA filter.
Accelerometer data from 3 axes from the sensor.
Definition accel_to_angle.h:70
float alpha
Filter coefficient.
Definition ema.h:77
float odr_hz
Output data rate in Hz.
Definition ema.h:68
struct accel_to_angle_accel_data filtered_data
Filtered accelerometer data.
Definition ema.h:62
float tau_s
Time constant in seconds.
Definition ema.h:74
Context for the EMA filter.
Definition ema.h:60