mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-14 20:56:38 +01:00
add mapping method, equivalent to arduino map()
This commit is contained in:
@@ -3,4 +3,9 @@
|
||||
|
||||
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(array[0])
|
||||
|
||||
static long mapValueToRange(long x, long in_min, long in_max, long out_min, long out_max)
|
||||
{
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user