From 455a9625994ce30ebaaa8bb6494db267e420e920 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Wed, 27 May 2026 15:28:12 +0200 Subject: [PATCH 1/2] increase NIBBLEARRAY_MAXSIZE --- .github/workflows/arduino-lint.yml | 2 +- .github/workflows/arduino_test_runner.yml | 3 +-- .github/workflows/jsoncheck.yml | 2 +- CHANGELOG.md | 5 +++++ LICENSE | 2 +- README.md | 8 ++++---- examples/nibbleArray_demo/nibbleArray_demo.ino | 15 ++++++++++----- .../nibbleArray_performance.ino | 2 +- library.json | 2 +- library.properties | 4 ++-- nibbleArray.cpp | 2 +- nibbleArray.h | 12 ++++++------ 12 files changed, 34 insertions(+), 25 deletions(-) diff --git a/.github/workflows/arduino-lint.yml b/.github/workflows/arduino-lint.yml index 0ad60f4..aed264b 100644 --- a/.github/workflows/arduino-lint.yml +++ b/.github/workflows/arduino-lint.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - uses: arduino/arduino-lint-action@v2 with: library-manager: update diff --git a/.github/workflows/arduino_test_runner.yml b/.github/workflows/arduino_test_runner.yml index 1897982..a2a5f07 100644 --- a/.github/workflows/arduino_test_runner.yml +++ b/.github/workflows/arduino_test_runner.yml @@ -6,9 +6,8 @@ jobs: runTest: runs-on: ubuntu-latest timeout-minutes: 20 - steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - uses: ruby/setup-ruby@v1 with: ruby-version: 2.6 diff --git a/.github/workflows/jsoncheck.yml b/.github/workflows/jsoncheck.yml index 8804e69..2c52dc7 100644 --- a/.github/workflows/jsoncheck.yml +++ b/.github/workflows/jsoncheck.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v6 - name: json-syntax-check uses: limitusus/json-syntax-check@v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1eaef91..d581dd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.2.8] - 2026-05-27 +- change NIBBLEARRAY_MAXSIZE => 2500 (UNO R3 limit) +- update GitHub actions +- minor edits + ## [0.2.7] - 2025-09-09 - update GitHub actions - minor edits diff --git a/LICENSE b/LICENSE index cc54713..dd89d54 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017-2025 Rob Tillaart +Copyright (c) 2017-2026 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/README.md b/README.md index 02e5eff..a8ef21c 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,14 @@ Arduino library for a compact array of nibbles (4 bit units). ## Description -A nibble is a 4 bit element, which can hold a value 0..15 (0..F in HEX). +A nibble is a 4 bit element, which can hold a value 0..15 (0x00..0x0F in HEX). It can be seen as an **uint4_t** type. The nibbleArray is an array that stores 2 nibbles in a byte therefore it is -twice as small as a normal array. +twice as small as a normal "byte" array. -The current implementation can hold 510 elements. This is due a limitation of -the UNO R3 which can **allocate** max 255 bytes in one **malloc()** call. +The current implementation can hold 2500 elements. This is due a limitation of +memory of the UNO R3. For other processors one may adapt this size. This **NIBBLEARRAY_MAXSIZE** can be defined compile time "-D NIBBLEARRAY_MAXSIZE" or one can adjust it in the library if other platforms can allocate more memory. diff --git a/examples/nibbleArray_demo/nibbleArray_demo.ino b/examples/nibbleArray_demo/nibbleArray_demo.ino index 427c8ee..4bde09e 100644 --- a/examples/nibbleArray_demo/nibbleArray_demo.ino +++ b/examples/nibbleArray_demo/nibbleArray_demo.ino @@ -7,7 +7,9 @@ #include "nibbleArray.h" -nibbleArray na(500); +// max size UNO R3 = 2500 +// but this program uses too much +nibbleArray na(2500); void setup() @@ -19,6 +21,10 @@ void setup() Serial.println(NIBBLEARRAY_LIB_VERSION); Serial.println(); + Serial.println(); + Serial.println(na.size()); + Serial.println(na.memory()); + test_1(); Serial.println("\nDone..."); @@ -33,7 +39,7 @@ void test_1() na.clear(); // 500 throws with 3 dices (3..18 ==> 0..15) - for (int i = 0; i < 500; i++) + for (int i = 0; i < 2500; i++) { uint8_t sum = random(6); // 0..5 sum += random(6); @@ -41,7 +47,7 @@ void test_1() na.set(i, sum); // diff from na.set(i, random(16)); } - for (int i = 0; i < 500; i++) + for (int i = 0; i < 2500; i++) { ar[na.get(i)]++; Serial.print(" "); @@ -84,7 +90,7 @@ void test_1() void play(uint8_t octave, uint8_t note, uint8_t duration) { Serial.print("Play: "); - // Serial.print(octave); + Serial.print(octave); Serial.print(" "); switch (note) { @@ -148,4 +154,3 @@ void loop() // -- END OF FILE -- - diff --git a/examples/nibbleArray_performance/nibbleArray_performance.ino b/examples/nibbleArray_performance/nibbleArray_performance.ino index 756d96e..5aaf1c8 100644 --- a/examples/nibbleArray_performance/nibbleArray_performance.ino +++ b/examples/nibbleArray_performance/nibbleArray_performance.ino @@ -8,7 +8,7 @@ #include "nibbleArray.h" -// AVR UNO can handle only 510 +// AVR UNO R3 can handle only 510 // ESP32 can do more but depends on RTOS limits diff --git a/library.json b/library.json index f9ab6f9..c83cdab 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/nibbleArray.git" }, - "version": "0.2.7", + "version": "0.2.8", "license": "MIT", "frameworks": "*", "platforms": "*", diff --git a/library.properties b/library.properties index 55b7696..8882526 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ name=NibbleArray -version=0.2.7 +version=0.2.8 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library to implement a compact array of nibbles (4 bit). -paragraph= +paragraph=nybble category=Data Processing url=https://github.com/RobTillaart/Arduino/tree/master/libraries/ architectures=* diff --git a/nibbleArray.cpp b/nibbleArray.cpp index 9bd8c3c..9fa3fec 100644 --- a/nibbleArray.cpp +++ b/nibbleArray.cpp @@ -1,7 +1,7 @@ // // FILE: nibbleArray.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.2.7 +// VERSION: 0.2.8 // PURPOSE: Arduino library for a compact array of nibbles (4 bits) // URL: https://github.com/RobTillaart/nibbleArray diff --git a/nibbleArray.h b/nibbleArray.h index b579183..4a0eb56 100644 --- a/nibbleArray.h +++ b/nibbleArray.h @@ -2,7 +2,7 @@ // // FILE: nibbleArray.h // AUTHOR: Rob Tillaart -// VERSION: 0.2.7 +// VERSION: 0.2.8 // PURPOSE: Arduino library for a compact array of nibbles (4 bits) // URL: https://github.com/RobTillaart/nibbleArray @@ -10,12 +10,12 @@ #include "Arduino.h" -#define NIBBLEARRAY_LIB_VERSION (F("0.2.7")) +#define NIBBLEARRAY_LIB_VERSION (F("0.2.8")) #ifndef NIBBLEARRAY_MAXSIZE -// UNO R3 BASED MAXSIZE -#define NIBBLEARRAY_MAXSIZE 510 +// UNO R3 BASED MAXSIZE = 2500 ==> 1250 bytes +#define NIBBLEARRAY_MAXSIZE 2500 #endif #define NIBBLEARRAY_OK 0x00 @@ -28,7 +28,7 @@ class nibbleArray nibbleArray(const uint16_t size); ~nibbleArray(); - // return 0..F if ok + // return 0x00..0x0F if OK // returns 0xFF for index error. uint8_t get(const uint16_t index); // returns 0xFF for index error. @@ -43,7 +43,7 @@ class nibbleArray private: uint8_t * _arr; uint16_t _size; - uint8_t _bytes = 0; + uint16_t _bytes = 0; }; From 0a3176dcc48672e8f6c55b2862d94d09a0b3c5e5 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Wed, 27 May 2026 17:37:17 +0200 Subject: [PATCH 2/2] fix unit test --- test/unit_test_001.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_test_001.cpp b/test/unit_test_001.cpp index ecf4f1e..5de6fb8 100644 --- a/test/unit_test_001.cpp +++ b/test/unit_test_001.cpp @@ -50,7 +50,7 @@ unittest_teardown() unittest(test_constants) { - assertEqual(NIBBLEARRAY_MAXSIZE , 510 ); + assertEqual(NIBBLEARRAY_MAXSIZE , 2500); assertEqual(NIBBLEARRAY_OK , 0x00); assertEqual(NIBBLEARRAY_ERROR_INDEX, 0xFF); }