10#ifndef INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_DEMO_H_
11#define INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_DEMO_H_
15#include <zephyr/toolchain.h>
52union algorithm_demo_common_data {
54 uint8_t current_state;
84#define ALGORITHM_DEMO_EVENT_DEFINE(name, loggers_, tdfs, event_chance_percent) \
85 static void name##_wrapper(const struct zbus_channel *chan, \
86 const struct infuse_algorithm *algorithm, const void *args) \
88 static union algorithm_demo_common_data data; \
89 algorithm_demo_event_fn(chan, algorithm, args, &data); \
91 static struct algorithm_demo_common_args name##_default_args = { \
94 .loggers = loggers_, \
97 .event_gen_chance = event_chance_percent, \
99 static const struct infuse_algorithm name = { \
100 .fn = name##_wrapper, \
101 .algorithm_id = 0xFFFFFFF0, \
102 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
103 .arguments = &name##_default_args, \
104 .arguments_size = sizeof(struct algorithm_demo_common_args), \
116#define ALGORITHM_DEMO_STATE_DEFINE(name, loggers_, tdfs) \
117 static void name##_wrapper(const struct zbus_channel *chan, \
118 const struct infuse_algorithm *algorithm, const void *args) \
120 static union algorithm_demo_common_data data; \
121 algorithm_demo_state_fn(chan, algorithm, args, &data); \
123 static struct algorithm_demo_common_args name##_default_args = { \
126 .loggers = loggers_, \
130 static const struct infuse_algorithm name = { \
131 .fn = name##_wrapper, \
132 .algorithm_id = 0xFFFFFFF1, \
133 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
134 .arguments = &name##_default_args, \
135 .arguments_size = sizeof(struct algorithm_demo_common_args), \
148#define ALGORITHM_DEMO_METRIC_DEFINE(name, loggers_, tdfs, metric_compute_len) \
149 static void name##_wrapper(const struct zbus_channel *chan, \
150 const struct infuse_algorithm *algorithm, const void *args) \
152 static union algorithm_demo_common_data data; \
153 algorithm_demo_metric_fn(chan, algorithm, args, &data); \
155 static struct algorithm_demo_common_args name##_default_args = { \
158 .loggers = loggers_, \
161 .compute_metric_len = metric_compute_len, \
163 static const struct infuse_algorithm name = { \
164 .fn = name##_wrapper, \
165 .algorithm_id = 0xFFFFFFF2, \
166 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
167 .arguments = &name##_default_args, \
168 .arguments_size = sizeof(struct algorithm_demo_common_args), \
Infuse-IoT algorithm runner.
Infuse-IoT zbus channels.
void algorithm_demo_metric_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_state_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_event_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
@ ALGORITHM_DEMO_STATE_LOG
Definition demo.h:33
@ ALGORITHM_DEMO_METRIC_LOG
Definition demo.h:34
@ ALGORITHM_DEMO_EVENT_LOG
Definition demo.h:32
Arguments common to the demonstration algorithms.
Definition demo.h:38
uint8_t event_gen_chance
Chance to emit an event on each buffer (%)
Definition demo.h:44
struct kv_algorithm_logging logging
Common logging configuration.
Definition demo.h:40
uint16_t compute_metric_len
Number of samples to compute metric over.
Definition demo.h:46
Algorithm definition.
Definition implementation.h:47
Algorithm logging configuration.
Definition kv_types.h:97