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

55 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
2023-10-18 10:27:05 -04:00
// VERSION: 0.2.8
// DATE: 2015-12-06
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
2022-10-29 11:05:43 -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.
// 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
2023-10-18 10:27:05 -04:00
#define BOOLARRAY_LIB_VERSION (F("0.2.8"))
2021-01-29 06:31:58 -05:00
2021-10-19 08:40:20 -04:00
#define BOOLARRAY_MAXSIZE (250 * 8) // 2000
2021-01-29 06:31:58 -05:00
#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
2023-02-08 11:14:17 -05:00
uint16_t size();
uint8_t memory();
2020-11-27 05:10:47 -05:00
2021-01-29 06:31:58 -05:00
uint8_t setAll(const uint8_t value);
2023-02-08 11:14:17 -05:00
uint8_t clear();
2021-01-29 06:31:58 -05:00
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-12-14 08:48:42 -05:00
uint8_t _masks[8] = {1, 2, 4, 8, 16, 32, 64, 128};
uint8_t * _array;
2023-02-08 11:14:17 -05:00
uint16_t _size = 0;
2021-10-19 08:40:20 -04:00
uint8_t _bytes = 0;
2015-12-07 13:56:21 -05:00
};
2022-10-29 11:05:43 -04:00
2023-02-08 11:14:17 -05:00
// -- END OF FILE --
2022-10-29 11:05:43 -04:00