Skip to content

Commit bb44517

Browse files
committed
0.3.1 BoolArray
1 parent 0d635e6 commit bb44517

File tree

14 files changed

+149
-51
lines changed

14 files changed

+149
-51
lines changed

libraries/BoolArray/.github/workflows/arduino-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ jobs:
66
runs-on: ubuntu-latest
77
timeout-minutes: 5
88
steps:
9-
- uses: actions/checkout@v4
10-
- uses: arduino/arduino-lint-action@v1
9+
- uses: actions/checkout@v5
10+
- uses: arduino/arduino-lint-action@v2
1111
with:
1212
library-manager: update
1313
compliance: strict

libraries/BoolArray/.github/workflows/arduino_test_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
timeout-minutes: 20
99

1010
steps:
11-
- uses: actions/checkout@v4
11+
- uses: actions/checkout@v5
1212
- uses: ruby/setup-ruby@v1
1313
with:
1414
ruby-version: 2.6

libraries/BoolArray/.github/workflows/jsoncheck.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
paths:
66
- '**.json'
77
pull_request:
8+
paths:
9+
- '**.json'
810

911
jobs:
1012
test:
1113
runs-on: ubuntu-latest
1214
timeout-minutes: 5
1315
steps:
14-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1517
- name: json-syntax-check
1618
uses: limitusus/json-syntax-check@v2
1719
with:

libraries/BoolArray/BoolArray.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: BoolArray.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.3.0
4+
// VERSION: 0.3.1
55
// DATE: 2015-12-06
66
// PURPOSE: BoolArray library for Arduino
77
// URL: https://github.com/RobTillaart/BoolArray
@@ -19,6 +19,7 @@ BoolArray::BoolArray()
1919
{
2020
_array = NULL;
2121
_size = 0;
22+
_bytes = 0;
2223
}
2324

2425

@@ -35,12 +36,12 @@ uint8_t BoolArray::begin(const uint16_t size)
3536
{
3637
return BOOLARRAY_SIZE_ERROR;
3738
}
38-
// do we need to re-allocate?
39+
// do we need to re-allocate?
3940
if (_size != size)
4041
{
4142
_size = size;
4243
_bytes = (_size + 7) / 8;
43-
if (_array)
44+
if (_array)
4445
{
4546
free(_array);
4647
}
@@ -73,7 +74,7 @@ uint8_t BoolArray::setAll(const uint8_t value)
7374
if (_array == NULL) return BOOLARRAY_INIT_ERROR;
7475
uint8_t *p = _array;
7576
uint8_t t = _bytes;
76-
if (value == 0)
77+
if (value == 0)
7778
{
7879
while(t--) *p++ = 0;
7980
}
@@ -133,6 +134,7 @@ BoolArray32::BoolArray32()
133134
{
134135
_array = NULL;
135136
_size = 0;
137+
_bytes = 0;
136138
}
137139

138140

libraries/BoolArray/BoolArray.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: BoolArray.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.3.0
5+
// VERSION: 0.3.1
66
// DATE: 2015-12-06
77
// PURPOSE: BoolArray library for Arduino
88
// URL: https://github.com/RobTillaart/BoolArray.git
@@ -15,10 +15,10 @@
1515
#include "Arduino.h"
1616

1717

18-
#define BOOLARRAY_LIB_VERSION (F("0.3.0"))
18+
#define BOOLARRAY_LIB_VERSION (F("0.3.1"))
1919

2020
#ifndef BOOLARRAY_MAXSIZE
21-
#define BOOLARRAY_MAXSIZE (1250 * 8) // 8000
21+
#define BOOLARRAY_MAXSIZE (1250 * 8) // 10000
2222
#endif
2323

2424
#define BOOLARRAY_OK 0x00

libraries/BoolArray/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.3.1] - 2025-11-25
10+
- update GitHub actions
11+
- update readme.md (performance ESP32)
12+
- update examples
13+
- minor edits
14+
915
## [0.3.0] - 2024-04-10
1016
- made BOOLARRAY_MAXSIZE a -D command line define option
1117
- increased default BOOLARRAY_MAXSIZE to 1250 x 8 = 10000 booleans

libraries/BoolArray/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2015-2024 Rob Tillaart
3+
Copyright (c) 2015-2025 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

libraries/BoolArray/README.md

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,31 @@
1111

1212
# BoolArray
1313

14-
Arduino library for compact array of booleans of max size 2000 (UNO).
14+
Arduino library for compact array of booleans of max size 10000 (UNO R3).
1515

