Shiftbrite class
Diff: Shiftbrite.cpp
- Revision:
- 0:8322a6c71e18
diff -r 000000000000 -r 8322a6c71e18 Shiftbrite.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Shiftbrite.cpp Wed Feb 13 05:52:25 2013 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "Shiftbrite.h" + + + + +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) +{ + SPI _spi(pin_do, pin_di, pin_clk); + _pin_l=0; + _pin_e=0; + _spi.format(16,0); + _spi.frequency(500000); +} + + +void Shiftbrite::RGB(int red, int green, int blue){ + + unsigned int low_color=0; + unsigned int high_color=0; + high_color=(blue<<4)|((red&0x3C0)>>6); + low_color=(((red&0x3F)<<10)|(green)); + _spi.write(high_color); + _spi.write(low_color); + _pin_l=1; + _pin_l=0; + + } + + \ No newline at end of file