mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.1.1 FLE
This commit is contained in:
parent
166d55a287
commit
533983fcc8
@ -2,17 +2,23 @@
|
||||
// FILE: FLE.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2020-07-21
|
||||
// VERSION: 0.1.0
|
||||
// VERSION: 0.1.1
|
||||
// PURPOSE: Arduino library for float with error datatype
|
||||
// URL: https://github.com/RobTillaart/FLE
|
||||
//
|
||||
// HISTORY
|
||||
// 0.0.1 2020-07-21 initial version
|
||||
// 0.1.0 2020-12-23 arduino-CI + unit tests
|
||||
// 0.1.1 2021-05-27 fix arduino-lint
|
||||
|
||||
|
||||
// TODO - initial implementation.
|
||||
// TODO - test with negative values
|
||||
|
||||
|
||||
#include "FLE.h"
|
||||
|
||||
|
||||
FLE::FLE(float val, float err)
|
||||
{
|
||||
_v = val;
|
||||
@ -32,19 +38,19 @@ size_t FLE::printTo(Print& p) const
|
||||
return n;
|
||||
}
|
||||
|
||||
// TODO - initial implementation.
|
||||
// TODO - test with negative values
|
||||
|
||||
FLE FLE::operator + (const FLE &in)
|
||||
{
|
||||
return FLE(_v + in._v, _e + in._e);
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator - (const FLE &in)
|
||||
{
|
||||
return FLE(_v - in._v, _e + in._e);
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator * (const FLE &in)
|
||||
{
|
||||
float val = _v * in._v;
|
||||
@ -52,6 +58,7 @@ FLE FLE::operator * (const FLE &in)
|
||||
return FLE(val, err);
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator / (const FLE &in)
|
||||
{
|
||||
float val = _v / in._v;
|
||||
@ -59,6 +66,7 @@ FLE FLE::operator / (const FLE &in)
|
||||
return FLE(val, err);
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator += (const FLE &in)
|
||||
{
|
||||
_v += in._v;
|
||||
@ -66,6 +74,7 @@ FLE FLE::operator += (const FLE &in)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator -= (const FLE &in)
|
||||
{
|
||||
_v -= in._v;
|
||||
@ -73,6 +82,7 @@ FLE FLE::operator -= (const FLE &in)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator *= (const FLE &in)
|
||||
{
|
||||
float sum = relError() + in.relError();
|
||||
@ -81,6 +91,7 @@ FLE FLE::operator *= (const FLE &in)
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
FLE FLE::operator /= (const FLE &in)
|
||||
{
|
||||
float sum = relError() + in.relError();
|
||||
@ -90,6 +101,4 @@ FLE FLE::operator /= (const FLE &in)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: FLE.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2020-07-21
|
||||
// VERSION: 0.1.0
|
||||
// VERSION: 0.1.1
|
||||
// PURPOSE: Arduino library for float with error datatype
|
||||
// URL: https://github.com/RobTillaart/FLE
|
||||
//
|
||||
@ -14,8 +14,9 @@
|
||||
#include "Arduino.h"
|
||||
#include "math.h"
|
||||
|
||||
#define FLE_LIB_VERSION "0.1.0"
|
||||
|
||||
#define FLE_LIB_VERSION (F("0.1.1"))
|
||||
|
||||
|
||||
class FLE: public Printable
|
||||
{
|
||||
public:
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
Arduino library for Arduino library for float with error datatype
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
This experimental library provides basic math when have a quantity with a certain
|
||||
@ -31,6 +32,7 @@ This allows you to print an FLE in human readable form.
|
||||
|
||||
When the ± char does not print correctly, one could change the font.
|
||||
|
||||
|
||||
### Functions
|
||||
|
||||
- **FLE(val = 0, err = 0)** constructor, with default value and error set to 0.
|
||||
@ -47,6 +49,7 @@ Then it return 0. Q: should this be "NaN
|
||||
|
||||
furthermore the basic math is implemented, "+, -, *, /, +=, -=, *=, /="
|
||||
|
||||
|
||||
## Todo
|
||||
|
||||
- comparison (investigate, what means equal or less than ..)
|
||||
@ -60,6 +63,7 @@ furthermore the basic math is implemented, "+, -, *, /, +=, -=, *=, /="
|
||||
- test other separator
|
||||
- more demo sketches...
|
||||
|
||||
|
||||
## Operation
|
||||
|
||||
- negative numbers not tested yet
|
||||
|
@ -6,6 +6,7 @@
|
||||
// DATE: 2020-07-21
|
||||
// URL: https://github.com/RobTillaart/FLE
|
||||
|
||||
|
||||
#include "FLE.h"
|
||||
|
||||
FLE zero;
|
||||
@ -18,6 +19,7 @@ FLE EE(EULER);
|
||||
FLE x(2, 0.1);
|
||||
FLE y(7, 0.3);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -30,10 +32,12 @@ void setup()
|
||||
Serial.println("\nDone...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void test_printable()
|
||||
{
|
||||
Serial.println(__FUNCTION__);
|
||||
|
@ -6,10 +6,12 @@
|
||||
// DATE: 2020-07-21
|
||||
// URL: https://github.com/RobTillaart/FLE
|
||||
|
||||
|
||||
#include "FLE.h"
|
||||
|
||||
FLE ar[20];
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
@ -30,6 +32,7 @@ void setup()
|
||||
Serial.println("\nDone...");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
@ -51,7 +54,6 @@ FLE meanAverageError(FLE *, uint8_t len, uint8_t dec)
|
||||
}
|
||||
|
||||
|
||||
|
||||
FLE meanError(FLE *, uint8_t len, uint8_t dec)
|
||||
{
|
||||
if (len == 0) return FLE(0, 0);
|
||||
@ -82,4 +84,5 @@ FLE meanError(FLE *, uint8_t len, uint8_t dec)
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
@ -15,7 +15,8 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/FLE.git"
|
||||
},
|
||||
"version":"0.1.0",
|
||||
"version": "0.1.1",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*"
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
name=FLE
|
||||
version=0.1.0
|
||||
version=0.1.1
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for FLE = FLoat with Error datatype
|
||||
paragraph=Measurements are seldom exact. This library is meant to handle measurement errors and propagation thereof during math.
|
||||
category=data processing
|
||||
category=Data Processing
|
||||
url=https://github.com/RobTillaart/FLE
|
||||
architectures=*
|
||||
includes=FLE.h
|
||||
|
@ -32,6 +32,7 @@ unittest_setup()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
@ -49,6 +50,7 @@ unittest(test_new_operator)
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
FLE zero;
|
||||
@ -84,11 +86,13 @@ unittest(test_constructor)
|
||||
assertEqualFloat(0.3, y.error(), 0.001);
|
||||
}
|
||||
|
||||
|
||||
unittest(test_basic_math)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
Loading…
x
Reference in New Issue
Block a user