Huh?
Lets make the math a little easier, say an 8x8x8 cube.
For each layer, you then have 8 bytes that represent the states of the LEDs in that layer.
Once a millisecond:
You turn off output enable, send out the 8 bytes for layerX, turn on the anodes for that layer
While waiting for the next millisecond, you update the layers data
So shifting out 9 bytes at 4 MHz will be pretty quick, do the math on it.
9 bytes, 8 bits/byte = 72 bits, something like 0.018mS?
So lots of time in between layer updates to do other stuff,
and whole still updated every 8mS.
Array refresh something like this:
// define these prior to void setup, put some data in if wanted
byte layer0[] = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000}; // 1 LED on in each byte
byte layer1[] = {B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000, B00000001}; //
:
:
layer7[] = {B10000000, B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000}; //
// these will not change and turn on the layers
anodes[] = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000}; // 1 anode on at a time
now put that in a loop as described above
[code]
// assumes that 8 layer shift registers and the anode shift register are daisy chained, with the OE pin controlled also
currentMillis = millis();
if ((currentMillis - previousMillis) >= interval){ // interval like 1 or 2 milliseconds
previousMillis = previousMillis + interval;
digitalWrite (OE, HIGH); // turn off all drives
layerCount = layerCount +1;
if (layerCount ==8){ layerCount = 0;} // reset to bottom layer
// there's a better way to do this, but:
switch (layerCount){
case 0:
digitalWrite (shiftRegSS, LOW);
for (int x = 0; x<8; x=x+1){
SPI.transfer(layer0[x]);
}
SPI.transfer (anodes[x]);
digitalWrite (shiftRegSS, HIGH);
digitalWrite(OE, LOW);
break;
:
:
case 7:
digitalWrite (shiftRegSS, LOW);
for (int x = 0; x<8; x=x+1){
SPI.transfer(layer7[x]);
}
SPI.transfer (anodes[x]);
digitalWrite (shiftRegSS, HIGH);
digitalWrite(OE, LOW);
break;
} // end switch
} // end time check
// do whatever you're gonna to update the layer arrays, like making all the bits that represent a face high
} // end loop
[/code]