Data Structures | Macros | Enumerations | Functions
ref_app_tank_level.c File Reference
`#include <math.h>`
`#include <stdbool.h>`
`#include <stdint.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include "acc_definitions_a121.h"`
`#include "acc_detector_distance.h"`
`#include "acc_hal_definitions_a121.h"`
`#include "acc_hal_integration_a121.h"`
`#include "acc_integration.h"`
`#include "acc_integration_log.h"`
`#include "acc_rss_a121.h"`
`#include "acc_sensor.h"`
`#include "acc_version.h"`

Go to the source code of this file.

## Data Structures
struct | acc_ref_app_tank_level_config_t
struct | app_context_t
struct | app_result_t

## Macros
#define | SENSOR_ID 1U
#define | SENSOR_TIMEOUT_MS 1000U
#define | DEFAULT_UPDATE_RATE 1.0f
#define | SMALL_TANK_MEDIAN_FILTER_LENGTH 5U
#define | SMALL_TANK_NUM_MEDIANS_TO_AVERAGE 5U
#define | SMALL_TANK_RANGE_START_M 0.03f
#define | SMALL_TANK_RANGE_END_M 0.5f
#define | SMALL_TANK_MAX_STEP_LENGTH 2U
#define | SMALL_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_2
#define | SMALL_TANK_NUM_FRAMES_REC 50U
#define | SMALL_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST
#define | SMALL_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
#define | SMALL_TANK_THRESHOLD_SENSITIVITY 0.0f
#define | SMALL_TANK_SIGNAL_QUALITY 20.0f
#define | SMALL_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true
#define | MEDIUM_TANK_MEDIAN_FILTER_LENGTH 3U
#define | MEDIUM_TANK_NUM_MEDIANS_TO_AVERAGE 3U
#define | MEDIUM_TANK_RANGE_START_M 0.05f
#define | MEDIUM_TANK_RANGE_END_M 6.0f
#define | MEDIUM_TANK_MAX_STEP_LENGTH 0U
#define | MEDIUM_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_3
#define | MEDIUM_TANK_NUM_FRAMES_REC 50U
#define | MEDIUM_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
#define | MEDIUM_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
#define | MEDIUM_TANK_THRESHOLD_SENSITIVITY 0.0f
#define | MEDIUM_TANK_SIGNAL_QUALITY 20.0f
#define | MEDIUM_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true
#define | LARGE_TANK_MEDIAN_FILTER_LENGTH 3U
#define | LARGE_TANK_NUM_MEDIANS_TO_AVERAGE 1U
#define | LARGE_TANK_RANGE_START_M 0.1f
#define | LARGE_TANK_RANGE_END_M 10.0f
#define | LARGE_TANK_MAX_STEP_LENGTH 0U
#define | LARGE_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_5
#define | LARGE_TANK_NUM_FRAMES_REC 50U
#define | LARGE_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST
#define | LARGE_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR
#define | LARGE_TANK_THRESHOLD_SENSITIVITY 0.0f
#define | LARGE_TANK_SIGNAL_QUALITY 20.0f
#define | LARGE_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true
#define | DEFAULT_PRESET_CONFIG TANK_LEVEL_PRESET_CONFIG_SMALL_TANK

## Enumerations
enum | tank_level_preset_config_t { TANK_LEVEL_PRESET_CONFIG_NONE = 0, TANK_LEVEL_PRESET_CONFIG_SMALL_TANK, TANK_LEVEL_PRESET_CONFIG_MEDIUM_TANK, TANK_LEVEL_PRESET_CONFIG_LARGE_TANK }
enum | peak_status_t { PEAK_STATUS_IN_RANGE, PEAK_STATUS_NO_DETECTION, PEAK_STATUS_OVERFLOW, PEAK_STATUS_OUT_OF_RANGE }

