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

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

Go to the source code of this file.

Macros

#define RESCALE(input, input_min, input_max, output_min, 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)