1616

1717
## Description
1818

1919
The BoolArray class allows the user to instantiate an array of booleans, allocating only one bit per element.
2020
For example one could create an array of 1000 throws with a coin. Normally this would take 1000 bytes,
21-
but BoolArray can store one throw in 1 bit, so 1000 throws in approx 125 bytes.
21+
but BoolArray can store one throw in 1 bit, so store the 1000 throws in approx 125 bytes.
2222

2323
The class is optimized for storage by packing 8 elements of the array in one byte.
2424
You need to check if your application needs more performance than this library can deliver.
2525

26-
#### Notes
26+
### Notes
2727

2828
The BoolArray class allocates dynamic memory.
2929
The **BOOLARRAY_MAXSIZE** is set to 10000 (booleans).
30-
This number is chosen as it is about the maximum one can allocate in one call on an UNO.
30+
This number is chosen as it is about the maximum one can allocate in one call on an UNO R3.
3131

3232
If one want to allocate more booleans, adjust the **BOOLARRAY_MAXSIZE**.
3333
This can be done as a command line option.
3434

3535
The library is tested on AVR architecture only.
3636

3737

38-
#### BoolArray32
38+
### BoolArray32
3939

4040
Since 0.3.0 a **BoolArray32** class is added - **experimental** for now.
4141

@@ -49,7 +49,7 @@ that are native 32 bit (not verified yet).
4949
On an Arduino UNO the **BoolArray32** class is slower.(verified).
5050

5151

52-
#### Related
52+
### Related
5353

5454
The BitArray library is one from a set of three:
5555

@@ -62,29 +62,31 @@ BoolArray is faster than BitArray as it only supports single bits and does not n
6262
of different bytes to read/write a value. However BoolArray currently only supports 2000 bits while
6363
BitArray can support more.
6464

65+
6566
## Performance
6667

67-
See **boolArrayDemo0.ino**
68+
Run **boolArrayDemo0.ino** to get your boards figures.
6869

6970
Indicative performance figures.
7071

7172
| class | function | UNO | ESP32 | Notes |
7273
|:--------------|:-----------:|:-------:|:--------:|:--------:|
73-
| BoolArray | set(0) | 10.37 | |
74-
| BoolArray | set(1) | 10.25 | |
75-
| BoolArray | get(i) | 16.03 | |
76-
| BoolArray | setAll(0) | 96 | | per 2000
77-
| BoolArray | setAll(1) | 100 | | per 2000
74+
| BoolArray | set(0) | 10.37 | 0.58 |
75+
| BoolArray | set(1) | 10.25 | 0.56 |
76+
| BoolArray | get(i) | 16.03 | 0.61 |
77+
| BoolArray | setAll(0) | 96 | 17 | per 2000
78+
| BoolArray | setAll(1) | 100 | 10 | per 2000
7879
| | | | |
79-
| BoolArray32 | set(0) | 15.97 | |
80-
| BoolArray32 | set(1) | 15.84 | |
81-
| BoolArray32 | get(i) | 24.20 | |
82-
| BoolArray32 | setAll(0) | 148 | | per 2000
83-
| BoolArray32 | setAll(1) | 144 | | per 2000
84-
85-
- UNO 16 MHz, ESP32 240 MHz.
80+
| BoolArray32 | set(0) | 15.97 | 0.56 |
81+
| BoolArray32 | set(1) | 15.84 | 0.54 |
82+
| BoolArray32 | get(i) | 24.20 | 0.59 |
83+
| BoolArray32 | setAll(0) | 148 | 12 | per 2000
84+
| BoolArray32 | setAll(1) | 144 | 8 | per 2000
85+
86+
- UNO 16 MHz (version 0.3.0)
87+
- ESP32 240 MHz (version 0.3.1)
8688
- toggle() is expected to be similar to set()
87-
- clear() is a wrapper around setAll(0) so similar.
89+
- clear() is a wrapper around setAll(0) so identical.
8890

8991

