GY-63_MS5611/libraries/NibbleArray
2021-04-07 13:31:22 +02:00
..
.github/workflows update libs 2021-04-07 13:31:22 +02:00
examples update libraries M..P 2020-11-27 11:28:57 +01:00
test 2021-01-29 2021-01-29 12:31:58 +01:00
.arduino-ci.yml 2021-01-29 2021-01-29 12:31:58 +01:00
keywords.txt 2021-01-29 2021-01-29 12:31:58 +01:00
library.json 2021-01-29 2021-01-29 12:31:58 +01:00
library.properties 2021-01-29 2021-01-29 12:31:58 +01:00
LICENSE 2021-01-29 2021-01-29 12:31:58 +01:00
nibbleArray.cpp 2021-01-29 2021-01-29 12:31:58 +01:00
nibbleArray.h 2021-01-29 2021-01-29 12:31:58 +01:00
README.md 2021-01-29 2021-01-29 12:31:58 +01:00

Arduino CI License: MIT GitHub release

nibbleArray

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). It can be seen as an uint4_t type.

The nibbleArray is an array that stores 2 nibbles in a byte therefor it is twice as small as a normal array.

The current implementation can hold 510 elements. This is due a limitation of the UNO which can alloc max 255 bytes in one malloc() call.

This NIBBLEARRAY_MAXSIZE can be defined compiletime "-D NIBBLEARRAY_MAXSIZE" or one can adjust it in the library if other platforms can allocate more memory.

Interface

The interface of the nibbleArray is straightforward:

  • nibbleArray(uint16_t size) constructor
  • set(index, value) set a value in the nibbleArray, index must be in range otherwise 0xFF will be returned.
  • get(index) get value from index, index must be in range otherwise 0xFF will be returned
  • size() returns the size of the array.
  • clear() set all elements to 0;
  • SetAll(value) set all elements to value (0..15)

Operation

See examples

Todo

  • todo's to issues
  • implement NIBBLEARRAY_ERROR_VALUE for set and setAll ??
  • allow larger allocations for non AVR, how?
  • setAll( f() ) - fill the array by calling a function n times?
  • align interface with boolArray and bitArray.