Data Structures | Macros | Functions
example_waste_level.c File Reference
`#include <complex.h>`
`#include <inttypes.h>`
`#include <math.h>`
`#include <stdbool.h>`
`#include <stddef.h>`
`#include <stdint.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include "acc_algorithm.h"`
`#include "acc_config.h"`
`#include "acc_config_subsweep.h"`
`#include "acc_definitions_common.h"`
`#include "acc_integration.h"`
`#include "acc_integration_log.h"`
`#include "acc_processing.h"`
`#include "example_waste_level.h"`

Go to the source code of this file.

## Data Structures
struct | waste_level_handle

## Macros
#define | MODULE "example_waste_level"

## Functions
static bool | validate_app_config (const waste_level_app_config_t *app_config)
| Validate an app_config (processing & sensor config). More...
static bool | subsweep_start_points_strictly_increases (const acc_config_t *sensor_config)
| Helper function for validation. More...
static bool | has_overlapping_subsweeps (const acc_config_t *sensor_config, uint8_t *offending_subsweep)
| Helper function for validation. More...
static bool | is_invalid_start_point (const acc_config_t *sensor_config)
| Helper function for validation. More...
static bool | is_outside_measuring_interval (const acc_config_t *sensor_config, float distance_m)
| Helper function for validation. More...
static float | subsweep_approx_start_m (const acc_config_t *sensor_config, uint8_t subsweep_idx)
| Helper function for validation. More...
static float | subsweep_approx_end_m (const acc_config_t *sensor_config, uint8_t subsweep_idx)
| Helper function for validation. More...
static float | point_in_sweep_to_distance_m (const acc_config_t *sensor_config, const acc_processing_metadata_t *metadata, uint16_t point_idx)
| Calculate a point's corresponding distance in meters. More...
static void | write_to_ring_buffer (float *buffer, uint16_t capacity, uint16_t *length, uint16_t *write_idx, float elem)
| Write next value into a ring buffer. More...
static uint16_t | copy_non_nan_floats (const float *in, float *out, uint16_t length)
| Copy non-NaN floats between buffers. More...
static void | set_level_numbers (float filtered_distance, const waste_level_processing_config_t *processing_config, waste_level_result_t *result)
| Populate a waste level result with its human-readable entries. More...
waste_level_app_config_t * | waste_level_app_config_create (void)
| Create a waste level app config (includes an acc_config_t) More...
void | waste_level_app_config_destroy (waste_level_app_config_t *app_config)
| Destroy a waste level app config. More...
void | waste_level_app_config_set_preset (waste_level_preset_t preset, waste_level_app_config_t *app_config)
| Apply a preset to an app config. More...
waste_level_handle_t * | waste_level_handle_create (const waste_level_app_config_t *app_config)
| Create a waste level handle. More...
void | waste_level_handle_destroy (waste_level_handle_t *handle)
| Destroy a waste level handle. More...
void | waste_level_process (waste_level_handle_t *handle, const waste_level_app_config_t *app_config, const acc_processing_metadata_t *metadata, const acc_int16_complex_t *frame, waste_level_result_t *waste_level_result)
| Process Sparse IQ data. More...
void | waste_level_processing_config_log (const waste_level_processing_config_t *config)
| Log a waste level config. More...

## Macro Definition Documentation

## ◆ MODULE

#define MODULE "example_waste_level"

Definition at line 25 of file example_waste_level.c.

## Function Documentation

## ◆ copy_non_nan_floats()

static uint16_t copy_non_nan_floats | ( | const float * | in,
|  | float * | out,
|  | uint16_t | length
| ) |  |
| static

Copy non-NaN floats between buffers.

Parameters

  [in] | in | Source buffer of floats which can contain NaNs
  [out] | out | The destination buffer. Will not contain NaNs
  [in] | length | The allocated size of in & out

Returns
  The number of elements written to out

Definition at line 580 of file example_waste_level.c.

## ◆ has_overlapping_subsweeps()

static bool has_overlapping_subsweeps | ( | const acc_config_t * | sensor_config,
|  | uint8_t * | offending_subsweep
| ) |  |
| static

Helper function for validation.

Parameters

  [in] | sensor_config | The sensor config
  [out] | offending_subsweep | The subsweep index of a subsweep that overlaps into the subsweep after it

Returns
  True if sensor config has overlapping (in distance) subsweeps, false otherwise

Definition at line 473 of file example_waste_level.c.

## ◆ is_invalid_start_point()

static bool is_invalid_start_point | ( | const acc_config_t * | sensor_config | ) |
| static

Helper function for validation.

Parameters

  [in] | sensor_config | The sensor config

Returns
  True if start_point for subsweep 0 is invalid

Definition at line 494 of file example_waste_level.c.

## ◆ is_outside_measuring_interval()

static bool is_outside_measuring_interval | ( | const acc_config_t * | sensor_config,
|  | float | distance_m
| ) |  |
| static

Helper function for validation.

Parameters

  [in] | sensor_config | The sensor config
  [in] | distance_m | The distance to check

Returns
  True if distance_m is outside the interval measured by sensor_config, false otherwise

Definition at line 503 of file example_waste_level.c.

## ◆ point_in_sweep_to_distance_m()

static float point_in_sweep_to_distance_m | ( | const acc_config_t * | sensor_config,
|  | const acc_processing_metadata_t * | metadata,
|  | uint16_t | point_idx
| ) |  |
| static

