GY-63_MS5611/libraries/BoolArray/BoolArray.h

51 lines
1.1 KiB
C
Raw Normal View History

2020-11-27 05:10:47 -05:00
#pragma once
2015-12-07 13:56:21 -05:00
//
// FILE: BoolArray.h
2020-11-27 05:10:47 -05:00
// AUTHOR: Rob Tillaart
2021-01-29 06:31:58 -05:00
// VERSION: 0.2.3
2015-12-07 13:56:21 -05:00
// PURPOSE: BoolArray library for Arduino
2020-11-27 05:10:47 -05:00
// URL: https://github.com/RobTillaart/BoolArray.git
2017-04-28 04:34:30 -04:00
// BoolArray implement a compact array of booleans of max size 2000.
// For larger arrays one need to modify the code, or use BitArray.
2020-11-27 05:10:47 -05:00
// Tested on AVR only
2015-12-07 13:56:21 -05:00
2021-01-29 06:31:58 -05:00
2015-12-07 13:56:21 -05:00
#include "Arduino.h"
2021-01-29 06:31:58 -05:00
#define BOOLARRAY_LIB_VERSION (F("0.2.3"))
#define BOOLARRAY_MAXSIZE (250 * 8)
#define BOOLARRAY_OK 0x00
#define BOOLARRAY_ERROR 0xFF
#define BOOLARRAY_SIZE_ERROR 0xFE
#define BOOLARRAY_INIT_ERROR 0xFD
2015-12-07 13:56:21 -05:00
class BoolArray
{
public:
2021-01-29 06:31:58 -05:00
BoolArray();
~BoolArray();
uint8_t begin(const uint16_t size);
2015-12-07 13:56:21 -05:00
2021-01-29 06:31:58 -05:00
uint16_t size() { return _size; };
uint16_t memory() { return (_size + 7) / 8; };
2020-11-27 05:10:47 -05:00
2021-01-29 06:31:58 -05:00
uint8_t setAll(const uint8_t value);
uint8_t clear() { return setAll(0); };
uint8_t get(const uint16_t index);
uint8_t set(const uint16_t index, const uint8_t value);
uint8_t toggle(const uint16_t index);
2015-12-07 13:56:21 -05:00
private:
2021-01-29 06:31:58 -05:00
uint8_t masks[8] = {1, 2, 4, 8, 16, 32, 64, 128};
uint8_t * _ar;
uint16_t _size;
2015-12-07 13:56:21 -05:00
};
2020-11-27 05:10:47 -05:00
// -- END OF FILE --