2020-11-27 05:28:57 -05:00
|
|
|
#pragma once
|
2016-12-17 14:59:03 -05:00
|
|
|
//
|
|
|
|
// FILE: nibbleArray.h
|
|
|
|
// AUTHOR: Rob Tillaart
|
2021-01-29 06:31:58 -05:00
|
|
|
// VERSION: 0.2.1
|
2020-11-27 05:28:57 -05:00
|
|
|
// PURPOSE: Arduino library for a compact array of nibbles (4 bits)
|
|
|
|
// URL: https://github.com/RobTillaart/nibbleArray
|
2016-12-17 14:59:03 -05:00
|
|
|
//
|
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#include "Arduino.h"
|
2020-11-27 05:28:57 -05:00
|
|
|
|
2021-01-29 06:31:58 -05:00
|
|
|
#define NIBBLEARRAY_LIB_VERSION "0.2.1"
|
2020-11-27 05:28:57 -05:00
|
|
|
|
|
|
|
#ifndef NIBBLEARRAY_MAXSIZE
|
|
|
|
#define NIBBLEARRAY_MAXSIZE 510
|
2016-12-17 14:59:03 -05:00
|
|
|
#endif
|
|
|
|
|
2020-11-27 05:28:57 -05:00
|
|
|
#define NIBBLEARRAY_OK 0x00
|
|
|
|
#define NIBBLEARRAY_ERROR_INDEX 0xFF
|
2016-12-17 14:59:03 -05:00
|
|
|
|
|
|
|
class nibbleArray
|
|
|
|
{
|
|
|
|
public:
|
2020-11-27 05:28:57 -05:00
|
|
|
nibbleArray(uint16_t size);
|
|
|
|
~nibbleArray();
|
|
|
|
|
|
|
|
// return 0..F if ok
|
|
|
|
// retuns 0xFF for index error.
|
|
|
|
uint8_t get(const uint16_t idx);
|
|
|
|
// retuns 0xFF for index error.
|
|
|
|
uint8_t set(const uint16_t idx, uint8_t value);
|
2016-12-17 14:59:03 -05:00
|
|
|
|
2020-11-27 05:28:57 -05:00
|
|
|
uint16_t size() { return _size; };
|
|
|
|
void clear();
|
|
|
|
void setAll(uint8_t val);
|
2016-12-17 14:59:03 -05:00
|
|
|
|
|
|
|
private:
|
2020-11-27 05:28:57 -05:00
|
|
|
uint8_t *arr;
|
|
|
|
uint16_t _size;
|
2016-12-17 14:59:03 -05:00
|
|
|
};
|
2020-11-27 05:28:57 -05:00
|
|
|
|
|
|
|
// -- END OF FILE --
|