GY-63_MS5611/libraries/FastMap/FastMap.h

45 lines
979 B
C
Raw Normal View History

2014-11-02 11:24:21 -05:00
//
// FILE: FastMap.h
// AUTHOR: Rob Tillaart
2017-07-27 09:26:36 -04:00
// VERSION: 0.1.8
// PURPOSE: class with fast map function - library for Arduino
2014-11-02 11:24:21 -05:00
// URL: http://forum.arduino.cc/index.php?topic=276194
//
// HISTORY:
// see FastMap.cpp file
2014-11-02 11:24:21 -05:00
//
#ifndef FastMap_h
#define FastMap_h
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
2017-07-27 09:26:36 -04:00
#define FASTMAP_LIB_VERSION (F("0.1.8"))
2014-11-02 11:24:21 -05:00
class FastMap
{
public:
FastMap();
2014-11-02 11:24:21 -05:00
2017-07-27 09:26:36 -04:00
void init(const float in_min, const float in_max, const float out_min, const float out_max);
2017-07-27 09:26:36 -04:00
float inline map (const float value) { return _base + value * _factor; }
float inline back (const float value) { return _backbase + value * _backfactor; }
2017-07-27 09:26:36 -04:00
float constrainedMap(const float value);
float lowerConstrainedMap(const float value);
float upperConstrainedMap(const float value);
2014-11-02 11:24:21 -05:00
private:
2017-07-27 09:26:36 -04:00
float _in_min, _in_max, _out_min, _out_max;
float _factor, _base;
float _backfactor, _backbase;
2014-11-02 11:24:21 -05:00
};
#endif
2017-07-27 09:26:36 -04:00
// END OF FILE