2015-12-07 13:56:21 -05:00
|
|
|
#ifndef BoolArray_H
|
|
|
|
#define BoolArray_H
|
|
|
|
//
|
|
|
|
// FILE: BoolArray.h
|
|
|
|
// AUTHOR: Rob dot Tillaart at gmail dot com
|
2017-04-28 04:34:30 -04:00
|
|
|
// VERSION: 0.1.3
|
2015-12-07 13:56:21 -05:00
|
|
|
// PURPOSE: BoolArray library for Arduino
|
|
|
|
// HISTORY: See BoolArray.cpp
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
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.
|
2015-12-07 13:56:21 -05:00
|
|
|
//
|
|
|
|
|
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
|
|
|
#include "Arduino.h"
|
|
|
|
#else
|
|
|
|
#include "WProgram.h"
|
|
|
|
#endif
|
|
|
|
|
2017-04-28 04:34:30 -04:00
|
|
|
#define BOOLARRAY_LIB_VERSION "0.1.3"
|
2015-12-07 13:57:27 -05:00
|
|
|
#define BOOLARRAY_MAXSIZE (250*8)
|
2015-12-22 04:16:44 -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:
|
2015-12-07 13:57:27 -05:00
|
|
|
BoolArray();
|
2015-12-07 13:56:21 -05:00
|
|
|
~BoolArray();
|
|
|
|
|
|
|
|
uint8_t begin(const uint16_t size);
|
2015-12-22 04:16:44 -05:00
|
|
|
uint8_t clear();
|
|
|
|
uint8_t setAll(const uint8_t value);
|
2015-12-07 13:56:21 -05:00
|
|
|
uint8_t get(const uint16_t idx);
|
2015-12-22 04:16:44 -05:00
|
|
|
uint8_t set(const uint16_t idx, const uint8_t value);
|
2017-04-28 04:34:30 -04:00
|
|
|
uint8_t toggle(const uint16_t idx);
|
2015-12-07 13:56:21 -05:00
|
|
|
|
|
|
|
private:
|
2015-12-22 04:16:44 -05:00
|
|
|
uint8_t * _ar;
|
2015-12-07 13:56:21 -05:00
|
|
|
uint16_t _size;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|