Skip to content

Commit dfbc898

Browse files
committed
0.2.1 DistanceTable
1 parent 1107c65 commit dfbc898

File tree

7 files changed

+47
-35
lines changed

7 files changed

+47
-35
lines changed

libraries/DistanceTable/.arduino-ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ compile:
22
# Choosing to run compilation tests on 2 different Arduino platforms
33
platforms:
44
- uno
5-
- leonardo
6-
- due
7-
- zero
5+
# - due
6+
# - zero
7+
# - leonardo
8+
- m4
9+
- esp32
10+
# - esp8266
11+
# - mega2560

libraries/DistanceTable/.github/workflows/arduino_test_runner.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ name: Arduino CI
44
on: [push, pull_request]
55

66
jobs:
7-
arduino_ci:
7+
runTest:
88
runs-on: ubuntu-latest
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- uses: Arduino-CI/action@master
13-
# Arduino-CI/[email protected]
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb

libraries/DistanceTable/DistanceTable.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
//
22
// FILE: DistanceTable.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.2.0
4+
// VERSION: 0.2.1
55
// PURPOSE: Arduino library to store a symmetrical distance table in less memory
66
// URL: https://github.com/RobTillaart/DistanceTable
77

8-
8+
// HISTORY
9+
// 0.1.00 initial version
10+
// 0.1.01 refactor
11+
// 0.1.2 fix overflow; add some error detection; revert float to float to memory
12+
// 0.1.3 2017-07-27 Fix issue #33
13+
// 0.1.4 2019-01-10 add size()
14+
// 0.1.5 2020-06-07 fix library.json, minor edits
15+
// 0.1.6 2020-12-20 arduino-ci + unit test
916
// 0.2.0 2021-01-19 refactor
1017
// properly named functions,
1118
// add setAll(), minimum(), maximum() and count()
12-
// 0.1.6 2020-12-20 arduino-ci + unit test
13-
// 0.1.5 2020-06-07 fix library.json, minor edits
14-
// 0.1.4 2019-01-10 add size()
15-
// 0.1.3 2017-07-27 Fix issue #33
16-
// 0.1.2 fix overflow; add some error detection; revert float to float to memory
17-
// 0.1.01 refactor
18-
// 0.1.00 initial version
19+
// 0.2.1 2021-10-26 update build-CI, update readme.md
20+
// default value in constructor
1921

2022

2123
#include "DistanceTable.h"
2224

2325

24-
DistanceTable::DistanceTable(uint8_t dimension)
26+
DistanceTable::DistanceTable(uint8_t dimension, float value)
2527
{
26-
// ATMEL 328 has 2000 bytes mem,
28+
// ATMEL 328 has ~2000 bytes RAM,
2729
// so roughly 30X30 = 900 floats(4Bytes) => 1740 bytes is max feasible
2830
_dimension = 0;
2931
_elements = 0;
@@ -38,7 +40,7 @@ DistanceTable::DistanceTable(uint8_t dimension)
3840
_dimension = 0;
3941
_elements = 0;
4042
}
41-
setAll(0);
43+
setAll(value);
4244
}
4345

4446

