example_detector_presence.c
Go to the documentation of this file.
1 // Copyright (c) Acconeer AB, 2022-2025
2 // All rights reserved
3 // This file is subject to the terms and conditions defined in the file
4 // 'LICENSES/license_acconeer.txt', (BSD 3-Clause License) which is part
5 // of this source code package.
6
7 #include <stdbool.h>
8 #include <stdint.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "acc_definitions_a121.h"
13 #include "acc_definitions_common.h"
14 #include "acc_detector_presence.h"
15 #include "acc_hal_definitions_a121.h"
16 #include "acc_hal_integration_a121.h"
17 #include "acc_integration.h"
18 #include "acc_rss_a121.h"
19 #include "acc_sensor.h"
20
21 #include "acc_version.h"
22
23 /** \example example_detector_presence.c
24 * @brief This is an example on how the Detector Presence API can be used
25 * @n
26 * The example executes as follows:
27 * - Create a presence configuration
28 * - Create a sensor instance
29 * - Create a detector instance
30 * - Calibrate the sensor
31 * - Prepare the detector
32 * - Perform a sensor measurement and read out the data
33 * - Process the measurement and get detector result
34 * - Print the result
35 * - Destroy the configuration
36 * - Destroy the detector instance
37 * - Destroy the sensor instance
38 */
39
40 typedef enum
41 {
42 PRESENCE_PRESET_CONFIG_NONE = 0,
43 PRESENCE_PRESET_CONFIG_SHORT_RANGE,
44 PRESENCE_PRESET_CONFIG_MEDIUM_RANGE,
45 PRESENCE_PRESET_CONFIG_LONG_RANGE,
46 PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP,
47 } presence_preset_config_t;
48
49 #define SENSOR_ID (1U)
50 #define SENSOR_TIMEOUT_MS (2000U)
51
52 #define DEFAULT_PRESET_CONFIG PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
53
54 static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size);
55
56 static void print_result(acc_detector_presence_result_t *result);
57
58 static void cleanup(acc_detector_presence_handle_t *presence_handle,
59 acc_detector_presence_config_t *presence_config,
60 acc_sensor_t *sensor,
61 void *buffer);
62
63 static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset);
64
65 int acconeer_main(int argc, char *argv[]);
66
67 int acconeer_main(int argc, char *argv[])
68 {
69 (void)argc;
70 (void)argv;
71 acc_detector_presence_config_t *presence_config = NULL;
72 acc_detector_presence_handle_t *presence_handle = NULL;
73 acc_detector_presence_metadata_t metadata;
74 acc_sensor_t *sensor = NULL;
75 void *buffer = NULL;
76 uint32_t buffer_size = 0U;
77
78 printf("Acconeer software version %s\n", acc_version_get());
79
80 const acc_hal_a121_t *hal = acc_hal_rss_integration_get_implementation();
81
82 if (!acc_rss_hal_register(hal))
83 {
84 return EXIT_FAILURE;
85 }
86
87 presence_config = acc_detector_presence_config_create();
88 if (presence_config == NULL)
89 {
90 printf("acc_detector_presence_config_create() failed\n");
91 cleanup(presence_handle, presence_config, sensor, buffer);
92 return EXIT_FAILURE;
93 }
94
95 set_config(presence_config, DEFAULT_PRESET_CONFIG);
96
97 // Print the configuration
98 acc_detector_presence_config_log(presence_config);
99
100 presence_handle = acc_detector_presence_create(presence_config, &metadata);
101 if (presence_handle == NULL)
102 {
103 printf("acc_detector_presence_create() failed\n");
104 cleanup(presence_handle, presence_config, sensor, buffer);
105 return EXIT_FAILURE;
106 }
107
108 if (!acc_detector_presence_get_buffer_size(presence_handle, &buffer_size))
109 {
110 printf("acc_detector_presence_get_buffer_size() failed\n");
111 cleanup(presence_handle, presence_config, sensor, buffer);
112 return EXIT_FAILURE;
113 }
114
115 buffer = acc_integration_mem_alloc(buffer_size);
116 if (buffer == NULL)
117 {
118 printf("buffer allocation failed\n");
119 cleanup(presence_handle, presence_config, sensor, buffer);
120 return EXIT_FAILURE;
121 }
122
123 acc_hal_integration_sensor_supply_on(SENSOR_ID);
124 acc_hal_integration_sensor_enable(SENSOR_ID);
125
126 sensor = acc_sensor_create(SENSOR_ID);
127 if (sensor == NULL)
128 {
129 printf("acc_sensor_create() failed\n");
130 cleanup(presence_handle, presence_config, sensor, buffer);
131 return EXIT_FAILURE;
132 }
133
134 acc_cal_result_t cal_result;
135
136 if (!do_sensor_calibration(sensor, &cal_result, buffer, buffer_size))
137 {
138 printf("do_sensor_calibration() failed\n");
139 cleanup(presence_handle, presence_config, sensor, buffer);
140 return EXIT_FAILURE;
141 }
142
143 if (!acc_detector_presence_prepare(presence_handle, presence_config, sensor, &cal_result, buffer, buffer_size))
144 {
145 printf("acc_detector_presence_prepare() failed\n");
146 cleanup(presence_handle, presence_config, sensor, buffer);
147 return EXIT_FAILURE;
148 }
149
150 while (true)
151 {
152 acc_detector_presence_result_t result;
153
154 if (!acc_sensor_measure(sensor))
155 {
156 printf("acc_sensor_measure failed\n");
157 cleanup(presence_handle, presence_config, sensor, buffer);
158 return EXIT_FAILURE;
159 }
160
161 if (!acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS))
162 {
163 printf("Sensor interrupt timeout\n");
164 cleanup(presence_handle, presence_config, sensor, buffer);
165 return EXIT_FAILURE;
166 }
167
168 if (!acc_sensor_read(sensor, buffer, buffer_size))
169 {
170 printf("acc_sensor_read failed\n");
171 cleanup(presence_handle, presence_config, sensor, buffer);
172 return EXIT_FAILURE;
173 }
174
175 if (!acc_detector_presence_process(presence_handle, buffer, &result))
176 {
177 printf("acc_detector_presence_process failed\n");
178 cleanup(presence_handle, presence_config, sensor, buffer);
179 return EXIT_FAILURE;
180 }
181
182 print_result(&result);
183
184 if (result.processing_result.data_saturated)
185 {
186 printf("Data saturated. The detector result is not reliable.\n");
187 }
188
189 if (result.processing_result.frame_delayed)
190 {
191 printf("Frame delayed. Could not read data fast enough.\n");
192 printf("Try lowering the frame rate or call 'acc_sensor_read' more frequently.\n");
193 }
194
195 /* If "calibration_needed" is indicated, the sensor needs to be recalibrated. */
196 if (result.processing_result.calibration_needed)
197 {
198 printf("Sensor recalibration needed ... \n");
199
200 if (!do_sensor_calibration(sensor, &cal_result, buffer, buffer_size))
201 {
202 printf("do_sensor_calibration() failed\n");
203 cleanup(presence_handle, presence_config, sensor, buffer);
204 return EXIT_FAILURE;
205 }
206
207 printf("Sensor recalibration done!\n");
208
209 /* Before measuring again, the sensor needs to be prepared through the detector. */
210 if (!acc_detector_presence_prepare(presence_handle, presence_config, sensor, &cal_result, buffer, buffer_size))
211 {
212 printf("acc_detector_presence_prepare() failed\n");
213 cleanup(presence_handle, presence_config, sensor, buffer);
214 return EXIT_FAILURE;
215 }
216 }
217 }
218
219 cleanup(presence_handle, presence_config, sensor, buffer);
220
221 printf("Application finished OK\n");
222
223 return EXIT_SUCCESS;
224 }
225
226 static void cleanup(acc_detector_presence_handle_t *presence_handle,
227 acc_detector_presence_config_t *presence_config,
228 acc_sensor_t *sensor,
229 void *buffer)
230 {
231 acc_hal_integration_sensor_disable(SENSOR_ID);
232 acc_hal_integration_sensor_supply_off(SENSOR_ID);
233
234 if (presence_config != NULL)
235 {
236 acc_detector_presence_config_destroy(presence_config);
237 }
238
239 if (presence_handle != NULL)
240 {
241 acc_detector_presence_destroy(presence_handle);
242 }
243
244 if (sensor != NULL)
245 {
246 acc_sensor_destroy(sensor);
247 }
248
249 if (buffer != NULL)
250 {
251 acc_integration_mem_free(buffer);
252 }
253 }
254
255 static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
256 {
257 bool status = false;
258 bool cal_complete = false;
259 const uint16_t calibration_retries = 1U;
260
261 // Random disturbances may cause the calibration to fail. At failure, retry at least once.
262 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
263 {
264 // Reset sensor before calibration by disabling/enabling it
265 acc_hal_integration_sensor_disable(SENSOR_ID);
266 acc_hal_integration_sensor_enable(SENSOR_ID);
267
268 do
269 {
270 status = acc_sensor_calibrate(sensor, &cal_complete, cal_result, buffer, buffer_size);
271
272 if (status && !cal_complete)
273 {
274 status = acc_hal_integration_wait_for_sensor_interrupt(SENSOR_ID, SENSOR_TIMEOUT_MS);
275 }
276 } while (status && !cal_complete);
277 }
278
279 if (status)
280 {
281 /* Reset sensor after calibration by disabling/enabling it */
282 acc_hal_integration_sensor_disable(SENSOR_ID);
283 acc_hal_integration_sensor_enable(SENSOR_ID);
284 }
285
286 return status;
287 }
288
289 static void print_result(acc_detector_presence_result_t *result)
290 {
291 if (result->presence_detected)
292 {
293 printf("Motion\n");
294 }
295 else
296 {
297 printf("No motion\n");
298 }
299
300 // Score and distance are multiplied by 1000 to avoid printing floats
301 printf("Intra presence score: %d, Inter presence score: %d, Distance (mm): %d\n",
302 (int)(result->intra_presence_score * 1000.0f),
303 (int)(result->inter_presence_score * 1000.0f),
304 (int)(result->presence_distance * 1000.0f));
305 }
306
307 static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset)
308 {
309 switch (preset)
310 {
311 case PRESENCE_PRESET_CONFIG_NONE:
312 // Add configuration of the detector here
313 break;
314
315 case PRESENCE_PRESET_CONFIG_SHORT_RANGE:
316 acc_detector_presence_config_start_set(presence_config, 0.06f);
317 acc_detector_presence_config_end_set(presence_config, 1.0f);
318 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
319 acc_detector_presence_config_signal_quality_set(presence_config, 30.0f);
320 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
321 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 16);
322 acc_detector_presence_config_frame_rate_set(presence_config, 10.0f);
323 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, false);
324 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
325 acc_detector_presence_config_intra_detection_set(presence_config, true);
326 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.4f);
327 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
328 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
329 acc_detector_presence_config_inter_detection_set(presence_config, true);
330 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 1.0f);
331 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
332 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 5.0f);
333 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
334 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.0f);
335 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 3);
336
337 break;
338
339 case PRESENCE_PRESET_CONFIG_MEDIUM_RANGE:
340 acc_detector_presence_config_start_set(presence_config, 0.3f);
341 acc_detector_presence_config_end_set(presence_config, 2.5f);
342 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
343 acc_detector_presence_config_signal_quality_set(presence_config, 20.0f);
344 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
345 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 16);
346 acc_detector_presence_config_frame_rate_set(presence_config, 12.0f);
347 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, false);
348 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
349 acc_detector_presence_config_intra_detection_set(presence_config, true);
350 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.3f);
351 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
352 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
353 acc_detector_presence_config_inter_detection_set(presence_config, true);
354 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 1.0f);
355 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
356 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 6.0f);
357 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
358 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.0f);
359 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 3);
360
361 break;
362
363 case PRESENCE_PRESET_CONFIG_LONG_RANGE:
364 acc_detector_presence_config_start_set(presence_config, 5.0f);
365 acc_detector_presence_config_end_set(presence_config, 7.5f);
366 acc_detector_presence_config_automatic_subsweeps_set(presence_config, true);
367 acc_detector_presence_config_signal_quality_set(presence_config, 10.0f);
368 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
369 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 16);
370 acc_detector_presence_config_frame_rate_set(presence_config, 12.0f);
371 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, false);
372 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
373 acc_detector_presence_config_intra_detection_set(presence_config, true);
374 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.2f);
375 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.15f);
376 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
377 acc_detector_presence_config_inter_detection_set(presence_config, true);
378 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 0.8f);
379 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
380 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 6.0f);
381 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
382 acc_detector_presence_config_inter_output_time_const_set(presence_config, 2.0f);
383 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 3);
384
385 break;
386
387 case PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP:
388 acc_detector_presence_config_start_set(presence_config, 0.38f);
389 acc_detector_presence_config_end_set(presence_config, 0.67f);
390 acc_detector_presence_config_automatic_subsweeps_set(presence_config, false);
391 acc_detector_presence_config_signal_quality_set(presence_config, 20.0f);
392 acc_detector_presence_config_auto_step_length_set(presence_config, true);
393 acc_detector_presence_config_auto_profile_set(presence_config, false);
394 acc_detector_presence_config_profile_set(presence_config, ACC_CONFIG_PROFILE_5);
395 acc_detector_presence_config_inter_frame_idle_state_set(presence_config, ACC_CONFIG_IDLE_STATE_DEEP_SLEEP);
396 acc_detector_presence_config_hwaas_set(presence_config, 8);
397 acc_detector_presence_config_sweeps_per_frame_set(presence_config, 8);
398 acc_detector_presence_config_frame_rate_set(presence_config, 0.7f);
399 acc_detector_presence_config_frame_rate_app_driven_set(presence_config, false);
400 acc_detector_presence_config_reset_filters_on_prepare_set(presence_config, true);
401 acc_detector_presence_config_intra_detection_set(presence_config, true);
402 acc_detector_presence_config_intra_detection_threshold_set(presence_config, 1.7f);
403 acc_detector_presence_config_intra_frame_time_const_set(presence_config, 0.3f);
404 acc_detector_presence_config_intra_output_time_const_set(presence_config, 0.3f);
405 acc_detector_presence_config_inter_detection_set(presence_config, true);
406 acc_detector_presence_config_inter_detection_threshold_set(presence_config, 1.2f);
407 acc_detector_presence_config_inter_frame_deviation_time_const_set(presence_config, 0.5f);
408 acc_detector_presence_config_inter_frame_fast_cutoff_set(presence_config, 5.0f);
409 acc_detector_presence_config_inter_frame_slow_cutoff_set(presence_config, 0.20f);
410 acc_detector_presence_config_inter_output_time_const_set(presence_config, 0.5f);
411 acc_detector_presence_config_inter_frame_presence_timeout_set(presence_config, 2);
412
413 break;
414 }
415 }
set_config
static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset)
Definition: example_detector_presence.c:307
acc_detector_presence_config_inter_detection_set
void acc_detector_presence_config_inter_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set inter-frame presence detection.
acc_detector_presence_config_sweeps_per_frame_set
void acc_detector_presence_config_sweeps_per_frame_set(acc_detector_presence_config_t *presence_config, uint16_t sweeps_per_frame)
Set the number of sweeps per frame.
acc_hal_integration_sensor_supply_off
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
Definition: acc_hal_integration_stm32cube_xm.c:104
acc_rss_a121.h
cargo_result_t::calibration_needed
bool calibration_needed
Definition: example_cargo.h:112
acc_hal_integration_sensor_supply_on
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
Definition: acc_hal_integration_stm32cube_xm.c:99
acc_detector_presence_destroy
void acc_detector_presence_destroy(acc_detector_presence_handle_t *presence_handle)
Destroy a presence detector identified with the provided handle.
acc_detector_presence_config_hwaas_set
void acc_detector_presence_config_hwaas_set(acc_detector_presence_config_t *presence_config, uint16_t hwaas)
Set the hardware accelerated average samples (HWAAS)
acc_sensor_read
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
SENSOR_TIMEOUT_MS
#define SENSOR_TIMEOUT_MS
Definition: example_detector_presence.c:50
buffer
void * buffer
Definition: i2c_example_cargo.c:40
acc_version.h
acc_detector_presence_config_inter_frame_deviation_time_const_set
void acc_detector_presence_config_inter_frame_deviation_time_const_set(acc_detector_presence_config_t *presence_config, float inter_frame_deviation_time_const)
Set the time constant of the low pass filter for the inter-frame deviation between fast and slow.
acc_detector_presence_config_auto_profile_set
void acc_detector_presence_config_auto_profile_set(acc_detector_presence_config_t *presence_config, bool enable)
Enable automatic selection of profile based on start point of measurement.
acc_cal_result_t
The result from a completed calibration.
Definition: acc_definitions_a121.h:30
acconeer_main
int acconeer_main(int argc, char *argv[])
Assembly test example.
Definition: example_detector_presence.c:67
acc_detector_presence_config_frame_rate_set
void acc_detector_presence_config_frame_rate_set(acc_detector_presence_config_t *presence_config, float frame_rate)
Set the frame rate.
ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
@ ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
Definition: acc_definitions_a121.h:73
ACC_CONFIG_PROFILE_5
@ ACC_CONFIG_PROFILE_5
Definition: acc_definitions_a121.h:57
PRESENCE_PRESET_CONFIG_LONG_RANGE
@ PRESENCE_PRESET_CONFIG_LONG_RANGE
Definition: example_detector_presence.c:45
acc_integration.h
acc_detector_presence_get_buffer_size
bool acc_detector_presence_get_buffer_size(const acc_detector_presence_handle_t *presence_handle, uint32_t *buffer_size)
Get the buffer size needed for the provided presence detector handle.
print_result
static void print_result(acc_detector_presence_result_t *result)
Definition: example_detector_presence.c:289
cargo_result_t::inter_presence_score
float inter_presence_score
Definition: example_cargo.h:137
acc_hal_rss_integration_get_implementation
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
Definition: acc_hal_integration_stm32cube_xm.c:152
acc_detector_presence_config_intra_detection_threshold_set
void acc_detector_presence_config_intra_detection_threshold_set(acc_detector_presence_config_t *presence_config, float intra_detection_threshold)
Set the detection threshold for the intra-frame presence detection.
acc_integration_mem_alloc
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Definition: acc_integration_stm32.c:592
acc_hal_a121_t
Definition: acc_hal_definitions_a121.h:82
acc_rss_hal_register
bool acc_rss_hal_register(const acc_hal_a121_t *hal)
Register an integration.
acc_sensor.h
acc_detector_presence_result_t
Presence detector results container.
Definition: acc_detector_presence.h:46
buffer_size
uint32_t buffer_size
Definition: i2c_example_cargo.c:41
acc_detector_presence_config_inter_frame_presence_timeout_set
void acc_detector_presence_config_inter_frame_presence_timeout_set(acc_detector_presence_config_t *presence_config, uint16_t inter_frame_presence_timeout)
Set the inter-frame presence timeout in seconds.
DEFAULT_PRESET_CONFIG
#define DEFAULT_PRESET_CONFIG
Definition: example_detector_presence.c:52
sensor
acc_sensor_t * sensor
Definition: i2c_example_cargo.c:33
acc_detector_presence_config_destroy
void acc_detector_presence_config_destroy(acc_detector_presence_config_t *presence_config)
Destroy a presence detector configuration.
acc_detector_presence_metadata_t
Definition: acc_detector_presence.h:88
acc_hal_integration_wait_for_sensor_interrupt
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
Definition: acc_hal_integration_stm32cube_xm.c:130
acc_hal_integration_a121.h
acc_detector_presence_config_end_set
void acc_detector_presence_config_end_set(acc_detector_presence_config_t *presence_config, float end)
Set the end point of measurement interval in meters.
acc_detector_presence_config_intra_output_time_const_set
void acc_detector_presence_config_intra_output_time_const_set(acc_detector_presence_config_t *presence_config, float intra_output_time_const)
Set the time constant for the output in the intra-frame part.
result
cargo_result_t result
Definition: i2c_example_cargo.c:43
acc_version_get
const char * acc_version_get(void)
Get the version of the Acconeer software.
PRESENCE_PRESET_CONFIG_SHORT_RANGE
@ PRESENCE_PRESET_CONFIG_SHORT_RANGE
Definition: example_detector_presence.c:43
printf
#define printf
Definition: printf.h:60
acc_hal_integration_sensor_enable
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
Definition: acc_hal_integration_stm32cube_xm.c:109
acc_detector_presence_config_inter_frame_idle_state_set
void acc_detector_presence_config_inter_frame_idle_state_set(acc_detector_presence_config_t *presence_config, acc_config_idle_state_t idle_state)
Set inter frame idle state.
acc_hal_definitions_a121.h
acc_detector_presence_process
bool acc_detector_presence_process(acc_detector_presence_handle_t *presence_handle, void *buffer, acc_detector_presence_result_t *result)
Process the data according to the configuration used in acc_detector_presence_config_create.
acc_detector_presence_config_inter_output_time_const_set
void acc_detector_presence_config_inter_output_time_const_set(acc_detector_presence_config_t *presence_config, float inter_output_time_const)
Set the time constant for the output in the inter-frame part.
PRESENCE_PRESET_CONFIG_NONE
@ PRESENCE_PRESET_CONFIG_NONE
Definition: example_detector_presence.c:42
acc_detector_presence_config_reset_filters_on_prepare_set
void acc_detector_presence_config_reset_filters_on_prepare_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the presence filters should reset on prepare.
acc_detector_presence_prepare
bool acc_detector_presence_prepare(const acc_detector_presence_handle_t *presence_handle, acc_detector_presence_config_t *presence_config, acc_sensor_t *sensor, const acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Prepare the detector to do a measurement.
acc_detector_presence_config_intra_detection_set
void acc_detector_presence_config_intra_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set intra-frame presence detection.
cargo_result_t::intra_presence_score
float intra_presence_score
Definition: example_cargo.h:140
acc_hal_integration_sensor_disable
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
Definition: acc_hal_integration_stm32cube_xm.c:119
acc_detector_presence_config_t
struct acc_detector_presence_config acc_detector_presence_config_t
Definition: acc_detector_presence.h:41
do_sensor_calibration
static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Definition: example_detector_presence.c:255
presence_preset_config_t
presence_preset_config_t
Definition: example_detector_presence_low_power_hibernate.c:45
acc_detector_presence_config_inter_frame_slow_cutoff_set
void acc_detector_presence_config_inter_frame_slow_cutoff_set(acc_detector_presence_config_t *presence_config, float inter_frame_slow_cutoff)
Set the cutoff frequency of the low pass filter for the slow filtered absolute sweep mean.
acc_detector_presence_config_log
void acc_detector_presence_config_log(acc_detector_presence_config_t *presence_config)
Print a configuration to the log.
PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
@ PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
Definition: example_detector_presence.c:44
acc_detector_presence_config_profile_set
void acc_detector_presence_config_profile_set(acc_detector_presence_config_t *presence_config, acc_config_profile_t profile)
Set a profile.
acc_integration_mem_free
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
Definition: acc_integration_stm32.c:602
acc_definitions_common.h
acc_detector_presence_create
acc_detector_presence_handle_t * acc_detector_presence_create(acc_detector_presence_config_t *presence_config, acc_detector_presence_metadata_t *metadata)
Create a presence detector with the provided configuration.
SENSOR_ID
#define SENSOR_ID
Definition: example_detector_presence.c:49
PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP
@ PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP
Definition: example_detector_presence.c:46
acc_detector_presence_handle_t
struct acc_detector_presence_handle acc_detector_presence_handle_t
Definition: acc_detector_presence.h:34
acc_sensor_calibrate
bool acc_sensor_calibrate(acc_sensor_t *sensor, bool *cal_complete, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
Calibrate a sensor.
acc_detector_presence_config_create
acc_detector_presence_config_t * acc_detector_presence_config_create(void)
Create a configuration for a presence detector.
cargo_result_t::presence_detected
bool presence_detected
Definition: example_cargo.h:134
acc_detector_presence_config_signal_quality_set
void acc_detector_presence_config_signal_quality_set(acc_detector_presence_config_t *presence_config, float signal_quality)
Set signal quality.
acc_detector_presence_config_start_set
void acc_detector_presence_config_start_set(acc_detector_presence_config_t *presence_config, float start)
Set the start point of measurement interval in meters.
acc_detector_presence.h
acc_detector_presence_config_inter_detection_threshold_set
void acc_detector_presence_config_inter_detection_threshold_set(acc_detector_presence_config_t *presence_config, float inter_detection_threshold)
Set the detection threshold for the inter-frame presence detection.
acc_sensor_measure
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
acc_detector_presence_config_auto_step_length_set
void acc_detector_presence_config_auto_step_length_set(acc_detector_presence_config_t *presence_config, bool enable)
Enable automatic selection of step length based on the profile.
acc_sensor_t
struct acc_sensor acc_sensor_t
Definition: acc_sensor.h:31
acc_detector_presence_config_intra_frame_time_const_set
void acc_detector_presence_config_intra_frame_time_const_set(acc_detector_presence_config_t *presence_config, float intra_frame_time_const)
Set the time constant for the depthwise filtering in the intra-frame part.
acc_detector_presence_config_automatic_subsweeps_set
void acc_detector_presence_config_automatic_subsweeps_set(acc_detector_presence_config_t *presence_config, bool automatic_subsweeps)
Set if automatic subsweeps should be used.
acc_sensor_destroy
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
cleanup
static void cleanup(acc_detector_presence_handle_t *presence_handle, acc_detector_presence_config_t *presence_config, acc_sensor_t *sensor, void *buffer)
Definition: example_detector_presence.c:226
acc_definitions_a121.h
acc_detector_presence_config_frame_rate_app_driven_set
void acc_detector_presence_config_frame_rate_app_driven_set(acc_detector_presence_config_t *presence_config, bool enable)
Set if the application should maintain the requested frame rate.
acc_detector_presence_config_inter_frame_fast_cutoff_set
void acc_detector_presence_config_inter_frame_fast_cutoff_set(acc_detector_presence_config_t *presence_config, float inter_frame_fast_cutoff)
Set the cutoff frequency of the low pass filter for the fast filtered absolute sweep mean.
acc_sensor_create
acc_sensor_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.
presence_preset_config_t
presence_preset_config_t
Definition: example_detector_presence.c:40