Go to the documentation of this file.
42 #define SENSOR_ID (1U)
43 #define SENSOR_TIMEOUT_MS (1000U)
45 #define DEFAULT_PRESET_CONFIG SMART_PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
254 printf(
"acc_detector_presence_config_create() failed\n");
262 printf(
"acc_detector_presence_config_create() failed\n");
271 printf(
"Initializing detector context failed\n");
282 printf(
"Sensor initializaiton failed\n");
289 printf(
"Sensor calibration failed\n");
296 printf(
"Sensor prepare failed failed\n");
303 printf(
"enter_hibernate failed\n");
312 bool swap_needed =
false;
317 printf(
"Could not get next result\n");
324 printf(
"Failed to process presence result\n");
333 printf(
"Data saturated. The detector result is not reliable.\n");
338 printf(
"Frame delayed. Could not read data fast enough.\n");
339 printf(
"Try lowering the frame rate or call 'acc_sensor_read' more frequently.\n");
344 printf(
"Sensor recalibration needed ... \n");
348 printf(
"exit_hibernate failed\n");
354 printf(
"Sensor calibration failed\n");
359 printf(
"Sensor recalibration done!\n");
366 printf(
"Sensor prepare failed failed\n");
373 printf(
"enter_hibernate failed\n");
389 printf(
"exit_hibernate failed\n");
397 printf(
"Sensor prepare failed failed\n");
404 printf(
"enter_hibernate failed\n");
414 printf(
"Application finished OK\n");
456 for (uint32_t distance = 0; distance < context->
num_distances; distance++)
458 context->
distances[distance] = start_m + (distance * step_length_m);
472 context->
zone_limits[zone] = start_m + ((float)(zone + 1) * zone_step_length);
493 return max_buffer_size;
509 return max_num_points;
525 return max_num_zones;
537 printf(
"acc_detector_presence_create() failed\n");
543 printf(
"acc_detector_presence_get_buffer_size() failed\n");
563 printf(
"acc_detector_presence_create() failed\n");
569 printf(
"acc_detector_presence_get_buffer_size() failed\n");
575 printf(
"Failed to initialize resources for wakeup\n");
584 if (context->
buffer == NULL)
586 printf(
"sensor buffer allocation failed\n");
593 printf(
"distances allocation failed\n");
600 printf(
"zone limits allocation failed\n");
608 printf(
"zone result allocation failed\n");
619 printf(
"wake up detection allocation failed\n");
636 float inter_frame_deviation_time_const =
638 float inter_output_time_const =
640 float intra_frame_time_const =
642 float intra_output_time_const =
646 float max_switch_delay_n = inter_frame_deviation_time_const + inter_output_time_const;
648 if (max_switch_delay_n < (intra_frame_time_const + intra_output_time_const))
650 max_switch_delay_n = intra_frame_time_const + intra_output_time_const;
684 if (context->
sensor != NULL)
689 if (context->
buffer != NULL)
719 if (context->
sensor == NULL)
721 printf(
"acc_sensor_create() failed\n");
740 printf(
"acc_detector_presence_prepare() failed\n");
751 bool cal_complete =
false;
752 const uint16_t calibration_retries = 1U;
755 for (uint16_t i = 0; !status && (i <= calibration_retries); i++)
766 if (status && !cal_complete)
770 }
while (status && !cal_complete);
781 printf(
"acc_sensor_calibrate() failed\n");
794 printf(
"exit_hibernate failed\n");
800 printf(
"acc_sensor_measure failed\n");
806 printf(
"Sensor interrupt timeout\n");
812 printf(
"acc_sensor_read failed\n");
818 printf(
"enter_hibernate failed\n");
824 printf(
"acc_detector_presence_process failed\n");
838 printf(
"acc_sensor_hibernate_on failed\n");
855 printf(
"acc_sensor_hibernate_off failed\n");
1178 static int32_t max_inter_zone = -1;
1179 static int32_t max_intra_zone = -1;
1184 float *depthwise_scores;
1185 int32_t *max_presence_zone;
1194 max_presence_zone = &max_inter_zone;
1203 max_presence_zone = &max_intra_zone;
1209 if (score > threshold)
1212 bool any_zone_detected =
false;
1213 bool zone_detected =
false;
1214 uint32_t limit_idx = 0;
1221 zone_detected =
false;
1231 zone_detected = (depthwise_scores[i] > threshold);
1243 any_zone_detected =
true;
1249 if (!any_zone_detected)
1263 float max_score = 0.0f;
1264 float max_distance = 0.0f;
1265 uint32_t max_zone = 0;
1269 if (depthwise_scores[i] > max_score)
1271 max_score = depthwise_scores[i];
1281 *max_presence_zone = max_zone;
1286 *max_presence_zone = -1;
1290 return *max_presence_zone;
1301 int32_t max_inter_zone = -1;
1302 int32_t max_intra_zone = -1;
1317 if (max_intra_zone != -1)
1372 uint32_t num_detections = 0;
float inter_presence_score
static bool enter_hibernate(acc_sensor_t *sensor)
void * acc_integration_mem_calloc(size_t nmemb, size_t size)
Allocate dynamic memory.
uint32_t num_zones_for_wakeup
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 bool initialize_application_resources(app_context_t *context)
bool acc_detector_presence_prepare(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.
int acconeer_main(int argc, char *argv[])
Assembly test example.
acc_ref_app_smart_presence_config_t * app_config
@ SMART_PRESENCE_PRESET_CONFIG_NONE
acc_detector_presence_config_t * current_presence_config
void acc_hal_integration_sensor_supply_on(acc_sensor_id_t sensor_id)
Power on sensor supply.
presence_detector_context_t * current_context
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)
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_phase_boost_set(acc_detector_presence_config_t *presence_config, bool enable)
Set inter-frame phase boost.
static bool exit_hibernate(acc_sensor_t *sensor)
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_ref_app_smart_presence_wakeup_config_t wakeup_config
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.
static bool initialize_wakeup_resources(app_context_t *context)
Smart presence reference application results container for each zone.
acc_processing_result_t processing_result
uint32_t * wakeup_detections
bool inter_zone_detection
void acc_detector_presence_config_frame_rate_set(acc_detector_presence_config_t *presence_config, float frame_rate)
Set the frame rate.
@ SMART_PRESENCE_PRESET_CONFIG_MEDIUM_RANGE
int32_t max_presence_zone
float acc_detector_presence_config_inter_output_time_const_get(const acc_detector_presence_config_t *presence_config)
Get the time constant for the output in the inter-frame part.
static bool detector_get_next(app_context_t *context, acc_detector_presence_result_t *detector_result)
@ SMART_PRESENCE_MODE_NOMINAL
acc_detector_presence_handle_t * detector_handle
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.
static bool sensor_prepare(app_context_t *context)
static bool swap_config(app_context_t *context, smart_presence_mode_t new_mode)
@ SMART_PRESENCE_PRESET_CONFIG_LONG_RANGE
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.
static uint32_t get_max_num_zones(app_context_t *context)
acc_detector_presence_metadata_t metadata
static void set_config(acc_ref_app_smart_presence_config_t *app_config, smart_presence_preset_config_t preset)
acc_smart_presence_zone_result_t * zone_results
bool acc_detector_presence_config_inter_detection_get(const acc_detector_presence_config_t *presence_config)
Get if inter-frame presence detection is enabled.
bool intra_zone_detection
void acc_integration_set_periodic_wakeup(uint32_t time_msec)
Set up a periodic timer used to wake up the system from sleep.
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.
acc_detector_presence_config_t * presence_config
smart_presence_mode_t current_mode
@ SMART_PRESENCE_PRESET_CONFIG_SHORT_RANGE
uint32_t max_switch_delay_n
float intra_presence_score
void acc_detector_presence_config_destroy(acc_detector_presence_config_t *presence_config)
Destroy a presence detector configuration.
uint32_t * wakeup_detections
bool acc_detector_presence_config_intra_detection_get(const acc_detector_presence_config_t *presence_config)
Get if frame intra-frame presence detection is enabled.
bool acc_hal_integration_wait_for_sensor_interrupt(acc_sensor_id_t sensor_id, uint32_t timeout_ms)
Wait for a sensor interrupt.
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.
bool acc_sensor_hibernate_off(const acc_sensor_t *sensor)
Restore sensor after exiting hibernation.
const char * acc_version_get(void)
Get the version of the Acconeer software.
float intra_presence_score
float acc_detector_presence_config_inter_detection_threshold_get(const acc_detector_presence_config_t *presence_config)
Get the detection threshold for the inter-frame presence detection.
float inter_presence_score
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.
float * depthwise_intra_presence_scores
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.
static void print_result(app_context_t *context, acc_smart_presence_result_t *result)
acc_cal_result_t sensor_cal_result
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.
static bool sensor_calibration(app_context_t *context)
@ ACC_CONFIG_IDLE_STATE_DEEP_SLEEP
float acc_detector_presence_config_inter_frame_deviation_time_const_get(const acc_detector_presence_config_t *presence_config)
Get the time constant of the low pass filter for the inter-frame deviation between fast and slow.
acc_ref_app_smart_presence_zone_config_t nominal_config
acc_smart_presence_zone_result_t * zone_results
void acc_detector_presence_config_intra_detection_set(acc_detector_presence_config_t *presence_config, bool enable)
Set intra-frame presence detection.
@ SMART_PRESENCE_MODE_WAKEUP
float * depthwise_inter_presence_scores
void acc_hal_integration_sensor_disable(acc_sensor_id_t sensor_id)
Disable sensor.
#define SENSOR_TIMEOUT_MS
struct acc_detector_presence_config acc_detector_presence_config_t
static uint16_t get_max_num_points(app_context_t *context)
presence_detector_context_t wakeup_context
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.
bool acc_sensor_hibernate_on(acc_sensor_t *sensor)
Prepare sensor for entering hibernation.
static uint32_t get_max_buffer_size(app_context_t *context)
static bool process_detector_result(app_context_t *context, acc_detector_presence_result_t *presence_result, acc_smart_presence_result_t *result, bool *swap_needed, smart_presence_mode_t *new_mode)
void acc_sensor_status(const acc_sensor_t *sensor)
Check the status of the sensor.
@ SMART_PRESENCE_PRESET_CONFIG_CEILING
static bool determine_config_swap(app_context_t *context, acc_smart_presence_result_t *result, smart_presence_mode_t *new_mode)
#define DEFAULT_PRESET_CONFIG
float acc_detector_presence_config_frame_rate_get(const acc_detector_presence_config_t *presence_config)
Get the frame rate.
presence_detector_context_t nominal_context
uint32_t current_num_zones
void acc_integration_mem_free(void *ptr)
Free dynamic memory.
void acc_integration_sleep_until_periodic_wakeup(void)
Put the system in sleep until the periodic timer triggers.
static int32_t process_inter_intra(app_context_t *context, acc_detector_presence_result_t *presence_result, acc_smart_presence_result_t *result, bool inter)
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.
float acc_detector_presence_config_intra_detection_threshold_get(const acc_detector_presence_config_t *presence_config)
Get the detection threshold for the intra-frame presence detection.
static bool initialize_sensor(app_context_t *context)
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.
bool show_all_detected_zones
float acc_detector_presence_config_intra_frame_time_const_get(const acc_detector_presence_config_t *presence_config)
Get the time constant for the depthwise filtering in the intra-frame part.
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.
float acc_detector_presence_config_intra_output_time_const_get(const acc_detector_presence_config_t *presence_config)
Get the time constant for the output in the intra-frame part.
smart_presence_preset_config_t
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_detector_presence_config_t * presence_config
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.
static void cleanup(app_context_t *context)
struct acc_sensor acc_sensor_t
@ SMART_PRESENCE_PRESET_CONFIG_LOW_POWER_WAKEUP
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_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.
Smart presence reference application results container.
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.