9092
## Interface
@@ -93,19 +95,21 @@ Indicative performance figures.
9395
#include "BoolArray.h"
9496
```
9597

96-
#### Constructor
98+
BoolArray32 is similar, uses uint32_t where BoolArray uses uint16_t.
99+
100+
### Constructor
97101

98102
- **BoolArray()** Constructor
99103
- **~BoolArray()** Destructor
100-
- **uint8_t begin(uint32_t size)** dynamically allocates size elements (8 booleans in one byte).
104+
- **uint8_t begin(uint16_t size)** dynamically allocates size elements (8 booleans in one byte).
101105
Returns **BOOLARRAY_OK** on success.
102106

103-
#### Meta
107+
### Meta
104108

105109
- **uint16_t size()** returns number of boolean elements.
106110
- **uint16_t memory()** returns number of bytes used.
107111

108-
#### Base
112+
### Base
109113

110114
The following functions return **BOOLARRAY_OK** on success.
111115

@@ -117,30 +121,38 @@ So one need to check these carefully.
117121
- **uint8_t toggle(uint16_t index)** Toggles element at index.
118122

119123

124+
## Error codes
125+
126+
| code | value | meaning |
127+
|:----------------------:|:--------:|:----------|
128+
| BOOLARRAY_OK | 0x00 |
129+
| BOOLARRAY_ERROR | 0xFF |
130+
| BOOLARRAY_SIZE_ERROR | 0xFE | index out of range
131+
| BOOLARRAY_INIT_ERROR | 0xFD | allocation error |
132+
133+
120134
## Future
121135

122136
#### Must
123137

124138
- improve documentation
125-
- add performance figures (UNO + ESP32)
126139

127140
#### Should
128141

129-
- performance test on ESP32
130-
- performance for **clear()** dedicated loop vs **setAll(0)** call
131142
- investigate template class
132-
- improve allocation (see PrintCharArray)
133143

134144
#### Could
135145

136-
- update examples.
146+
- add examples.
137147
- investigate **uint32_t array[N]** for BoolArray32 (ESP32?)
138148
- adjust math
139149

140150
#### Wont
141151

142152
- performance intern 16 bit instead of 8 bit is NOT faster on UNO
143-
153+
- strip tests in the functions for performance.
154+
- performance for **clear()** dedicated loop vs **setAll(0)** call
155+
- not faster.
144156

145157
## Support
146158

libraries/BoolArray/examples/boolArrayDemo0/boolArrayDemo0.ino

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "BoolArray.h"
99

1010

11-
BoolArray b;
11+
BoolArray32 b;
1212

1313
uint32_t start;
1414
uint32_t stop;
@@ -20,9 +20,11 @@ uint32_t duration1, duration2;
2020
void setup()
2121
{
2222
Serial.begin(115200);
23+
Serial.println();
2324
Serial.println(__FILE__);
2425
Serial.print("BOOLARRAY_LIB_VERSION:\t");
2526
Serial.println(BOOLARRAY_LIB_VERSION);
27+
Serial.println();
2628

2729
int rv = b.begin(2000);
2830
Serial.print("SIZE bits:\t");
@@ -55,7 +57,7 @@ void loop()
5557
void test0()
5658
{
5759
Serial.println();
58-
Serial.println("TEST SET(1)");
60+
Serial.println("TEST SET(true)");
5961
delay(10);
6062

6163
start = micros();
@@ -87,7 +89,7 @@ void test0()
8789
void test1()
8890
{
8991
Serial.println();
90-
Serial.println("TEST SET(0)");
92+
Serial.println("TEST SET(false)");
9193
delay(10);
9294

9395
start = micros();
@@ -159,14 +161,14 @@ void test3()
159161
b.set(i, 0);
160162
}
161163
duration1 = micros() - start;
162-
Serial.print("TEST SET(0):\t");
164+
Serial.print("TEST SET(false):\t");
163165
Serial.println(duration1);
164166
delay(10);
165167

166168
start = micros();
167169
b.setAll(0);
168170
duration2 = micros() - start;
169-
Serial.print("TEST SETALL(0):\t");
171+
Serial.print("TEST SETALL(false):\t");
170172
Serial.println(duration2);
171173
Serial.print("FACTOR:\t\t");
172174
Serial.println(1.0 * duration1 / duration2);
@@ -179,14 +181,14 @@ void test3()
179181
b.set(i, 1);
180182
}
181183
duration1 = micros() - start;
182-
Serial.print("TEST SET(1):\t");
184+
Serial.print("TEST SET(true):\t");
183185
Serial.println(duration1);
184186
delay(10);
185187

186188
start = micros();
187189
b.setAll(1);
188190
duration2 = micros() - start;
189-
Serial.print("TEST SETALL(1):\t");
191+
Serial.print("TEST SETALL(true):\t");
190192
Serial.println(duration2);
191193
Serial.print("FACTOR:\t\t");
192194
Serial.println(1.0 * duration1 / duration2);

0 commit comments

Comments
 (0)