(I've seen these questions (Convert Bytes to Int / uint in C and Converting Byte Array To Int24) but they seem more complicated than what I am trying to do, so I thought I would ask.)
I'm doing some LED matrix programming in Arduino/Wiring. For reasons probably not relevant here I have a byte array representing a "bit state" of a LED row, which I use to buffer the result of other operations. To actually set the LEDs (I'm using the Maxim 7219 chip), I need to derive an integer from the byte array.
Using the Arduino/Wiring bitWrite method, my little stripped down example routine below works but I am wondering if there is a C method which would be faster than looping.
byte dog[8] = {0,0,1,1,1,1,1,0};
byte cat;
for (int i = 0; i < 8; i++){
bitWrite(cat, i, dog[7-i]);
}