If you want to use BLDC with FUTABA without going backward, use it

Dependencies:   mbed Servo Pulse1

Map.cpp

Committer:
kyucheol
Date:
2019-12-20
Revision:
0:b806d9855f21

File content as of revision 0:b806d9855f21:

#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);
}