8x8x8 Led Cube driven by 4x PCF8575 for the columns and 1x PCF8574 for the layers
led_cube.h@0:920c5ed65a45, 2012-09-08 (annotated)
- Committer:
- Bas
- Date:
- Sat Sep 08 22:14:10 2012 +0000
- Revision:
- 0:920c5ed65a45
- Child:
- 1:e08a4d27f534
updated the addressing of the columns. they are connected for best wiring, not in sequence of the PCF8575's
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bas | 0:920c5ed65a45 | 1 | #ifndef __LED_CUBE_H |
Bas | 0:920c5ed65a45 | 2 | #define __LED_CUBE_H |
Bas | 0:920c5ed65a45 | 3 | |
Bas | 0:920c5ed65a45 | 4 | #define VERSION 1.0 |
Bas | 0:920c5ed65a45 | 5 | |
Bas | 0:920c5ed65a45 | 6 | #include <mbed.h> |
Bas | 0:920c5ed65a45 | 7 | #include "pcf8574.h" |
Bas | 0:920c5ed65a45 | 8 | #include "pcf8575.h" |
Bas | 0:920c5ed65a45 | 9 | |
Bas | 0:920c5ed65a45 | 10 | #define PI 3.14159 |
Bas | 0:920c5ed65a45 | 11 | #define Xd 8 |
Bas | 0:920c5ed65a45 | 12 | #define Yd 8 |
Bas | 0:920c5ed65a45 | 13 | #define Zd 8 |
Bas | 0:920c5ed65a45 | 14 | #define centre 3.5 |
Bas | 0:920c5ed65a45 | 15 | #define Vd Xd*Yd*Zd |
Bas | 0:920c5ed65a45 | 16 | |
Bas | 0:920c5ed65a45 | 17 | #define SB(x,n) (x|=(1<<n)) |
Bas | 0:920c5ed65a45 | 18 | #define CB(x,n) (x&=~(1<<n)) |
Bas | 0:920c5ed65a45 | 19 | #define TB(x,n) (x^=(1<<n)) |
Bas | 0:920c5ed65a45 | 20 | #define PB(x,n) do{SB(x,n);CB(x,n);}while(0) |
Bas | 0:920c5ed65a45 | 21 | |
Bas | 0:920c5ed65a45 | 22 | class LED_CUBE |
Bas | 0:920c5ed65a45 | 23 | { |
Bas | 0:920c5ed65a45 | 24 | public: |
Bas | 0:920c5ed65a45 | 25 | LED_CUBE(I2C* _interface); |
Bas | 0:920c5ed65a45 | 26 | ~LED_CUBE(void); |
Bas | 0:920c5ed65a45 | 27 | |
Bas | 0:920c5ed65a45 | 28 | void clear_cube(void); |
Bas | 0:920c5ed65a45 | 29 | void setVoxel(unsigned char x, unsigned char y, unsigned char z); |
Bas | 0:920c5ed65a45 | 30 | void clearVoxel(unsigned char x, unsigned char y, unsigned char z); |
Bas | 0:920c5ed65a45 | 31 | unsigned char getVoxel(unsigned char x, unsigned char y, unsigned char z); |
Bas | 0:920c5ed65a45 | 32 | void copyColumn(unsigned char x, unsigned char y, unsigned char col); |
Bas | 0:920c5ed65a45 | 33 | void clearVoxels(void); |
Bas | 0:920c5ed65a45 | 34 | |
Bas | 0:920c5ed65a45 | 35 | private: |
Bas | 0:920c5ed65a45 | 36 | PCF8574 row; |
Bas | 0:920c5ed65a45 | 37 | PCF8575 colums_0_1; |
Bas | 0:920c5ed65a45 | 38 | PCF8575 colums_2_3; |
Bas | 0:920c5ed65a45 | 39 | PCF8575 colums_4_5; |
Bas | 0:920c5ed65a45 | 40 | PCF8575 colums_6_7; |
Bas | 0:920c5ed65a45 | 41 | unsigned char cubeData[64]; |
Bas | 0:920c5ed65a45 | 42 | Ticker duty; |
Bas | 0:920c5ed65a45 | 43 | void UpdateRow(void); |
Bas | 0:920c5ed65a45 | 44 | |
Bas | 0:920c5ed65a45 | 45 | }; |
Bas | 0:920c5ed65a45 | 46 | #endif |