ref_app_breathing.c File Reference
#include <complex.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "acc_alg_basic_utils.h"
#include "acc_algorithm.h"
#include "acc_detector_presence.h"
#include "acc_integration.h"
#include "ref_app_breathing.h"

Go to the source code of this file.

Data Structures

struct  ref_app_breathing_handle
 

Macros

#define B_STATIC_LENGTH   (3U)
 
#define A_STATIC_LENGTH   (2U)
 
#define B_ANGLE_LENGTH   (5U)
 
#define A_ANGLE_LENGTH   (4U)
 

Functions

static bool validate_config (ref_app_breathing_config_t *config)
 
static void determine_state (ref_app_breathing_handle_t *handle, acc_detector_presence_result_t *presence_result)
 
static void update_presence_distance (ref_app_breathing_handle_t *handle, float presence_distance)
 
static bool reinit_breathing (ref_app_breathing_handle_t *handle, uint16_t start_point, uint16_t end_point)
 
static bool perform_action_based_on_state (ref_app_breathing_handle_t *handle, acc_int16_complex_t *frame, ref_app_breathing_result_t *result)
 
static bool process_breathing (ref_app_breathing_handle_t *handle, acc_int16_complex_t *frame, ref_app_breathing_result_t *result)
 
ref_app_breathing_config_tref_app_breathing_config_create (void)
 Create a configuration for the ref app breathing. More...
 
void ref_app_breathing_config_destroy (ref_app_breathing_config_t *config)
 Destory a configuration for the ref app breathing. More...
 
ref_app_breathing_handle_tref_app_breathing_create (ref_app_breathing_config_t *config)
 Create a handle for the ref app breathing. More...
 
void ref_app_breathing_destroy (ref_app_breathing_handle_t *handle)
 Destroy a handle for the ref app breathing. More...
 
bool ref_app_breathing_get_buffer_size (ref_app_breathing_handle_t *handle, uint32_t *buffer_size)
 Get the buffer size needed for the provided ref app breathing handle. More...
 
bool ref_app_breathing_prepare (ref_app_breathing_handle_t *handle, ref_app_breathing_config_t *config, acc_sensor_t *sensor, const acc_cal_result_t *sensor_cal_result, void *buffer, uint32_t buffer_size)
 Prepare the application to do a measurement. More...
 
bool ref_app_breathing_process (ref_app_breathing_handle_t *handle, void *buffer, ref_app_breathing_result_t *result)
 Process the data. More...
 

Macro Definition Documentation

◆ A_ANGLE_LENGTH

#define A_ANGLE_LENGTH   (4U)

Definition at line 21 of file ref_app_breathing.c.

◆ A_STATIC_LENGTH

#define A_STATIC_LENGTH   (2U)

Definition at line 19 of file ref_app_breathing.c.

◆ B_ANGLE_LENGTH

#define B_ANGLE_LENGTH   (5U)

Definition at line 20 of file ref_app_breathing.c.

◆ B_STATIC_LENGTH

#define B_STATIC_LENGTH   (3U)

Definition at line 18 of file ref_app_breathing.c.

Function Documentation

◆ determine_state()

static void determine_state ( ref_app_breathing_handle_t handle,
acc_detector_presence_result_t presence_result 
)
static

Definition at line 426 of file ref_app_breathing.c.

◆ perform_action_based_on_state()

static bool perform_action_based_on_state ( ref_app_breathing_handle_t handle,
acc_int16_complex_t frame,
ref_app_breathing_result_t result 
)
static

Definition at line 490 of file ref_app_breathing.c.

◆ process_breathing()

static bool process_breathing ( ref_app_breathing_handle_t handle,
acc_int16_complex_t frame,
ref_app_breathing_result_t result 
)
static

Definition at line 555 of file ref_app_breathing.c.

◆ ref_app_breathing_config_create()

ref_app_breathing_config_t* ref_app_breathing_config_create ( void  )

Create a configuration for the ref app breathing.

Returns
A configuration for the ref app breathing, NULL if creation was not possible

Definition at line 100 of file ref_app_breathing.c.

◆ ref_app_breathing_config_destroy()

void ref_app_breathing_config_destroy ( ref_app_breathing_config_t config)

Destory a configuration for the ref app breathing.

Parameters
[in]configThe configuration to destroy

Definition at line 143 of file ref_app_breathing.c.

◆ ref_app_breathing_create()

ref_app_breathing_handle_t* ref_app_breathing_create ( ref_app_breathing_config_t config)

Create a handle for the ref app breathing.

Parameters
[in]configThe configuration to create the handle with
Returns
A handle for the ref app breathing, NULL if creation was not possible

Definition at line 156 of file ref_app_breathing.c.

◆ ref_app_breathing_destroy()

void ref_app_breathing_destroy ( ref_app_breathing_handle_t handle)

Destroy a handle for the ref app breathing.

Parameters
[in]handleThe ref app breathing handle to destroy

Definition at line 265 of file ref_app_breathing.c.

◆ ref_app_breathing_get_buffer_size()

bool ref_app_breathing_get_buffer_size ( ref_app_breathing_handle_t handle,
uint32_t *  buffer_size 
)

Get the buffer size needed for the provided ref app breathing handle.

Parameters
[in]handleThe ref app breathing handle to to get the buffer size for
[out]buffer_sizeThe buffer size
Returns
true if successful, false otherwise

Definition at line 353 of file ref_app_breathing.c.

◆ ref_app_breathing_prepare()

bool ref_app_breathing_prepare ( ref_app_breathing_handle_t handle,
ref_app_breathing_config_t config,
acc_sensor_t sensor,
const acc_cal_result_t sensor_cal_result,
void *  buffer,
uint32_t  buffer_size 
)

Prepare the application to do a measurement.

Parameters
[in]handleThe ref app breathing handle to prepare for
[in]configThe configuration to prepare with
[in]sensorThe sensor instance to prepare
[in]sensor_cal_resultThe calibration result to prepare with
[in]bufferMemory used by the application to prepare the sensor for measurements The buffer will only be used during the duration of this call
[in]buffer_sizeThe size in bytes of the buffer, should be at least buffer_size from ref_app_breathing_get_buffer_size
Returns
true if successful, false otherwise

Definition at line 358 of file ref_app_breathing.c.

◆ ref_app_breathing_process()

bool ref_app_breathing_process ( ref_app_breathing_handle_t handle,
void *  buffer,
ref_app_breathing_result_t result 
)

Process the data.

Parameters
[in]handleThe ref app breathing handle for to get the next result for
[in]bufferA reference to the buffer (populated by acc_sensor_read) containing the data to be processed.
[out]resultRef app breathing results
Returns
true if successful, otherwise false

Definition at line 368 of file ref_app_breathing.c.

◆ reinit_breathing()

static bool reinit_breathing ( ref_app_breathing_handle_t handle,
uint16_t  start_point,
uint16_t  end_point 
)
static

Definition at line 467 of file ref_app_breathing.c.

◆ update_presence_distance()

static void update_presence_distance ( ref_app_breathing_handle_t handle,
float  presence_distance 
)
static

Definition at line 450 of file ref_app_breathing.c.

◆ validate_config()

static bool validate_config ( ref_app_breathing_config_t config)
static

Definition at line 399 of file ref_app_breathing.c.