## Functions
static void | cleanup (app_context_t *context)
static float | get_detector_start_m (acc_ref_app_tank_level_config_t *app_config)
static float | get_detector_end_m (acc_ref_app_tank_level_config_t *app_config)
static void | set_config (acc_ref_app_tank_level_config_t *app_config, tank_level_preset_config_t preset)
static bool | initialize_application_resources (app_context_t *context)
static bool | sensor_calibration (acc_sensor_t *sensor, acc_cal_result_t *cal_result, void *buffer, uint32_t buffer_size)
static bool | full_detector_calibration (app_context_t *context, const acc_cal_result_t *sensor_cal_result)
static bool | detector_recalibration (app_context_t *context, const acc_cal_result_t *sensor_cal_result)
static bool | detector_get_next (app_context_t *context, const acc_cal_result_t *sensor_cal_result, acc_detector_distance_result_t *detector_result)
static void | swap (float *array, uint16_t idx_a, uint16_t idx_b)
static void | sort (float *array, uint16_t array_length)
static float | median (float *array, uint16_t array_length)
static float | nanmean (float *array, uint16_t array_length)
static void | process_detector_result (const acc_detector_distance_result_t *distance_result, app_result_t *app_result, app_context_t *context)
static void | print_result (const app_result_t *app_result, const acc_ref_app_tank_level_config_t *app_config)
int | acconeer_main (int argc, char *argv[])
| Assembly test example. More...

## Macro Definition Documentation

## ◆ DEFAULT_PRESET_CONFIG

#define DEFAULT_PRESET_CONFIG TANK_LEVEL_PRESET_CONFIG_SMALL_TANK

Examples
  ref_app_tank_level.c.

Definition at line 106 of file ref_app_tank_level.c.

## ◆ DEFAULT_UPDATE_RATE

#define DEFAULT_UPDATE_RATE 1.0f

Examples
  ref_app_tank_level.c.

Definition at line 26 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION

#define LARGE_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true

Examples
  ref_app_tank_level.c.

Definition at line 68 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_MAX_PROFILE

#define LARGE_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_5

Examples
  ref_app_tank_level.c.

Definition at line 62 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_MAX_STEP_LENGTH

#define LARGE_TANK_MAX_STEP_LENGTH 0U

Examples
  ref_app_tank_level.c.

Definition at line 61 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_MEDIAN_FILTER_LENGTH

#define LARGE_TANK_MEDIAN_FILTER_LENGTH 3U

Examples
  ref_app_tank_level.c.

Definition at line 57 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_NUM_FRAMES_REC

#define LARGE_TANK_NUM_FRAMES_REC 50U

Examples
  ref_app_tank_level.c.

Definition at line 63 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_NUM_MEDIANS_TO_AVERAGE

#define LARGE_TANK_NUM_MEDIANS_TO_AVERAGE 1U

Examples
  ref_app_tank_level.c.

Definition at line 58 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_PEAK_SORTING

#define LARGE_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST

Examples
  ref_app_tank_level.c.

Definition at line 64 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_RANGE_END_M

#define LARGE_TANK_RANGE_END_M 10.0f

Examples
  ref_app_tank_level.c.

Definition at line 60 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_RANGE_START_M

#define LARGE_TANK_RANGE_START_M 0.1f

Examples
  ref_app_tank_level.c.

Definition at line 59 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_REFLECTOR_SHAPE

#define LARGE_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR

Examples
  ref_app_tank_level.c.

Definition at line 65 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_SIGNAL_QUALITY

#define LARGE_TANK_SIGNAL_QUALITY 20.0f

Examples
  ref_app_tank_level.c.

Definition at line 67 of file ref_app_tank_level.c.

## ◆ LARGE_TANK_THRESHOLD_SENSITIVITY

#define LARGE_TANK_THRESHOLD_SENSITIVITY 0.0f

Examples
  ref_app_tank_level.c.

Definition at line 66 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION

#define MEDIUM_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true

Examples
  ref_app_tank_level.c.

Definition at line 54 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_MAX_PROFILE

#define MEDIUM_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_3

Examples
  ref_app_tank_level.c.

Definition at line 48 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_MAX_STEP_LENGTH

#define MEDIUM_TANK_MAX_STEP_LENGTH 0U

Examples
  ref_app_tank_level.c.

Definition at line 47 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_MEDIAN_FILTER_LENGTH

#define MEDIUM_TANK_MEDIAN_FILTER_LENGTH 3U

Examples
  ref_app_tank_level.c.

Definition at line 43 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_NUM_FRAMES_REC

#define MEDIUM_TANK_NUM_FRAMES_REC 50U

Examples
  ref_app_tank_level.c.

Definition at line 49 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_NUM_MEDIANS_TO_AVERAGE

#define MEDIUM_TANK_NUM_MEDIANS_TO_AVERAGE 3U

Examples
  ref_app_tank_level.c.

Definition at line 44 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_PEAK_SORTING

#define MEDIUM_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_STRONGEST

Examples
  ref_app_tank_level.c.

Definition at line 50 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_RANGE_END_M

#define MEDIUM_TANK_RANGE_END_M 6.0f

