8x8x8 Led Cube driven by 4x PCF8575 for the columns and 1x PCF8574 for the layers
Diff: led_cube.h
- Revision:
- 0:920c5ed65a45
- Child:
- 1:e08a4d27f534
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/led_cube.h Sat Sep 08 22:14:10 2012 +0000 @@ -0,0 +1,46 @@ +#ifndef __LED_CUBE_H +#define __LED_CUBE_H + +#define VERSION 1.0 + +#include <mbed.h> +#include "pcf8574.h" +#include "pcf8575.h" + +#define PI 3.14159 +#define Xd 8 +#define Yd 8 +#define Zd 8 +#define centre 3.5 +#define Vd Xd*Yd*Zd + +#define SB(x,n) (x|=(1<<n)) +#define CB(x,n) (x&=~(1<<n)) +#define TB(x,n) (x^=(1<<n)) +#define PB(x,n) do{SB(x,n);CB(x,n);}while(0) + +class LED_CUBE +{ +public: + LED_CUBE(I2C* _interface); + ~LED_CUBE(void); + + void clear_cube(void); + void setVoxel(unsigned char x, unsigned char y, unsigned char z); + void clearVoxel(unsigned char x, unsigned char y, unsigned char z); + unsigned char getVoxel(unsigned char x, unsigned char y, unsigned char z); + void copyColumn(unsigned char x, unsigned char y, unsigned char col); + void clearVoxels(void); + +private: + PCF8574 row; + PCF8575 colums_0_1; + PCF8575 colums_2_3; + PCF8575 colums_4_5; + PCF8575 colums_6_7; + unsigned char cubeData[64]; + Ticker duty; + void UpdateRow(void); + +}; +#endif \ No newline at end of file