Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo Pulse1
Map.cpp
00001 #include "Map.h" 00002 //#include "mbed.h" 00003 00004 float map(float in, float inMin, float inMax, float outMin, float outMax) { 00005 // check it's within the range 00006 if (inMin<inMax) { 00007 if (in <= inMin) 00008 return outMin; 00009 if (in >= inMax) 00010 return outMax; 00011 } else { // cope with input range being backwards. 00012 if (in >= inMin) 00013 return outMin; 00014 if (in <= inMax) 00015 return outMax; 00016 } 00017 // calculate how far into the range we are 00018 float scale = (in-inMin)/(inMax-inMin); 00019 // calculate the output. 00020 return outMin + scale*(outMax-outMin); 00021 }
Generated on Mon Aug 22 2022 07:49:54 by
1.7.2