Examples
  ref_app_tank_level.c.

Definition at line 46 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_RANGE_START_M

#define MEDIUM_TANK_RANGE_START_M 0.05f

Examples
  ref_app_tank_level.c.

Definition at line 45 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_REFLECTOR_SHAPE

#define MEDIUM_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR

Examples
  ref_app_tank_level.c.

Definition at line 51 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_SIGNAL_QUALITY

#define MEDIUM_TANK_SIGNAL_QUALITY 20.0f

Examples
  ref_app_tank_level.c.

Definition at line 53 of file ref_app_tank_level.c.

## ◆ MEDIUM_TANK_THRESHOLD_SENSITIVITY

#define MEDIUM_TANK_THRESHOLD_SENSITIVITY 0.0f

Examples
  ref_app_tank_level.c.

Definition at line 52 of file ref_app_tank_level.c.

## ◆ SENSOR_ID

#define SENSOR_ID 1U

Examples
  ref_app_tank_level.c.

Definition at line 24 of file ref_app_tank_level.c.

## ◆ SENSOR_TIMEOUT_MS

#define SENSOR_TIMEOUT_MS 1000U

Examples
  ref_app_tank_level.c.

Definition at line 25 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION

#define SMALL_TANK_CLOSE_RANGE_LEAKAGE_CANCELLATION true

Examples
  ref_app_tank_level.c.

Definition at line 40 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_MAX_PROFILE

#define SMALL_TANK_MAX_PROFILE ACC_CONFIG_PROFILE_2

Examples
  ref_app_tank_level.c.

Definition at line 34 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_MAX_STEP_LENGTH

#define SMALL_TANK_MAX_STEP_LENGTH 2U

Examples
  ref_app_tank_level.c.

Definition at line 33 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_MEDIAN_FILTER_LENGTH

#define SMALL_TANK_MEDIAN_FILTER_LENGTH 5U

Examples
  ref_app_tank_level.c.

Definition at line 29 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_NUM_FRAMES_REC

#define SMALL_TANK_NUM_FRAMES_REC 50U

Examples
  ref_app_tank_level.c.

Definition at line 35 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_NUM_MEDIANS_TO_AVERAGE

#define SMALL_TANK_NUM_MEDIANS_TO_AVERAGE 5U

Examples
  ref_app_tank_level.c.

Definition at line 30 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_PEAK_SORTING

#define SMALL_TANK_PEAK_SORTING ACC_DETECTOR_DISTANCE_PEAK_SORTING_CLOSEST

Examples
  ref_app_tank_level.c.

Definition at line 36 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_RANGE_END_M

#define SMALL_TANK_RANGE_END_M 0.5f

Examples
  ref_app_tank_level.c.

Definition at line 32 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_RANGE_START_M

#define SMALL_TANK_RANGE_START_M 0.03f

Examples
  ref_app_tank_level.c.

Definition at line 31 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_REFLECTOR_SHAPE

#define SMALL_TANK_REFLECTOR_SHAPE ACC_DETECTOR_DISTANCE_REFLECTOR_SHAPE_PLANAR

Examples
  ref_app_tank_level.c.

Definition at line 37 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_SIGNAL_QUALITY

#define SMALL_TANK_SIGNAL_QUALITY 20.0f

Examples
  ref_app_tank_level.c.

Definition at line 39 of file ref_app_tank_level.c.

## ◆ SMALL_TANK_THRESHOLD_SENSITIVITY

#define SMALL_TANK_THRESHOLD_SENSITIVITY 0.0f

Examples
  ref_app_tank_level.c.

Definition at line 38 of file ref_app_tank_level.c.

## Enumeration Type Documentation

## ◆ peak_status_t

enum peak_status_t

Enumerator
PEAK_STATUS_IN_RANGE |
PEAK_STATUS_NO_DETECTION |
PEAK_STATUS_OVERFLOW |
PEAK_STATUS_OUT_OF_RANGE |

Examples
  ref_app_tank_level.c.

Definition at line 137 of file ref_app_tank_level.c.

## ◆ tank_level_preset_config_t

enum tank_level_preset_config_t

Enumerator
TANK_LEVEL_PRESET_CONFIG_NONE |
TANK_LEVEL_PRESET_CONFIG_SMALL_TANK |
TANK_LEVEL_PRESET_CONFIG_MEDIUM_TANK |
TANK_LEVEL_PRESET_CONFIG_LARGE_TANK |

Examples
  ref_app_tank_level.c.

