Step 50Software: How it works
Communication between these two happens via a voxel array. This array has a bit for every LED in the LED cube. We will refer to this as the cube array or cube buffer from now on.
The cube array is made of 8x8 bytes. Since each byte is 8 bits, this gives us a buffer that is 8 voxels wide, 8 woxels high and 8 voxels deep (1 byte deep).
volatile unsigned char cube[8][8];
The interrupt routine reads from the cube array at given intervals and displays the information on the LED cube.
The effect functions writes the desired LED statuses to this array.
We did not use any synchronization or double buffering, since there is only one producer (either the effects currently running, or input from RS232) and one consumer (the interrupt-code that updates the cube). This means that some voxels could be from the next or previous "frame", but this is not a problem, since the frame rate is so high.
When working with micro controllers, code size is critical. To save code size and programming work, and to make the code easier to read, we have tried to write re-usable code as often as possible.
The LED cube code has a base of low level drawing functions that are used by the higher level effect functions. The draw functions can be found in draw.c. Draw functions include everything from setting or clearing a single voxel to drawing lines and wireframe boxes.
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|






























































































![Hard Wired LED Cube: [No Programming]](http://img.instructables.com/files/deriv/FTD/SF1T/GO8DC8KW/FTDSF1TGO8DC8KW.SQUARE.jpg)














