Skip to content

Commit b3c0f3e

Browse files
committed
+ version 0.1.06
+ replaced float with double to support ARM (DUE) too
1 parent 740d030 commit b3c0f3e

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

libraries/FastMap/FastMap.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//
22
// FILE: FastMap.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.05
4+
// VERSION: 0.1.06
55
// PURPOSE: class implementation of map function - library for Arduino
66
// URL: http://forum.arduino.cc/index.php?topic=276194
77
//
88
// HISTORY:
9-
// 0.1.05 stripped of bit mask experimental code
9+
// 0.1.06 2015-03-08 replaced double by double (support ARM)
10+
// 0.1.05 2014-11-02 stripped of bit mask experimental code
1011
// 0.1.04 add back() - the inverse map
1112
// tested with bit mask for constrain code (Perfomance was killed)
1213
// 0.1.03 proper name
@@ -21,7 +22,7 @@
2122
//
2223
// PUBLIC
2324
//
24-
void FastMap::init(float in_min, float in_max, float out_min, float out_max)
25+
void FastMap::init(double in_min, double in_max, double out_min, double out_max)
2526
{
2627
_in_min = in_min;
2728
_in_max = in_max;
@@ -35,20 +36,20 @@ void FastMap::init(float in_min, float in_max, float out_min, float out_max)
3536
_backbase = in_min - out_min * _backfactor;
3637
}
3738

38-
float FastMap::constrainedMap(float value)
39+
double FastMap::constrainedMap(double value)
3940
{
4041
if (value <= _in_min) return _out_min;
4142
if (value >= _in_max) return _out_max;
4243
return this->map(value);
4344
}
4445

45-
float FastMap::lowerConstrainedMap(float value)
46+
double FastMap::lowerConstrainedMap(double value)
4647
{
4748
if (value <= _in_min) return _out_min;
4849
return this->map(value);
4950
}
5051

51-
float FastMap::upperConstrainedMap(float value)
52+
double FastMap::upperConstrainedMap(double value)
5253
{
5354
if (value >= _in_max) return _out_max;
5455
return this->map(value);

libraries/FastMap/FastMap.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//
22
// FILE: FastMap.h
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.1.05
5-
// PURPOSE: class implementation of map function - library for Arduino
4+
// VERSION: 0.1.06
5+
// PURPOSE: class with fast map function - library for Arduino
66
// URL: http://forum.arduino.cc/index.php?topic=276194
77
//
88
// HISTORY:
@@ -18,24 +18,24 @@
1818
#include <Arduino.h>
1919
#endif
2020

21-
#define FASTMAP_LIB_VERSION (F("0.1.05"))
21+
#define FASTMAP_LIB_VERSION (F("0.1.06"))
2222

2323
class FastMap
2424
{
2525
public:
26-
void init(float in_min, float in_max, float out_min, float out_max);
26+
void init(double in_min, double in_max, double out_min, double out_max);
2727

28-
float inline map(float value) { return _base + value * _factor; }
29-
float inline back(float value) { return _backbase + value * _backfactor; }
28+
double inline map(double value) { return _base + value * _factor; }
29+
double inline back(double value) { return _backbase + value * _backfactor; }
3030

31-
float constrainedMap(float value);
32-
float lowerConstrainedMap(float value);
33-
float upperConstrainedMap(float value);
31+
double constrainedMap(double value);
32+
double lowerConstrainedMap(double value);
33+
double upperConstrainedMap(double value);
3434

3535
private:
36-
float _in_min, _in_max, _out_min, _out_max;
37-
float _factor, _base;
38-
float _backfactor, _backbase;
36+
double _in_min, _in_max, _out_min, _out_max;
37+
double _factor, _base;
38+
double _backfactor, _backbase;
3939
};
4040

4141
#endif

0 commit comments

Comments
 (0)