diff --git a/libraries/FLE/FLE.cpp b/libraries/FLE/FLE.cpp index 3da5dd00..be224ffc 100644 --- a/libraries/FLE/FLE.cpp +++ b/libraries/FLE/FLE.cpp @@ -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 -- - diff --git a/libraries/FLE/FLE.h b/libraries/FLE/FLE.h index c594f6f4..2deff094 100644 --- a/libraries/FLE/FLE.h +++ b/libraries/FLE/FLE.h @@ -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: diff --git a/libraries/FLE/README.md b/libraries/FLE/README.md index 1e608990..3c15e693 100644 --- a/libraries/FLE/README.md +++ b/libraries/FLE/README.md @@ -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 diff --git a/libraries/FLE/examples/fle_demo/fle_demo.ino b/libraries/FLE/examples/fle_demo/fle_demo.ino index 00becc66..4f213155 100644 --- a/libraries/FLE/examples/fle_demo/fle_demo.ino +++ b/libraries/FLE/examples/fle_demo/fle_demo.ino @@ -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__); diff --git a/libraries/FLE/examples/fle_mae_demo/fle_mae_demo.ino b/libraries/FLE/examples/fle_mae_demo/fle_mae_demo.ino index 2e674b69..3a9f5de6 100644 --- a/libraries/FLE/examples/fle_mae_demo/fle_mae_demo.ino +++ b/libraries/FLE/examples/fle_mae_demo/fle_mae_demo.ino @@ -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 -- diff --git a/libraries/FLE/library.json b/libraries/FLE/library.json index b7b80daf..13b94aa6 100644 --- a/libraries/FLE/library.json +++ b/libraries/FLE/library.json @@ -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": "*" } diff --git a/libraries/FLE/library.properties b/libraries/FLE/library.properties index e14d4d6a..84bc40b0 100644 --- a/libraries/FLE/library.properties +++ b/libraries/FLE/library.properties @@ -1,10 +1,10 @@ name=FLE -version=0.1.0 +version=0.1.1 author=Rob Tillaart maintainer=Rob Tillaart 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 diff --git a/libraries/FLE/test/unit_test_001.cpp b/libraries/FLE/test/unit_test_001.cpp index c2265ecf..75ce3f42 100644 --- a/libraries/FLE/test/unit_test_001.cpp +++ b/libraries/FLE/test/unit_test_001.cpp @@ -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() // --------