Definition at line 98 of file ref_app_tank_level.c.

## Function Documentation

## ◆ acconeer_main()

int acconeer_main | ( | int | argc,
|  | char * | argv[]
| ) |  |

Assembly test example.

Surface velocity example application.

Tank level reference application.

Smart presence reference application.

Breathing example application.

Service subsweeps example.

Service multple configurations example.

Low power service example.

Service example.

Processing subtract adaptive background example.

Processing static presence example.

Processing peak interpolation example.

Processing noncoherent mean example.

Processing coherent mean example.

Processing amplitude example.

Detector presence example with multiple configurations.

Low power detector presence example.

Detector presence example.

Distance detector low power example.

Detector distance example.

Control helper example.

Returns
  Returns EXIT_SUCCESS if successful, otherwise EXIT_FAILURE

Test if measure on wake up is enable Do a measurement if the the detector is ready (configured and calibrated)

Test if measure on wake up is enable Do a measurement if the the detector is ready (configured and calibrated)

Detector filters and states are reset on prepare (reconfiguration) to avoid risk of false detections when switching back to a zone.

Detector filters and states are reset on prepare (reconfiguration) to avoid risk of false detections when switching back to a zone.

Examples
  ref_app_tank_level.c.

Definition at line 210 of file ref_app_tank_level.c.

## ◆ cleanup()

static void cleanup | ( | app_context_t * | context | ) |
| static

Examples
  ref_app_tank_level.c.

Definition at line 334 of file ref_app_tank_level.c.

## ◆ detector_get_next()

static bool detector_get_next | ( | app_context_t * | context,
|  | const acc_cal_result_t * | sensor_cal_result,
|  | acc_detector_distance_result_t * | detector_result
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 575 of file ref_app_tank_level.c.

## ◆ detector_recalibration()

static bool detector_recalibration | ( | app_context_t * | context,
|  | const acc_cal_result_t * | sensor_cal_result
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 553 of file ref_app_tank_level.c.

## ◆ full_detector_calibration()

static bool full_detector_calibration | ( | app_context_t * | context,
|  | const acc_cal_result_t * | sensor_cal_result
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 531 of file ref_app_tank_level.c.

## ◆ get_detector_end_m()

static float get_detector_end_m | ( | acc_ref_app_tank_level_config_t * | app_config | ) |
| static

Examples
  ref_app_tank_level.c.

Definition at line 361 of file ref_app_tank_level.c.

## ◆ get_detector_start_m()

static float get_detector_start_m | ( | acc_ref_app_tank_level_config_t * | app_config | ) |
| static

Examples
  ref_app_tank_level.c.

Definition at line 354 of file ref_app_tank_level.c.

## ◆ initialize_application_resources()

static bool initialize_application_resources | ( | app_context_t * | context | ) |
| static

Examples
  ref_app_tank_level.c.

Definition at line 432 of file ref_app_tank_level.c.

## ◆ median()

static float median | ( | float * | array,
|  | uint16_t | array_length
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 645 of file ref_app_tank_level.c.

## ◆ nanmean()

static float nanmean | ( | float * | array,
|  | uint16_t | array_length
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 679 of file ref_app_tank_level.c.

## ◆ print_result()

static void print_result | ( | const app_result_t * | app_result,
|  | const acc_ref_app_tank_level_config_t * | app_config
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 775 of file ref_app_tank_level.c.

## ◆ process_detector_result()

static void process_detector_result | ( | const acc_detector_distance_result_t * | distance_result,
|  | app_result_t * | app_result,
|  | app_context_t * | context
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 697 of file ref_app_tank_level.c.

## ◆ sensor_calibration()

static bool sensor_calibration | ( | acc_sensor_t * | sensor,
|  | acc_cal_result_t * | cal_result,
|  | void * | buffer,
|  | uint32_t | buffer_size
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 488 of file ref_app_tank_level.c.

## ◆ set_config()

static void set_config | ( | acc_ref_app_tank_level_config_t * | app_config,
|  | tank_level_preset_config_t | preset
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 368 of file ref_app_tank_level.c.

## ◆ sort()

static void sort | ( | float * | array,
|  | uint16_t | array_length
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 630 of file ref_app_tank_level.c.

## ◆ swap()

static void swap | ( | float * | array,
|  | uint16_t | idx_a,
|  | uint16_t | idx_b
| ) |  |
| static

Examples
  ref_app_tank_level.c.

Definition at line 621 of file ref_app_tank_level.c.