0.2.1 GAMMA

This commit is contained in:
rob tillaart 2021-12-18 17:16:37 +01:00
parent fa36d679ab
commit 4822b5988e
11 changed files with 37 additions and 24 deletions

View File

@ -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

View File

@ -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
-

View File

@ -1,7 +1,6 @@
//
// FILE: GammaErrorAnalysis.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// PURPOSE: demo
// DATE: 2020-08-08

View File

@ -1,7 +1,6 @@
//
// FILE: gammaPerformance.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// PURPOSE: demo
// DATE: 2020-08-08

View File

@ -1,7 +1,6 @@
//
// FILE: gammaTest.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// PURPOSE: demo
// DATE: 2020-08-08

View File

@ -1,7 +1,6 @@
//
// FILE: gammaTest2.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.2.0
// PURPOSE: demo setGamma
// DATE: 2020-08-08

View File

@ -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;
}

View File

@ -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

View File

@ -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"
}

View File

@ -1,5 +1,5 @@
name=GAMMA
version=0.2.0
version=0.2.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino Library for the GAMMA function

View File

@ -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());