PER Firmware
Loading...
Searching...
No Matches
rescale.h File Reference

Utility header to linearly map values from one range to another. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define RESCALE(input, input_min, input_max, output_min, output_max)
 

Functions

static float rescale_float (float input, float input_min, float input_max, float output_min, float output_max)
 
static signed int rescale_signed (signed int input, signed int input_min, signed int input_max, signed int output_min, signed int output_max)
 
static unsigned int rescale_unsigned (unsigned int input, unsigned int input_min, unsigned int input_max, unsigned int output_min, unsigned int output_max)
 

Detailed Description

Utility header to linearly map values from one range to another.

Typesafe, supporting ints and floats. Integer promotions also cover int8_t, uint8_t, int16_t, uint16_t

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ RESCALE

#define RESCALE ( input,
input_min,
input_max,
output_min,
output_max )
Value:
_Generic((input) + (input_min) + (input_max) + (output_min) + (output_max), \
signed int: rescale_signed, \
unsigned int: rescale_unsigned, \
float: rescale_float \
)(input, input_min, input_max, output_min, output_max)
static signed int rescale_signed(signed int input, signed int input_min, signed int input_max, signed int output_min, signed int output_max)
Definition rescale.h:34
static unsigned int rescale_unsigned(unsigned int input, unsigned int input_min, unsigned int input_max, unsigned int output_min, unsigned int output_max)
Definition rescale.h:53
static float rescale_float(float input, float input_min, float input_max, float output_min, float output_max)
Definition rescale.h:15

Function Documentation

◆ rescale_float()

static float rescale_float ( float input,
float input_min,
float input_max,
float output_min,
float output_max )
inlinestatic
Here is the caller graph for this function:

◆ rescale_signed()

static signed int rescale_signed ( signed int input,
signed int input_min,
signed int input_max,
signed int output_min,
signed int output_max )
inlinestatic
Here is the call graph for this function:

◆ rescale_unsigned()

static unsigned int rescale_unsigned ( unsigned int input,
unsigned int input_min,
unsigned int input_max,
unsigned int output_min,
unsigned int output_max )
inlinestatic
Here is the call graph for this function: