I have to implement a set of serial shift registers with each 8 outputs. The outputs are connected to switches, so I'm currently using boolean arrays in C that either turn the switch on (true) or off(false).
So each shift register has an array of 8 boolean values, which is in fact a 8 bit unsigned integer. I could continue to work with arrays but I assume thats a lot slower then just bitwise manipulating the integer. Also passing the integer to the SPI interface is a lot easier than an array.
Is there an easy way to convert boolean arrays into integers or manipulate the integers in the same way I could manipulate an array?
I.e.:
bool switch[8];
switch[0] = True; //Switch 1 on
switch[1] = False; //Switch 2 off
...
is the same as
uint8_t switch;
switch = 0b00000001;
But is harder to read and program when thinking in individual switches.
Performance is key, since my SPI needs to be very fast.