@@ -63,7 +65,7 @@ void DistanceTable::setAll(float value)
6365
void DistanceTable::set(uint8_t x, uint8_t y, float value )
6466
{
6567
if ( x == y ) return;
66-
// comment next line to skip rangecheck (squeeze performance)
68+
// comment next line to skip range check (squeeze performance)
6769
if ( (x >= _dimension) || (y >= _dimension)) return;
6870

6971
if ( x < y )
@@ -80,7 +82,7 @@ void DistanceTable::set(uint8_t x, uint8_t y, float value )
8082
float DistanceTable::get (uint8_t x, uint8_t y)
8183
{
8284
if ( x == y ) return 0.0; // TODO even true when x and y are out of range??
83-
// comment next line to skip rangecheck (squeeze performance)
85+
// comment next line to skip range check (squeeze performance)
8486
if ( (x >= _dimension) || (y >= _dimension)) return -1; // NAN ?
8587

8688
if ( x < y )

libraries/DistanceTable/DistanceTable.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: DistanceTable.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.2.0
5+
// VERSION: 0.2.1
66
// PURPOSE: Arduino library to store a symmetrical distance table in less memory
77
// URL: https://github.com/RobTillaart/DistanceTable
88
//
@@ -11,13 +11,13 @@
1111
#include "Arduino.h"
1212

1313

14-
#define DISTANCETABLE_LIB_VERSION (F("0.2.0"))
14+
#define DISTANCETABLE_LIB_VERSION (F("0.2.1"))
1515

1616

1717
class DistanceTable
1818
{
1919
public:
20-
explicit DistanceTable(uint8_t dimension);
20+
explicit DistanceTable(uint8_t dimension, float value = 0);
2121
~DistanceTable();
2222

2323
void clear() { setAll(0); };
@@ -55,4 +55,5 @@ class DistanceTable
5555

5656
};
5757

58+
5859
// --- END OF FILE ---

libraries/DistanceTable/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/DistanceTable"
1717
},
18-
"version": "0.2.0",
18+
"version": "0.2.1",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*"

libraries/DistanceTable/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=DistanceTable
2-
version=0.2.0
2+
version=0.2.1
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Library for a memory efficient DistanceTable for Arduino.

libraries/DistanceTable/readme.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
[![Arduino CI](https://github.com/RobTillaart/Distancetable/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/DistanceTable/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DistanceTable/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/DistanceTable/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DistanceTable/actions/workflows/jsoncheck.yml)
35
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/Distancetable/blob/master/LICENSE)
46
[![GitHub release](https://img.shields.io/github/release/RobTillaart/Distancetable.svg?maxAge=3600)](https://github.com/RobTillaart/Distancetable/releases)
57

@@ -13,7 +15,7 @@ Arduino library to store a symmetrical distance table in less memory.
1315

1416
The DistanceTable library is a class that stores a symmetrical distance table
1517
which is typically N x N entries in less memory space.
16-
It uses (N x (N-1))/2 ("in a triangle") as an eucledian distance table is
18+
It uses (N x (N-1))/2 ("in a triangle") as an euclidean distance table is
1719
symmetrical around its main diagonal.
1820
Furthermore as the main diagonal are all zero it does not need to be stored either.
1921

@@ -25,15 +27,15 @@ Within the 2K RAM of an Arduino one could store normally a 21 x 21 matrix (1764
2527

2628
## Interface
2729

28-
- **DistanceTable(uint8_t size)** Constructor, allocates memory and clears them.
30+
- **DistanceTable(uint8_t size, float value = 0.0)** Constructor, allocates memory and sets initial value to all elements.
2931
- **~DistanceTable();** Destructor, frees memory
3032
- **void clear()** sets all entries to 0.0.
31-
- **void setAll(value)** sets all entries to value;
33+
- **void setAll(float value)** sets all entries to value;
3234
- **void set(uint8_t x, uint8_t y, float value )** sets a value for (x,y) and automatically for (y, x)
3335
- **float get(uint8_t x, uint8_t y)** gets a value from (x,y). If x == y it will return 0.
34-
- **float minimum(uint8_t &x, uint8_t &y)** Returns minimum and first occurence in x and y. It does skip x == y pairs as these are 0.
35-
- **float maximum(uint8_t &x, uint8_t &y)** Returns maximum and first occurence in x and y. It does skip x == y pairs as these are 0.
36-
- **uint16_t count(value, epsilon)** counts the number of occurences of value. As we are comparing floats the epsilon can set a margin for 'almost equal'.
36+
- **float minimum(uint8_t &x, uint8_t &y)** Returns minimum and first occurrence in x and y. It does skip x == y pairs as these are 0.
37+
- **float maximum(uint8_t &x, uint8_t &y)** Returns maximum and first occurrence in x and y. It does skip x == y pairs as these are 0.
38+
- **uint16_t count(value, epsilon)** counts the number of occurrences of value. As we are comparing floats the epsilon can set a margin for 'almost equal'.
3739

3840

3941

@@ -47,13 +49,12 @@ Within the 2K RAM of an Arduino one could store normally a 21 x 21 matrix (1764
4749

4850
## Future
4951

50-
- **count()** could get an epsilon to count also nearly hits (default 0.0);
51-
- **clear()** could set all to NAN? is that better as it iindicates unknown?
52+
- **clear()** could set all to NAN? is that better as it indicates unknown?
5253
setAll() let the user decide.
5354

5455

55-
Note: table can be used for other symmetrical 2D tables. And therefor include
56-
negative values.
56+
Note: table can be used for other symmetrical 2D tables.
57+
And therefore include negative values.
5758

5859

5960
## Operational

0 commit comments

Comments
 (0)