Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jsoncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 10 additions & 5 deletions examples/nibbleArray_demo/nibbleArray_demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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...");
Expand All @@ -33,15 +39,15 @@ 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);
sum += random(6);
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(" ");
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -148,4 +154,3 @@ void loop()


// -- END OF FILE --

Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
4 changes: 2 additions & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name=NibbleArray
version=0.2.7
version=0.2.8
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
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=*
Expand Down
2 changes: 1 addition & 1 deletion nibbleArray.cpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 6 additions & 6 deletions nibbleArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
//
// 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


#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
Expand All @@ -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.
Expand All @@ -43,7 +43,7 @@ class nibbleArray
private:
uint8_t * _arr;
uint16_t _size;
uint8_t _bytes = 0;
uint16_t _bytes = 0;
};


Expand Down
2 changes: 1 addition & 1 deletion test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading