0.1.4 MultiMap

This commit is contained in:
rob tillaart 2021-05-28 13:39:42 +02:00
parent c1a6d80098
commit e83ffeb82e
10 changed files with 45 additions and 11 deletions

View File

@ -2,7 +2,7 @@
//
// FILE: MultiMap.h
// AUTHOR: Rob Tillaart
// VERSION: 0.1.3
// VERSION: 0.1.4
// DATE: 2011-01-26
// PURPOSE: Arduino library for fast non-linear mapping or interpolation of values
// URL: https://github.com/RobTillaart/MultiMap
@ -15,9 +15,11 @@
// 0.1.1 2020-04-09
// 0.1.2 2020-06-19 fix library.json
// 0.1.3 2021-01-02 add arduino-CI
//
// 0.1.4 2021-05-27 fix arduino-lint
#define MULTIMAP_LIB_VERSION (F("0.1.4"))
#define MULTIMAP_LIB_VERSION "0.1.3"
#include "Arduino.h"
@ -90,4 +92,5 @@ T multiMap(T val, T* _in, T* _out, uint8_t size)
}
*/
// -- END OF FILE --

View File

@ -7,6 +7,7 @@
Arduino library for fast non-linear mapping or interpolation of values
## Description
In Arduino applications often the value of a sensor is mapped upon a more
@ -35,12 +36,14 @@ points of the output\[\] array.
there is no such restriction for the **output\[\]** array.
- **Multimap()** automatically constrains the output to the first and last value in the **output\[\]** array.
## Operation
See examples
Please note the fail example as this shows that in the intern math overflow can happen.
## TODO
Investigate class implementation for performance.

View File

@ -7,6 +7,7 @@
// (c) : MIT
//
#include "MultiMap.h"
uint32_t start;
@ -17,6 +18,7 @@ volatile float x, y, z;
// Note this is a bit an extreme example,
// normally you only make a multimap of the working range
float in[] = {
0, 1, 3, 8, 13, 20, 25, 32, 50, 60, 72, 85, 100, 145, 200, 250, 300, 400, 500, 600, 650, 700, 753, 800, 830, 870, 900, 936, 964, 985, 1000, 1017, 1023
};
@ -27,6 +29,7 @@ float out[] = {
int sz = 33;
void setup()
{
Serial.begin(115200);
@ -64,10 +67,12 @@ void setup()
}
void loop()
{
}
// NTC formula
float val(int sensorValueA1)
{
@ -80,4 +85,5 @@ float val(int sensorValueA1)
return Temp;
}
// -- END OF FILE --

View File

@ -23,6 +23,7 @@ uint32_t stop;
volatile float x, y, z;
int in[] = {
0, 1, 3, 8, 13, 20, 25, 32, 50, 60, 72, 85, 100, 145, 200, 250, 300, 400, 500, 600, 650, 700, 753, 800, 830, 870, 900, 936, 964, 985, 1000, 1017, 1023
};
@ -33,6 +34,7 @@ int out[] = {
int sz = 33;
void setup()
{
Serial.begin(115200);
@ -67,13 +69,14 @@ void setup()
Serial.print(z);
Serial.println();
}
}
void loop()
{
}
// NTC formula
float val(int sensorValueA1)
{
@ -86,4 +89,5 @@ float val(int sensorValueA1)
return Temp;
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -1,4 +1,3 @@
//
// FILE: multimap_distance.ino
// AUTHOR: Rob Tillaart
@ -7,8 +6,10 @@
// DATE: 2020-04-09
//
#include "MultiMap.h"
void setup()
{
Serial.begin(115200);
@ -26,6 +27,7 @@ void setup()
Serial.println("Done...");
}
void loop()
{
}
@ -44,4 +46,5 @@ float sharp2cm(int val)
return dist;
}
// -- END OF FILE --

View File

@ -10,6 +10,7 @@
#include "MultiMap.h"
void setup()
{
Serial.begin(115200);
@ -27,11 +28,12 @@ void setup()
Serial.println("\nDone...");
}
void loop()
{
}
void test_normal_distribution()
{
// sort of normal distribution
@ -48,6 +50,7 @@ void test_normal_distribution()
}
}
void test_sinus()
{
// one sinus wave, amplitudo 1023
@ -64,6 +67,7 @@ void test_sinus()
}
}
void lest_log10()
{
// log10 * 100
@ -80,6 +84,7 @@ void lest_log10()
}
}
void test_exp2()
{
// 2^x
@ -96,6 +101,7 @@ void test_exp2()
}
}
void test_exp3()
{
// 3^x
@ -112,6 +118,7 @@ void test_exp3()
}
}
void test_sawtooth()
{
long sawtooth[] = { 0, 1000, 0, -1000, 0, 1000, -1000, 0 }; // size 8
@ -127,4 +134,5 @@ void test_sawtooth()
}
}
// -- END OF FILE --

View File

@ -19,6 +19,7 @@ float fout[] = {111, 222, 555};
uint32_t start;
uint32_t stop;
void setup()
{
Serial.begin(115200);
@ -40,9 +41,10 @@ void setup()
Serial.println(y, 4);
}
void loop()
{
}
// -- END OF FILE --

View File

@ -15,7 +15,8 @@
"type": "git",
"url": "https://github.com/RobTillaart/MultiMap.git"
},
"version":"0.1.3",
"version": "0.1.4",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
}

View File

@ -1,11 +1,11 @@
name=MultiMap
version=0.1.3
version=0.1.4
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library for fast non-linear interpolation by means of two arrays.
paragraph=
category=Data Processing
url=https://github.com/RobTillaart/Arduino/MultiMap
url=https://github.com/RobTillaart/MultiMap
architectures=*
includes=MultiMap.h
depends=

View File

@ -39,6 +39,7 @@ unittest_setup()
{
}
unittest_teardown()
{
}
@ -56,6 +57,7 @@ unittest(test_new_operator)
}
*/
unittest(test_all)
{
fprintf(stderr, "VERSION: %s\n", MULTIMAP_LIB_VERSION);
@ -75,6 +77,8 @@ unittest(test_all)
assertEqualFloat(20.0000, multiMap<float>(600, in, out, 14), 0.001);
}
unittest_main()
// --------