0.1.05 - added board dependant max # segments (thanks bricoleau)

This commit is contained in:
rob tillaart 2015-12-07 21:05:45 +01:00
parent 279b0bd9b2
commit 8ff93f5c5a
2 changed files with 33 additions and 6 deletions

View File

@ -1,13 +1,14 @@
//
// FILE: BitArray.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.04
// VERSION: 0.1.05
// PURPOSE: BitArray library for Arduino
// URL: http://forum.arduino.cc/index.php?topic=361167
//
// Released to the public domain
//
// 0.1.05 - added board dependant max # segments (thanks bricoleau)
// 0.1.04 - improve performance
// 0.1.03 - refactoring
// 0.1.02 - first stabile version (at last)

View File

@ -3,7 +3,7 @@
//
// FILE: BitArray.h
// AUTHOR: Rob dot Tillaart at gmail dot com
// VERSION: 0.1.04
// VERSION: 0.1.05
// PURPOSE: BitArray library for Arduino
// HISTORY: See BitArray.cpp
//
@ -12,7 +12,7 @@
// BitArray allows you to make a compact array of objects with a size
// expressed in bits. typically 1..10.
// The interface uses uint32_t as that will be enough for most purposes.
// The main requirement is to optimize storage space
// The main requirement is to optimize storage space
// the total space may not exceed 256 bytes.
//
// Originally created to store lot of numbers between 1..6 dice rolls
@ -26,11 +26,37 @@
#include "WProgram.h"
#endif
#define BITARRAY_LIB_VERSION "0.1.04"
#define BA_MAX_SEGMENTS 8
#define BITARRAY_LIB_VERSION "0.1.05"
#define BA_SEGMENT_SIZE 200
// max memory is board type dependant
// note the bitArray does not use all of the RAM
// 1K - max 600
#if defined(__AVR_ATmega168__)
#define BA_MAX_SEGMENTS 3
// 2K - max 1600
#elif defined(__AVR_ATmega328P__)
#define BA_MAX_SEGMENTS 8
// 8K - max 7000
#elif defined(__AVR_ATmega1280__)
#define BA_MAX_SEGMENTS 35
// 8K - max 7000
#elif defined(__AVR_ATmega2560__)
#define BA_MAX_SEGMENTS 35
// 1.25K - max 800
#elif defined(__AVR_ATmega16U4__)
#define BA_MAX_SEGMENTS 4
// 2.5K - max 2000
#elif defined(__AVR_ATmega32U4__)
#define BA_MAX_SEGMENTS 10
// 96K (64 + 32) DUE...
#elif defined(__SAM3X8E__)
#define BA_MAX_SEGMENTS 100
// default max 1000
#else
#define BA_MAX_SEGMENTS 5
#endif
#define BA_ERR 0xFFFFFFFF
#define BA_OK 0x00
#define BA_NO_MEMORY 0x01