Alyson Castiblanco
/
TETRISACT
ok
Fork of 00_01LAB_matrix8x8_fig_tetris1 by
Diff: main.cpp
- Revision:
- 0:61199d9d0aed
- Child:
- 1:b732136485e0
diff -r 000000000000 -r 61199d9d0aed main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 15 20:45:14 2017 +0000 @@ -0,0 +1,89 @@ + +#include "mbed.h" +//#include "max7219.h" + +// *************************************************************************** +// option 1 : use SPI +// *************************************************************************** +SPI deviceM(PB_15, PB_14, PB_13); +DigitalOut ssel (PB_12); + +#define uint8_t unsigned char + +uint8_t vcol[8]={0,0,0,0,0,0,0,0}; + +void sendSPI(uint8_t d1, uint8_t d2) +{ + deviceM.unlock(); + ssel=0; + deviceM.write(d1); + deviceM.write(d2); + ssel=1; + deviceM.lock(); +}; + + +void printMatrix(uint8_t* vC) + +{ + uint8_t i =0; + for (i=1;i<9;i++){ + sendSPI(i,*(vC+i)); + } + + }; + + +int main() { + sendSPI(0x0c,1); + sendSPI(0x0F,1); + wait (1); + sendSPI(0x0f,0); + wait (1); + int i =0; + while(1){ + i ++; + vcol[1]=i; + printMatrix(vcol); + wait(0.5); + } +} +// *************************************************************************** +// option two: use maz7219 library + +// *************************************************************************** +/* +Max7219 deviceM(PB_15, PB_14, PB_13, PB_12); + + +int main() { + + max7219_configuration_t cfg = { + .device_number = 1, + .decode_mode = 0, + .intensity = Max7219::MAX7219_INTENSITY_8, + .scan_limit = Max7219::MAX7219_SCAN_8 +}; + + deviceM.init_device(cfg); + + deviceM.enable_device(1); + + deviceM.set_display_test(); + wait(1); + deviceM.clear_display_test(); + wait(1); + + while(1){ + deviceM.write_digit(1,8,0b11111111); + deviceM.write_digit(1,1,0b01010101); + deviceM.write_digit(1,2,0b10101010); + deviceM.write_digit(1,3,0b01010101); + deviceM.write_digit(1,4,0b10101010); + deviceM.write_digit(1,5,0b01010101); + deviceM.write_digit(1,6,0b10101010); + deviceM.write_digit(1,7,0b01010101); + } +} +*/ +