lhrhost.util.math module

Various functions to simplify math calculations.

Summary

Functions

map_value

Maps a value from an input range to a target range.

map_value

lhrhost.util.math.map_value(x, in_min, in_max, out_min, out_max)[source]

Maps a value from an input range to a target range.

Equivalent to Arduino’s map function.

Parameters
  • x (Union[int, float]) – the value to map.

  • in_min (Union[int, float]) – the lower bound of the value’s current range.

  • in_max (Union[int, float]) – the upper bound of the value’s current range.

  • out_min (Union[int, float]) – the lower bound of the value’s target range.

  • out_max (Union[int, float]) – the upper bound of the value’s target range.

Return type

float

Returns

The mapped value in the target range.