GY-63_MS5611/libraries/NibbleArray/nibbleArray.h

50 lines
990 B
C
Raw Normal View History

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-11-10 13:53:12 -05:00
// VERSION: 0.2.2
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-11-10 13:53:12 -05:00
2021-01-29 06:31:58 -05:00
#include "Arduino.h"
2020-11-27 05:28:57 -05:00
2021-11-10 13:53:12 -05:00
#define NIBBLEARRAY_LIB_VERSION (F("0.2.2"))
2020-11-27 05:28:57 -05:00
#ifndef NIBBLEARRAY_MAXSIZE
2021-11-10 13:53:12 -05:00
// UNO BASED MAXSIZE?
#define NIBBLEARRAY_MAXSIZE 510
2016-12-17 14:59:03 -05:00
#endif
2021-11-10 13:53:12 -05:00
#define NIBBLEARRAY_OK 0x00
#define NIBBLEARRAY_ERROR_INDEX 0xFF
2016-12-17 14:59:03 -05:00
class nibbleArray
{
public:
2021-11-10 13:53:12 -05:00
nibbleArray(const uint16_t size);
2020-11-27 05:28:57 -05:00
~nibbleArray();
2021-11-10 13:53:12 -05:00
// return 0..F if ok
// returns 0xFF for index error.
uint8_t get(const uint16_t index);
// returns 0xFF for index error.
uint8_t set(const uint16_t index, uint8_t value);
uint16_t size() { return _size; };
uint16_t memory() { return _bytes; };
2016-12-17 14:59:03 -05:00
2020-11-27 05:28:57 -05:00
void clear();
2021-11-10 13:53:12 -05:00
void setAll(uint8_t value);
2016-12-17 14:59:03 -05:00
private:
2021-11-10 13:53:12 -05:00
uint8_t * _arr;
2020-11-27 05:28:57 -05:00
uint16_t _size;
2021-11-10 13:53:12 -05:00
uint8_t _bytes = 0;
2016-12-17 14:59:03 -05:00
};
2020-11-27 05:28:57 -05:00
2021-11-10 13:53:12 -05:00
2020-11-27 05:28:57 -05:00
// -- END OF FILE --