If you want to use BLDC with FUTABA without going backward, use it
Dependencies: mbed Servo Pulse1
Diff: Map.cpp
- Revision:
- 0:b806d9855f21
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Map.cpp Fri Dec 20 07:32:15 2019 +0000 @@ -0,0 +1,21 @@ +#include "Map.h" +//#include "mbed.h" + +float map(float in, float inMin, float inMax, float outMin, float outMax) { + // check it's within the range + if (inMin<inMax) { + if (in <= inMin) + return outMin; + if (in >= inMax) + return outMax; + } else { // cope with input range being backwards. + if (in >= inMin) + return outMin; + if (in <= inMax) + return outMax; + } + // calculate how far into the range we are + float scale = (in-inMin)/(inMax-inMin); + // calculate the output. + return outMin + scale*(outMax-outMin); +} \ No newline at end of file