L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
mydefs.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ABS(x)
 Compute the absolute value of x without using math.h.
#define PRIf_02   "%d.%02d"
 printf format string for printing a float/double as integer with 2 decimal places. Use together with PRIf_02D to avoid floating-point printf on embedded targets.
#define PRIf_02D(fData)
 Expands to integer and fractional arguments for use with PRIf_02. Splits a float/double into the integer part and the two-digit fractional part.
#define CLAMP(val, minVal, maxVal)
 Clamp val to the closed interval [minVal, maxVal]. All three arguments are evaluated exactly once via temporary variables, avoiding double-evaluation side effects. Uses a GCC statement expression.

Macro Definition Documentation

◆ ABS

#define ABS ( x)
Value:
(((x) >= 0) ? (x) : -(x))

Compute the absolute value of x without using math.h.

Parameters
xAny numeric expression
Returns
Non-negative value of x

Definition at line 18 of file mydefs.h.

◆ CLAMP

#define CLAMP ( val,
minVal,
maxVal )
Value:
__extension__({ \
__typeof__(val) _v = (val); \
__typeof__(minVal) _min = (minVal); \
__typeof__(maxVal) _max = (maxVal); \
_v < _min ? _min : (_v > _max ? _max : _v); \
})

Clamp val to the closed interval [minVal, maxVal]. All three arguments are evaluated exactly once via temporary variables, avoiding double-evaluation side effects. Uses a GCC statement expression.

Parameters
valThe value to clamp
minValLower bound (inclusive)
maxValUpper bound (inclusive)
Returns
val if it is within [minVal, maxVal], minVal if val < minVal, or maxVal if val > maxVal

Definition at line 50 of file mydefs.h.

Referenced by systemParams_Correction().

◆ PRIf_02

#define PRIf_02   "%d.%02d"

printf format string for printing a float/double as integer with 2 decimal places. Use together with PRIf_02D to avoid floating-point printf on embedded targets.

Example:

float val = 3.14f;
printf("Value: " PRIf_02 "\n", PRIf_02D(val)); // prints "Value: 3.14"
#define PRIf_02D(fData)
Expands to integer and fractional arguments for use with PRIf_02. Splits a float/double into the inte...
Definition mydefs.h:38
#define PRIf_02
printf format string for printing a float/double as integer with 2 decimal places....
Definition mydefs.h:30

Definition at line 30 of file mydefs.h.

Referenced by amb_tsl2591_LogData(), bar_bmp585_LogData(), bar_ils22qs_LogData(), scd41_LogData(), sps30_LogData(), and tmphm_sht45_LogData().

◆ PRIf_02D

#define PRIf_02D ( fData)
Value:
(int)fData, ABS(((int)(fData * 100.0f) % 100))
#define ABS(x)
Compute the absolute value of x without using math.h.
Definition mydefs.h:18

Expands to integer and fractional arguments for use with PRIf_02. Splits a float/double into the integer part and the two-digit fractional part.

Parameters
fDataThe float or double value to format
Returns
Two comma-separated integer arguments: integer part and abs(fractional * 100)

Definition at line 38 of file mydefs.h.

Referenced by amb_tsl2591_LogData(), bar_bmp585_LogData(), bar_ils22qs_LogData(), scd41_LogData(), sps30_LogData(), and tmphm_sht45_LogData().