Calculate a point's corresponding distance in meters.

Parameters

  [in] | sensor_config | The sensor config
  [in] | metadata | The processing metadata
  [in] | point_idx | The index in a sweep of the point to get distance for

Returns
  The distance of point at point_idx

Definition at line 545 of file example_waste_level.c.

## ◆ set_level_numbers()

static void set_level_numbers | ( | float | filtered_distance,
|  | const waste_level_processing_config_t * | processing_config,
|  | waste_level_result_t * | result
| ) |  |
| static

Populate a waste level result with its human-readable entries.

Parameters

  [in] | filtered_distance | The median filtered distance
  [in] | processing_config | The waste processing config
  [out] | result | The waste result

Definition at line 596 of file example_waste_level.c.

## ◆ subsweep_approx_end_m()

static float subsweep_approx_end_m | ( | const acc_config_t * | sensor_config,
|  | uint8_t | subsweep_idx
| ) |  |
| static

Helper function for validation.

Parameters

  [in] | sensor_config | The sensor config
  [in] | subsweep_idx | The distance to check

Returns
  The approximate distance to the last point measured in subsweep with index subsweep_idx

Definition at line 537 of file example_waste_level.c.

## ◆ subsweep_approx_start_m()

static float subsweep_approx_start_m | ( | const acc_config_t * | sensor_config,
|  | uint8_t | subsweep_idx
| ) |  |
| static

Helper function for validation.

Parameters

  [in] | sensor_config | The sensor config
  [in] | subsweep_idx | The distance to check

Returns
  The approximate distance to the first point measured in subsweep with index subsweep_idx

Definition at line 529 of file example_waste_level.c.

## ◆ subsweep_start_points_strictly_increases()

static bool subsweep_start_points_strictly_increases | ( | const acc_config_t * | sensor_config | ) |
| static

Helper function for validation.

Parameters

  [in] | sensor_config | The sensor config

Returns
  True if all subsweeps' start_points are strictly increasing, false otherwise

Definition at line 452 of file example_waste_level.c.

## ◆ validate_app_config()

static bool validate_app_config | ( | const waste_level_app_config_t * | app_config | ) |
| static

Validate an app_config (processing & sensor config).

Parameters

  [in] | app_config | The app config

Returns
  True if config was valid, false otherwise.

Definition at line 364 of file example_waste_level.c.

## ◆ waste_level_app_config_create()

waste_level_app_config_t* waste_level_app_config_create | ( | void |  | ) |

Create a waste level app config (includes an acc_config_t)

Definition at line 147 of file example_waste_level.c.

## ◆ waste_level_app_config_destroy()

void waste_level_app_config_destroy | ( | waste_level_app_config_t * | app_config | ) |

Destroy a waste level app config.

Parameters

  [in] | app_config | The config to destroy

Definition at line 166 of file example_waste_level.c.

## ◆ waste_level_app_config_set_preset()

void waste_level_app_config_set_preset | ( | waste_level_preset_t | preset,
|  | waste_level_app_config_t * | app_config
| ) |  |

Apply a preset to an app config.

Parameters

  [in] | preset | The preset
  [in] | app_config | The waste level app config

Definition at line 179 of file example_waste_level.c.

## ◆ waste_level_handle_create()

waste_level_handle_t* waste_level_handle_create | ( | const waste_level_app_config_t * | app_config | ) |

Create a waste level handle.

The handle is used only for processing

Parameters

  [in] | app_config | Waste level app configuration

Returns
  A waste_level handle, or NULL if creation failed

Definition at line 217 of file example_waste_level.c.

## ◆ waste_level_handle_destroy()

void waste_level_handle_destroy | ( | waste_level_handle_t * | handle | ) |

Destroy a waste level handle.

Parameters

  [in] | handle | The waste_level handle to destroy

Definition at line 257 of file example_waste_level.c.

## ◆ waste_level_process()

void waste_level_process | ( | waste_level_handle_t * | handle,
|  | const waste_level_app_config_t * | app_config,
|  | const acc_processing_metadata_t * | metadata,
|  | const acc_int16_complex_t * | frame,
|  | waste_level_result_t * | waste_level_result
| ) |  |

Process Sparse IQ data.

Parameters

  [in] | handle | The waste level handle
  [in] | app_config | The waste level app configuration handle was created with
  [in] | metadata | The processing metadata
  [in] | frame | The Sparse IQ frame
  [out] | waste_level_result | Result processed by waste_level

Definition at line 275 of file example_waste_level.c.

## ◆ waste_level_processing_config_log()

void waste_level_processing_config_log | ( | const waste_level_processing_config_t * | config | ) |

Log a waste level config.

Parameters

  [in] | config | The waste level config

Definition at line 354 of file example_waste_level.c.

## ◆ write_to_ring_buffer()

static void write_to_ring_buffer | ( | float * | buffer,
|  | uint16_t | capacity,
|  | uint16_t * | length,
|  | uint16_t * | write_idx,
|  | float | elem
| ) |  |
| static

Write next value into a ring buffer.

Parameters

  [in,out] | buffer | The circular buffer
  [in] | capacity | The allocated number of elements of buffer
  [in,out] | length | The buffer length (number of valid elements)
  [in,out] | write_idx | The next index in buffer to write to
  [in] | elem | The new element to write

Definition at line 568 of file example_waste_level.c.