Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
tilt.h
Go to the documentation of this file.
1
11
12#ifndef INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_TILT_H_
13#define INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_TILT_H_
14
15#include <stdint.h>
16
17#include <zephyr/toolchain.h>
18
21#include <infuse/math/filter.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
34
35enum {
37};
38
39/* Algorithm runtime state */
41struct algorithm_tilt_data {
42 struct iir_filter_single_pole_f32 filter;
43 struct kv_gravity_reference gravity;
44 uint32_t kv_store_crc;
45 uint16_t gravity_mag;
46 bool reference_valid;
47};
49
51void algorithm_tilt_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm,
52 const void *args, void *data);
53
63#define ALGORITHM_TILT_DEFINE(name, loggers_, tdfs, filter_alpha, one_g_valid_percent) \
64 static void name##_wrapper(const struct zbus_channel *chan, \
65 const struct infuse_algorithm *algorithm, const void *args) \
66 { \
67 static struct algorithm_tilt_data data; \
68 algorithm_tilt_fn(chan, algorithm, args, &data); \
69 } \
70 static struct kv_alg_tilt_args name##_default_args = { \
71 .logging = \
72 { \
73 .loggers = loggers_, \
74 .tdf_mask = tdfs, \
75 }, \
76 .args = \
77 { \
78 .iir_filter_alpha = filter_alpha, \
79 .one_g_percent = one_g_valid_percent, \
80 }, \
81 }; \
82 static const struct infuse_algorithm name = { \
83 .fn = name##_wrapper, \
84 .algorithm_id = 0x15F20001, \
85 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
86 .arguments = &name##_default_args, \
87 .arguments_size = sizeof(struct kv_alg_tilt_args), \
88 .arguments_kv_key = KV_KEY_ALG_TILT_ARGS, \
89 }
90
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif /* INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_TILT_H_ */
Infuse-IoT algorithm runner.
Infuse-IoT zbus channels.
void algorithm_tilt_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
@ ALGORITHM_TILT_LOG_ANGLE
Definition tilt.h:36
Data filtering library.
Infuse-IoT statistics helpers.
Algorithm definition.
Definition implementation.h:47