This is a remake of tetris game for mbed. Please see detail here http://developer.mbed.org/users/sucrelv/notebook/tetris-game-on-mbed
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed-rtos mbed wave_player
Shiftbrite/Shiftbrite.cpp@0:3b5e97ab5884, 2014-10-21 (annotated)
- Committer:
- sucrelv
- Date:
- Tue Oct 21 15:10:36 2014 +0000
- Revision:
- 0:3b5e97ab5884
initial upload
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sucrelv | 0:3b5e97ab5884 | 1 | #include "mbed.h" |
sucrelv | 0:3b5e97ab5884 | 2 | #include "Shiftbrite.h" |
sucrelv | 0:3b5e97ab5884 | 3 | |
sucrelv | 0:3b5e97ab5884 | 4 | |
sucrelv | 0:3b5e97ab5884 | 5 | |
sucrelv | 0:3b5e97ab5884 | 6 | |
sucrelv | 0:3b5e97ab5884 | 7 | Shiftbrite::Shiftbrite(PinName pin_e, PinName pin_l, PinName pin_do,PinName pin_di, PinName pin_clk): _pin_e(pin_e), _pin_l(pin_l), _spi(pin_do, pin_di, pin_clk) |
sucrelv | 0:3b5e97ab5884 | 8 | { |
sucrelv | 0:3b5e97ab5884 | 9 | SPI _spi(pin_do, pin_di, pin_clk); |
sucrelv | 0:3b5e97ab5884 | 10 | _pin_l=0; |
sucrelv | 0:3b5e97ab5884 | 11 | _pin_e=0; |
sucrelv | 0:3b5e97ab5884 | 12 | _spi.format(16,0); |
sucrelv | 0:3b5e97ab5884 | 13 | _spi.frequency(500000); |
sucrelv | 0:3b5e97ab5884 | 14 | } |
sucrelv | 0:3b5e97ab5884 | 15 | |
sucrelv | 0:3b5e97ab5884 | 16 | |
sucrelv | 0:3b5e97ab5884 | 17 | void Shiftbrite::RGB(int red, int green, int blue){ |
sucrelv | 0:3b5e97ab5884 | 18 | |
sucrelv | 0:3b5e97ab5884 | 19 | unsigned int low_color=0; |
sucrelv | 0:3b5e97ab5884 | 20 | unsigned int high_color=0; |
sucrelv | 0:3b5e97ab5884 | 21 | high_color=(blue<<4)|((red&0x3C0)>>6); |
sucrelv | 0:3b5e97ab5884 | 22 | low_color=(((red&0x3F)<<10)|(green)); |
sucrelv | 0:3b5e97ab5884 | 23 | _spi.write(high_color); |
sucrelv | 0:3b5e97ab5884 | 24 | _spi.write(low_color); |
sucrelv | 0:3b5e97ab5884 | 25 | _pin_l=1; |
sucrelv | 0:3b5e97ab5884 | 26 | _pin_l=0; |
sucrelv | 0:3b5e97ab5884 | 27 | |
sucrelv | 0:3b5e97ab5884 | 28 | } |
sucrelv | 0:3b5e97ab5884 | 29 | |
sucrelv | 0:3b5e97ab5884 | 30 |