7#ifndef _CAF_SENSOR_COMMON_H_
8#define _CAF_SENSOR_COMMON_H_
21#include <zephyr/drivers/sensor.h>
25#define FLOAT_TO_SENSOR_VAL_CONST 1000000
27#define FLOAT_TO_SENSOR_VALUE(float_val) \
29 .val1 = (int32_t)(float_val), \
30 .val2 = (int32_t)(((float_val) - (int32_t)(float_val)) * \
31 FLOAT_TO_SENSOR_VAL_CONST), \
54 struct sensor_value sensor_val2)
56 return ((sensor_val1.val1 > sensor_val2.val1) ||
57 ((sensor_val1.val1 == sensor_val2.val1) && (sensor_val1.val2 > sensor_val2.val2)));
68 struct sensor_value sensor_val2)
70 struct sensor_value result;
72 result.val1 = abs(sensor_val1.val1 - sensor_val2.val1);
73 result.val2 = abs(sensor_val1.val2 - sensor_val2.val2);
static struct sensor_value sensor_value_abs_difference(struct sensor_value sensor_val1, struct sensor_value sensor_val2)
Helper function for calculating absolute value of difference of two sensor_values.
Definition: caf_sensor_common.h:67
static bool sensor_value_greater_then(struct sensor_value sensor_val1, struct sensor_value sensor_val2)
Helper function for checking if one sensor_value is greater than the other.
Definition: caf_sensor_common.h:53
#define FLOAT_TO_SENSOR_VAL_CONST
Definition: caf_sensor_common.h:25
enum sensor_channel chan
Channel identifier.
Definition: caf_sensor_common.h:41
uint8_t data_cnt
Number of data samples in selected channel.
Definition: caf_sensor_common.h:43
Description of single channel.
Definition: caf_sensor_common.h:39