I have some code I have in the Arduino environment that requires x (in increments of 8) boolean values that are manipulatable during run time for some shift register code. So currently I am using a boolean array like so:
#define number_of_shiftRegisters 220 //num of 8 bit shift registers
#define numOfRegisterPins number_of_shiftRegisters * 8 //number of booleans needed
boolean registers[numOfRegisterPins]; //boolean array
But I was running out of RAM around 200 (1600 booleans) and didn't know why until I saw that, even though booleans are 1 bit, they are stored in 8 bits of data.
As I said before, the number of bools needed is always in an increment of 8, so I don't know if that could work to my advantage.
Is there a more memory efficient way to store 1000+ boolean values and still be able to reference them by index?
Or... At least more memory efficient that will not cost significantly more CPU time to set and iterate through?
I had thought about a char
array, and then bit masking each char to access the individual bits. But I didn't know if there was an easier way, or if this would take up considerably more CPU time.