I have a code that I have in an Arduino environment that requires x (in increments of 8) Boolean values that manipulate at runtime for some shift register code. Therefore, I am currently using such a logical array:
#define number_of_shiftRegisters 220
#define numOfRegisterPins number_of_shiftRegisters * 8
boolean registers[numOfRegisterPins];
But I had about 200 (1600 Boolean) memory, and I did not know why, until I saw this, although the logical values are 1 bit, they are stored in 8 bits of data.
As I said, the number of bools needed always increases in increments of 8, so I don’t know if this can work in my interests.
Is there a more efficient way to store more than 1000 boolean values and can still reference them by index?
Or ... At least a more efficient memory that won't cost significantly more CPU time to install and repeat through?
I thought of an array char, and then a bit masked each char to access individual bits. But I did not know if there was an easier way, or if it would require significantly more processor time.
source
share