Go to the documentation of this file.
51 #define SENSOR_ID (1U)
52 #define SENSOR_TIMEOUT_MS (2000U)
54 #define DEFAULT_PRESET_CONFIG PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
92 if (presence_config == NULL)
94 printf(
"acc_detector_presence_config_create() failed\n");
105 if (presence_handle == NULL)
107 printf(
"acc_detector_presence_create() failed\n");
114 printf(
"acc_detector_presence_get_buffer_size() failed\n");
122 printf(
"buffer allocation failed\n");
133 printf(
"acc_sensor_create() failed\n");
142 printf(
"do_sensor_calibration() failed\n");
149 printf(
"acc_detector_presence_prepare() failed\n");
160 printf(
"acc_sensor_measure failed\n");
167 printf(
"Sensor interrupt timeout\n");
174 printf(
"acc_sensor_read failed\n");
181 printf(
"acc_detector_presence_process failed\n");
189 if (
result.processing_result.data_saturated)
191 printf(
"Data saturated. The detector result is not reliable.\n");
194 if (
result.processing_result.frame_delayed)
196 printf(
"Frame delayed. Could not read data fast enough.\n");
197 printf(
"Try lowering the frame rate or call 'acc_sensor_read' more frequently.\n");
203 printf(
"Sensor recalibration needed ... \n");
207 printf(
"do_sensor_calibration() failed\n");
212 printf(
"Sensor recalibration done!\n");
217 printf(
"acc_detector_presence_prepare() failed\n");
226 printf(
"Application finished OK\n");
239 if (presence_config != NULL)
244 if (presence_handle != NULL)
263 bool cal_complete =
false;
264 const uint16_t calibration_retries = 1U;
267 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
277 if (status && !cal_complete)
281 }
while (status && !cal_complete);
304 printf(
"BEGIN:Distance(m), [Frame], Amplitude\n");
307 for (uint8_t subsweep_idx = 0; subsweep_idx < num_subsweeps; subsweep_idx++)
318 for (uint16_t point_idx = 0; point_idx < subsweep_length; point_idx++)
325 int32_t iq_point_real_acc = 0;
326 int32_t iq_point_imag_acc = 0;
329 for (uint16_t sweep_idx = 0; sweep_idx < sweeps_per_frame; sweep_idx++)
331 uint16_t point_offset = sweep_idx * sweep_length + subsweep_offset + point_idx;
332 iq_point_real_acc += frame[point_offset].
real;
333 iq_point_imag_acc += frame[point_offset].
imag;
337 int16_t imag = frame[point_offset].
imag;
346 printf(
"%" PRIi16
"%s%" PRIi16
"i%s", frame[point_offset].real, sign, imag, ((sweep_idx + 1 == sweeps_per_frame) ?
"" :
", "));
349 iq_point_real_acc = iq_point_real_acc / sweeps_per_frame;
350 iq_point_imag_acc = iq_point_imag_acc / sweeps_per_frame;
353 uint32_t iq_point_abs = (uint32_t)sqrt(iq_point_real_acc * iq_point_real_acc + iq_point_imag_acc * iq_point_imag_acc);
356 printf(
"], %" PRIu32
"\n", iq_point_abs);
360 printf(
"END:Distance(m), [Frame], Amplitude\n");
375 printf(
"Intra presence score: %d, Inter presence score: %d, Distance (mm): %d\n",
378 (
int)(
result->presence_distance * 1000.0f));
void acc_detector_presence_config_inter_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set inter-frame presence detection.
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.
void acc_hal_integration_sensor_supply_off(acc_sensor_id_t sensor_id)
Power off sensor supply.
static void print_result(acc_detector_presence_result_t *result)
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
void acc_detector_presence_destroy(acc_detector_presence_handle_t *presence_handle)
Destroy a presence detector identified with the provided handle.
void acc_detector_presence_config_hwaas_set(acc_detector_presence_config_t *presence_config, uint16_t hwaas)
Set the hardware accelerated average samples (HWAAS)
@ PRESENCE_PRESET_CONFIG_LONG_RANGE
static void cleanup(acc_detector_presence_handle_t *presence_handle, acc_detector_presence_config_t *presence_config, acc_sensor_t *sensor, void *buffer)
bool acc_sensor_read(const acc_sensor_t *sensor, void *buffer, uint32_t buffer_size)
Read out radar data.
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.
uint8_t acc_config_num_subsweeps_get(const acc_config_t *config)
Get the number of subsweeps to use.
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.
@ PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP
Data type for interger-based representation of complex numbers.
The result from a completed calibration.
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
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.
float inter_presence_score
const acc_hal_a121_t * acc_hal_rss_integration_get_implementation(void)
Get hal implementation reference.
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.
void * acc_integration_mem_alloc(size_t size)
Allocate dynamic memory.
Presence detector results container.
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.
uint16_t acc_config_sweeps_per_frame_get(const acc_config_t *config)
Get the number of sweeps per frame.
void acc_detector_presence_config_destroy(acc_detector_presence_config_t *presence_config)
Destroy a presence detector configuration.
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
@ PRESENCE_PRESET_CONFIG_SHORT_RANGE
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.
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.
const char * acc_version_get(void)
Get the version of the Acconeer software.
uint16_t acc_config_subsweep_step_length_get(const acc_config_t *config, uint8_t index)
Get the step length in a sweep.
#define SENSOR_TIMEOUT_MS
float acc_processing_points_to_meter(int32_t points)
Convert a distance or step length in points to meter.
int acconeer_main(int argc, char *argv[])
Assembly test example.
void acc_hal_integration_sensor_enable(acc_sensor_id_t sensor_id)
Enable sensor.
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.
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.
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.
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.
@ PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
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.
void acc_detector_presence_config_intra_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set intra-frame presence detection.
float intra_presence_score
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
struct acc_detector_presence_config acc_detector_presence_config_t
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.
#define ACC_LOG_FLOAT_TO_INTEGER(a)
static void print_iq_data(acc_detector_presence_result_t *result, acc_detector_presence_metadata_t *metadata)
#define DEFAULT_PRESET_CONFIG
void acc_detector_presence_config_log(acc_detector_presence_config_t *presence_config)
Print a configuration to the log.
static bool do_sensor_calibration(acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
void acc_detector_presence_config_profile_set(acc_detector_presence_config_t *presence_config, acc_config_profile_t profile)
Set a profile.
@ PRESENCE_PRESET_CONFIG_NONE
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
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.
struct acc_detector_presence_handle acc_detector_presence_handle_t
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_t * acc_detector_presence_config_create(void)
Create a configuration for a presence detector.
#define PRIfloat
Specifier for printing float type using integers.
void acc_detector_presence_config_signal_quality_set(acc_detector_presence_config_t *presence_config, float signal_quality)
Set signal quality.
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.
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.
bool acc_sensor_measure(acc_sensor_t *sensor)
Start a radar measurement with previously prepared configuration.
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.
int32_t acc_config_subsweep_start_point_get(const acc_config_t *config, uint8_t index)
Get the starting point of the sweep.
static void set_config(acc_detector_presence_config_t *presence_config, presence_preset_config_t preset)
struct acc_sensor acc_sensor_t
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.
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.
void acc_sensor_destroy(acc_sensor_t *sensor)
Destroy a sensor instance freeing any resources allocated.
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.
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_t * acc_sensor_create(acc_sensor_id_t sensor_id)
Create a sensor instance.