Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE PinDetect mbed
Shiftbrite.h
00001 #include "mbed.h" 00002 00003 //Setup a new class for a Shiftbrite RGB LED module 00004 class Shiftbrite 00005 { 00006 public: 00007 Shiftbrite(PinName pin_e, PinName pin_l, PinName pin_do, PinName pin_di, PinName pin_clk); 00008 void write(int red, int green, int blue); 00009 00010 private: 00011 //class sets up the pins 00012 DigitalOut _pin_e; 00013 DigitalOut _pin_l; 00014 SPI _spi; 00015 }; 00016 00017 Shiftbrite::Shiftbrite(PinName pin_e, PinName pin_l, PinName pin_do, PinName pin_di, PinName pin_clk) 00018 : _pin_e(pin_e), _pin_l(pin_l), _spi(pin_do, pin_di, pin_clk) 00019 { 00020 _spi.format(16,0); 00021 _spi.frequency(500000); 00022 _pin_e=0; 00023 _pin_l=0; 00024 } 00025 00026 void Shiftbrite::write(int red, int green, int blue) 00027 { 00028 _pin_e=0; 00029 _pin_l=0; 00030 unsigned int low_color=0; 00031 unsigned int high_color=0; 00032 high_color=(blue<<4)|((red&0x3C0)>>6); 00033 low_color=(((red&0x3F)<<10)|(green)); 00034 _spi.write(high_color); 00035 _spi.write(low_color); 00036 _pin_l=1; 00037 _pin_l=0; 00038 }
Generated on Sat Sep 3 2022 16:28:26 by
1.7.2