diff --git a/libraries/SparseArray/.arduino-ci.yml b/libraries/SparseArray/.arduino-ci.yml index 1fd3a202..75b4d96b 100644 --- a/libraries/SparseArray/.arduino-ci.yml +++ b/libraries/SparseArray/.arduino-ci.yml @@ -1,3 +1,18 @@ +platforms: + rpipico: + board: rp2040:rp2040:rpipico + package: rp2040:rp2040 + gcc: + features: + defines: + - ARDUINO_ARCH_RP2040 + warnings: + flags: + +packages: + rp2040:rp2040: + url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json + compile: # Choosing to run compilation tests on 2 different Arduino platforms platforms: @@ -9,5 +24,6 @@ compile: - esp32 - esp8266 # - mega2560 + - rpipico libraries: - "SHT85" \ No newline at end of file diff --git a/libraries/SparseArray/CHANGELOG.md b/libraries/SparseArray/CHANGELOG.md new file mode 100644 index 00000000..f1653618 --- /dev/null +++ b/libraries/SparseArray/CHANGELOG.md @@ -0,0 +1,17 @@ +# Change Log sparseArray + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + + +## [0.1.1] - 2022-11-25 +- Add RP2040 support to build-CI. +- Add CHANGELOG.md +- update readme.md + + +## [0.1.0] - 2022-07-17 +- initial version, derives from SparseMatrix + diff --git a/libraries/SparseArray/README.md b/libraries/SparseArray/README.md index 32bfdfca..74a8b89f 100644 --- a/libraries/SparseArray/README.md +++ b/libraries/SparseArray/README.md @@ -11,22 +11,20 @@ Arduino library for sparse arrays of floats. -TODO REDO DOCUMENTATION. - - ## Description SparseArray is an **experimental** library to implement a one dimensional sparse array of floats (a.k.a. vector) on an Arduino. -A sparse array is a mn array with mostly zeros and a low percentage +A sparse array is an array with mostly zeros and a low percentage non-zero values. The purpose of this library is efficient storage in memory. -The maximum array that can be represented is 65535 elements -with a theoretical maximum of 65535 non-zero elements. +The maximum array size this library can represent is 65535 elements +with a theoretical maximum of 65535 non-zero elements. (although that does not make sense due to overhead) -In practice the library limits this to 1000 non-zero elements. -Note: 255 elements would still fit in an UNO's 2K memory. +In practice the library limits the number of non-zero elements to 1000. + +Note: 255 non-zero elements would fit in an UNO's 2K memory. Relates to: - https://github.com/RobTillaart/SparseMatrix @@ -37,15 +35,17 @@ Note: this library is derived from SparseMatrix. #### Implementation -The implementation is based on 2 arrays holding ``` x, value``` +The implementation is based on 2 arrays holding ```x, value``` where value is float, and x is an uint16_t. That are 6 bytes per element. -The number of elements that the sparse array object can hold are +The number of elements that the sparse array object can hold is given as parameter to the constructor. If the space cannot be allocated the size is set to zero. In the future other data types should be possible. +Relates to https://github.com/RobTillaart/SET + #### Performance @@ -99,18 +99,29 @@ This can be useful for printing or processing the non zero elements. ## Future -- documentation -- test +#### must +- improve documentation + +#### should +- do test +- investigate optimizations + - derived sorted class ==> insertSort - keep in sync with SparseMatrix where possible -- merge into one class hierarchy? + - merge into one class hierarchy? +- Template class for the data type + - better than SparseArray64 SparseArray32 SparseArray16 SparseArray8 (signed / unsigned?) + +#### could - dump should be in the class? - or as static function... - stream as param dump(Stream str, ... - + #### ideas - array { uint32_t, float }; for logging millis/micros + measurement delta coding of time stamp? if it fit in 16 bit? => sounds like a class on its own. +- investigate index \[\] operator for **get()** and **set()** + - would break with sparse matrix diff --git a/libraries/SparseArray/SparseArray.cpp b/libraries/SparseArray/SparseArray.cpp index 382041e4..fc869a29 100644 --- a/libraries/SparseArray/SparseArray.cpp +++ b/libraries/SparseArray/SparseArray.cpp @@ -1,15 +1,10 @@ // // FILE: SparseArray.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 +// VERSION: 0.1.1 // DATE: 2022-07-17 // PURPOSE: Arduino library for sparse arrays of floats // URL: https://github.com/RobTillaart/SparseArray -// -// HISTORY: -// 0.1.0 2022-07-17 initial version -// derives from SparseMatrix - #include "SparseArray.h" diff --git a/libraries/SparseArray/SparseArray.h b/libraries/SparseArray/SparseArray.h index 92cc7354..d8f9d95e 100644 --- a/libraries/SparseArray/SparseArray.h +++ b/libraries/SparseArray/SparseArray.h @@ -2,7 +2,7 @@ // // FILE: SparseArray.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.0 +// VERSION: 0.1.1 // DATE: 2022-07-17 // PURPOSE: Arduino library for sparse arrays of floats // URL: https://github.com/RobTillaart/SparseArray @@ -11,7 +11,7 @@ #include "Arduino.h" -#define SPARSEARRAY_LIB_VERSION (F("0.1.0")) +#define SPARSEARRAY_LIB_VERSION (F("0.1.1")) #ifndef SPARSEARRAY_MAX_SIZE #define SPARSEARRAY_MAX_SIZE 1000 @@ -31,9 +31,8 @@ public: // returns false if no slots free - // could return # free slots? bool set(uint16_t x, float value); - // adds value to element x,y + // adds value to element x bool add(uint16_t x, float value); float get(uint16_t x); @@ -42,18 +41,18 @@ public: void boundingSegment(uint16_t &minX, uint16_t &maxX); -private: +protected: uint16_t _size = 0; uint16_t _count = 0; uint16_t *_x = NULL; // support array's [0..65535] float *_value = NULL; - // returns index of x, y if in set + // returns index of x if in set // otherwise -1 int32_t findPos(uint16_t x); - // removes element at pos (from findPos) + // removes element at position (from findPos) // pre: count > 0 void removeElement(uint16_t pos); // creates a new element if value != 0 and if there is room diff --git a/libraries/SparseArray/library.json b/libraries/SparseArray/library.json index 8eaef236..ddbce730 100644 --- a/libraries/SparseArray/library.json +++ b/libraries/SparseArray/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/SparseArray.git" }, - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "frameworks": "arduino", "platforms": "*", diff --git a/libraries/SparseArray/library.properties b/libraries/SparseArray/library.properties index 41175921..4bcba821 100644 --- a/libraries/SparseArray/library.properties +++ b/libraries/SparseArray/library.properties @@ -1,5 +1,5 @@ name=SparseArray -version=0.1.0 +version=0.1.1 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for sparse arrays of floats.