PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Utility
libsimpletools
source
mapFloat.c
1
/*
2
* @file mapFloat.c
3
*
4
* @author Andy Lindsay
5
*
6
* @version 1.1.8
7
*
8
* @copyright Copyright (C) Parallax, Inc. 2018. See end of file for
9
* terms of use (MIT License).
10
*
11
* @brief mapfloat function source, see simpletools.h for documentation.
12
*
13
* @detail Please submit bug reports, suggestions, and improvements to
14
* this code to editor@parallax.com.
15
*/
16
17
18
19
#include "
simpletools.h
"
20
21
float
mapFloat
(
float
value,
float
fromMin,
float
fromMax,
float
toMin,
float
toMax)
22
{
23
// n - numerator
24
// d - denomenator
25
26
float
n = (value - fromMin) * (toMax - toMin);
27
float
d = (fromMax - fromMin);
28
29
float
val = n / d;
30
31
return
val + toMin;
32
}
33
34
35
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
mapFloat
float mapFloat(float value, float fromMin, float fromMax, float toMin, float toMax)
Maps a floating point value from its position in one range to its corresponding. position in a differ...
Definition:
mapFloat.c:21
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17