diff --git a/libraries/GAMMA/LICENSE b/libraries/GAMMA/LICENSE index 8eba944a..c3d6b3da 100644 --- a/libraries/GAMMA/LICENSE +++ b/libraries/GAMMA/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020-2021 Rob Tillaart +Copyright (c) 2020-2022 Rob Tillaart Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/libraries/GAMMA/README.md b/libraries/GAMMA/README.md index dfa5b7ef..48f51bd8 100644 --- a/libraries/GAMMA/README.md +++ b/libraries/GAMMA/README.md @@ -57,7 +57,8 @@ like ```x = G[40];``` Makes it easy to switch with a real array. ### Development functions - **size()** returns size of the internal array. -- **distinct()** returns the number of distinct values in the table. Especially with larger internal tables this will happen. +- **distinct()** returns the number of distinct values in the table. +Especially with larger internal tables rhere will be duplicate numbers in the table. - **dump()** dumps the internal table to Serial. Can be useful to create an array in RAM, PROGMEM or wherever. @@ -69,8 +70,10 @@ See example ## Future ideas -- test other platforms - improve documentation +- test other platforms - look for optimizations - uint16 version? -- +- **dumpAsArray()** - generate a C style array +- + diff --git a/libraries/GAMMA/examples/GammaErrorAnalysis/GammaErrorAnalysis.ino b/libraries/GAMMA/examples/GammaErrorAnalysis/GammaErrorAnalysis.ino index afb9537e..d280edb6 100644 --- a/libraries/GAMMA/examples/GammaErrorAnalysis/GammaErrorAnalysis.ino +++ b/libraries/GAMMA/examples/GammaErrorAnalysis/GammaErrorAnalysis.ino @@ -1,7 +1,6 @@ // // FILE: GammaErrorAnalysis.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo // DATE: 2020-08-08 diff --git a/libraries/GAMMA/examples/GammaPerformance/GammaPerformance.ino b/libraries/GAMMA/examples/GammaPerformance/GammaPerformance.ino index bc9c6772..2681e3e2 100644 --- a/libraries/GAMMA/examples/GammaPerformance/GammaPerformance.ino +++ b/libraries/GAMMA/examples/GammaPerformance/GammaPerformance.ino @@ -1,7 +1,6 @@ // // FILE: gammaPerformance.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo // DATE: 2020-08-08 diff --git a/libraries/GAMMA/examples/gammaTest/gammaTest.ino b/libraries/GAMMA/examples/gammaTest/gammaTest.ino index fcc87762..d2518239 100644 --- a/libraries/GAMMA/examples/gammaTest/gammaTest.ino +++ b/libraries/GAMMA/examples/gammaTest/gammaTest.ino @@ -1,7 +1,6 @@ // // FILE: gammaTest.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo // DATE: 2020-08-08 diff --git a/libraries/GAMMA/examples/gammaTest2/gammaTest2.ino b/libraries/GAMMA/examples/gammaTest2/gammaTest2.ino index f4773342..b7509517 100644 --- a/libraries/GAMMA/examples/gammaTest2/gammaTest2.ino +++ b/libraries/GAMMA/examples/gammaTest2/gammaTest2.ino @@ -1,7 +1,6 @@ // // FILE: gammaTest2.ino // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 // PURPOSE: demo setGamma // DATE: 2020-08-08 diff --git a/libraries/GAMMA/gamma.h b/libraries/GAMMA/gamma.h index 1426dbbb..0321d3dd 100644 --- a/libraries/GAMMA/gamma.h +++ b/libraries/GAMMA/gamma.h @@ -2,19 +2,24 @@ // // FILE: gamma.h // AUTHOR: Rob Tillaart -// VERSION: 0.2.0 +// VERSION: 0.2.1 // DATE: 2020-08-08 // PURPOSE: Arduino Library to efficiently hold a gamma lookup table // 0.1.0 2020-08-08 initial release -// 0.1.1 2020-12-24 arduino-ci + unit test +// 0.1.1 2020-12-24 arduino-ci + unit test // 0.2.0 2021-11-02 update build-CI, badges // add begin() - fixes ESP32 crash. +// 0.2.1 2021-12-18 update library.json, license, +// add constants, minor edits. #include "Arduino.h" -#define GAMMA_LIB_VERSION (F("0.2.0")) +#define GAMMA_LIB_VERSION (F("0.2.1")) + +#define GAMMA_DEFAULT_SIZE 32 +#define GAMMA_MAX_SIZE 256 class GAMMA @@ -22,11 +27,11 @@ class GAMMA public: - GAMMA(uint16_t size = 32) + GAMMA(uint16_t size = GAMMA_DEFAULT_SIZE) { _shift = 7; // force power of 2; get shift & mask right - for (uint16_t s = 2; s < 512; s <<= 1) + for (uint16_t s = 2; s <= GAMMA_MAX_SIZE; s <<= 1) { if (size <= s) { @@ -36,8 +41,7 @@ public: _shift--; } _mask = (1 << _shift) - 1; - _interval = 256 / _size; - // removed malloc from constructor for ESP32 + _interval = GAMMA_MAX_SIZE / _size; } diff --git a/libraries/GAMMA/keywords.txt b/libraries/GAMMA/keywords.txt index 4317b753..9f822c4a 100644 --- a/libraries/GAMMA/keywords.txt +++ b/libraries/GAMMA/keywords.txt @@ -1,9 +1,10 @@ -# Syntax Coloring Map For GAMMA +# Syntax Colouring Map For GAMMA -# Datatypes (KEYWORD1) +# Data types (KEYWORD1) GAMMA KEYWORD1 # Methods and Functions (KEYWORD2) +begin KEYWORD2 setGamma KEYWORD2 getGamma KEYWORD2 size KEYWORD2 diff --git a/libraries/GAMMA/library.json b/libraries/GAMMA/library.json index dd571a5a..3102e86e 100644 --- a/libraries/GAMMA/library.json +++ b/libraries/GAMMA/library.json @@ -15,8 +15,9 @@ "type": "git", "url": "https://github.com/RobTillaart/GAMMA.git" }, - "version": "0.2.0", + "version": "0.2.1", "license": "MIT", "frameworks": "arduino", - "platforms": "*" + "platforms": "*", + "headers": "gamma.h" } diff --git a/libraries/GAMMA/library.properties b/libraries/GAMMA/library.properties index 15c93062..5850af4d 100644 --- a/libraries/GAMMA/library.properties +++ b/libraries/GAMMA/library.properties @@ -1,5 +1,5 @@ name=GAMMA -version=0.2.0 +version=0.2.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino Library for the GAMMA function diff --git a/libraries/GAMMA/test/unit_test_001.cpp b/libraries/GAMMA/test/unit_test_001.cpp index 65601bf7..8cd91444 100644 --- a/libraries/GAMMA/test/unit_test_001.cpp +++ b/libraries/GAMMA/test/unit_test_001.cpp @@ -31,6 +31,7 @@ unittest_setup() { + fprintf(stderr, "GAMMA_LIB_VERSION: %s\n", (char *) GAMMA_LIB_VERSION); } unittest_teardown() @@ -38,6 +39,13 @@ unittest_teardown() } +unittest(test_constants) +{ + assertEqual( 32, GAMMA_DEFAULT_SIZE); + assertEqual(256, GAMMA_MAX_SIZE); +} + + unittest(test_constructor) { GAMMA gt0; // uses default 32 size @@ -57,25 +65,25 @@ unittest(test_constructor) assertEqual(129, gt2.size()); assertEqualFloat(2.8, gt2.getGamma(), 0.0001); assertEqual(97, gt2.distinct()); - + GAMMA gt3(64); gt3.begin(); assertEqual(65, gt3.size()); assertEqualFloat(2.8, gt3.getGamma(), 0.0001); assertEqual(53, gt3.distinct()); - + GAMMA gt4(32); // default gt4.begin(); assertEqual(33, gt4.size()); assertEqualFloat(2.8, gt4.getGamma(), 0.0001); assertEqual(28, gt4.distinct()); - + GAMMA gt5(16); gt5.begin(); assertEqual(17, gt5.size()); assertEqualFloat(2.8, gt5.getGamma(), 0.0001); assertEqual(15, gt5.distinct()); - + GAMMA gt6(8); gt6.begin(); assertEqual(9, gt6.size());