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.
Diff: sbDriver.h
- Revision:
- 4:d2f8ddb423e2
- Parent:
- 3:9376bf1f1bbd
- Child:
- 5:aa0424f31fa1
--- a/sbDriver.h Wed Aug 20 08:11:28 2014 +0000
+++ b/sbDriver.h Wed Aug 20 09:26:42 2014 +0000
@@ -3,28 +3,8 @@
#ifndef SHIFTBTIRE
#define SHIFTBTIRE
#include "mbed.h"
-//#include <string> // NOT string.h... hope this works with mbed
//REFER TO FRDM_LIGHTFX modules for hardware code
-//=============================================================================================
-//class frame{//Would this help?
- /*house a complete frame of data
- This would include a shiftBriteDisplay as a member
- The shiftBriteDisplay would then be fed a frame of data at a time
- OR
- would it be better to have a movie class, holding all frames, as an member in shiftBriteDisplay
- shiftBriteDisplay would then call loadFrame from the movie class
- Movie class is essentially an array of frames with a circular buffer type of implementation
-
- I think first option better as this would mean I can easily change movie content and have the movie
- in control of updating the frame etc.
-
-
- */
-
-//};
-//class movie{
- /*house several frames that can be played in sequence*/
-//};
+
//=============================================================================================
/** Colour class
@@ -99,14 +79,12 @@
* @code
#include "mbed.h"
#include "sbDriver.h"
- //This code is licenced as "BEERWARE" and used at own your own risk and discretion. Coded by Johan Kritzinger 8/2014.
- Serial PC(PTA2, PTA1);//Access to serial port for sending error messages
DigitalOut latch(PTC16);//to LI pin of shiftBrite module
DigitalOut enable(PTA13);//to EI pin of shiftBrite module
DigitalOut reset(PTC12);//to power control circuit of your doing - NOT MANDATORY
SPI spi(PTD2,NC,PTD1);//PDT2 = MOSI to DI and PDT1 to CI of shiftBrite module
- shiftBriteDisplay sbDisplay(&PC,latch, enable, reset, spi,6);//for, say, 6 modules wired in SERIES.
+ shiftBriteDisplay sbDisplay(latch, enable, reset, spi,6);//for, say, 6 modules wired in SERIES.
//If you wish to change the DOT CORR registers
sbDisplay.setCurrentCorr(0x78,0x64,0x64);//use values you want to set as default. These are the suggested values
@@ -133,15 +111,11 @@
* I suggest the first method is the best.
*
*
-*
-* TO DO:
-* See if thee is a better way to deal with the serial port.
-* Write a frame and movie class to abstract dealing with individual LED's
* @endnote
*/
class shiftBriteDisplay{
private:
- Serial *serial_p; // for debug printing
+ //Serial *serial_p; // for debug printing
//Harware control lines - common to all leds in display
DigitalOut sb_latch;
@@ -172,33 +146,51 @@
/**Constructor
See the example code for usage instructions.
*/
- shiftBriteDisplay (Serial *port,DigitalOut &latch, DigitalOut &enable, DigitalOut &reset, SPI &spiPort, unsigned int moduleCount); //constructor
+// shiftBriteDisplay (Serial *port,DigitalOut &latch, DigitalOut &enable, DigitalOut &reset, SPI &spiPort, unsigned int moduleCount); //constructor
+ shiftBriteDisplay (DigitalOut &latch, DigitalOut &enable, DigitalOut &reset, SPI &spiPort, unsigned int moduleCount); //constructor
// Destructor
~shiftBriteDisplay();//destructor - needs to release module_p
// Setters
/**used to set the colour for a specific dot (LED) using the RGB system. e.g. 0XFF0000 is full blue. I would suggest not using this
* unless you have no option because it only allows specifying 256 levels for each colour whereas the ShiftBright modules are
-* capable of 1024. Use the overloaded member function.
+* capable of 1024. Use the overloaded member function. Example:
+* @code
+ myDisplay.setLed(ledNum,0X007F00);//Set led module 'ledNum' to half brightness green
+ myDisplay.setLed(ledNum+1,0X00FF00); // Set module 'ledNum+1' to full brightness green
+ @endcode
*/
void setLed(unsigned int moduleNum, unsigned long int rgbValue);
/**used to set the colour for a specific dot (LED) using the full ability of the ShiftBrite modules. Each colour is supplied
-* individualy in the range of 0-1023 (0-0x3FF).
+* individualy in the range of 0-1023 (0-0x3FF). Example:
+* @code
+ myDisplay.setLed(ledNum,0,512,0);//Set led module 'ledNum' to half brightness green using a decimal no
+ myDisplay.setLed(ledNum+1,0,0x3FF,0); // Set module 'ledNum+1' to full brightness green using a hex no
+ @endcode
+
*/
void setLed(unsigned int moduleNum, unsigned short int red, unsigned short int green, unsigned short int blue);//Overloaded
// void setCurrentCorr( unsigned long int rgbValue=0x786464);//ALL modules
/** used to adjust the maximum current to each colour. Consists of 3 values, one each for red, green and blue.
* This allow you to adjust the brightness level of the reds, green and blues. Is usefull if one colour is brighter than the others
-* that causes colours to mix incorrectly. When used it will record the arguments as the default values.
+* that causes colours to mix incorrectly. When used it will record the arguments as the default values. Range is from 0 to 127 for each colour.
+* This equated to rought 30% to 100% full brightness. NOTE, This is NOT for setting the brightness of the display (even though
+* it can be abused that way), it is intended for adjusting the brightness balance between colours so that, for example, 0X3FF red and 0X3FF
+* green makes yellow and not reddy-yellow or greeny-yellow etc.
+* @code
+ myDisplay.setCurrentCorr(0x78,0x64,0x64); // set and record values as default. Retained only until master reset or powerdown.
+ @endcode
+*
*/
-
void setCurrentCorr( unsigned short int red, unsigned short int green, unsigned short int blue);//ALL modules
-/** same as above but call up the stored default values.
+/**Overloaded version of above but calls up the stored values.
+* These can either be the default (as Suggested by the ShiftBrite manufacturer) if they were not overwritten
+* with the alternate member function (above).
*/
void setCurrentCorr();//overload - meaning, read the vals from the class member and set accordingly
@@ -214,18 +206,39 @@
/**rotateLeft()
* is used to shift the whole display colours one step left.
*The first colour is rotated around and shifted in the last dot.
+* @code
+for(loop=0; loop !=NumOfLeds; loop++){
+ sbDisplay.rotateLeft();
+ sbDisplay.displayFrame();
+ wait(0.2);
+}
+* @endcode
*/
void rotateLeft();
/**shiftLeft()
* is used to shift the whole display colours one step left.
* A blank dot is shifted in.
+* @code
+for(loop=0; loop !=NumOfLeds; loop++){
+ sbDisplay.shiftLeft();
+ sbDisplay.displayFrame();
+ wait(0.2);
+}
+* @endcode
*/
void shiftLeft();//info shifted out is lost
/**rotateRight()
* is used to shift the whole display colours one step right.
*The first colour is rotated around and shifted in the last dot.
+* @code
+for(loop=0; loop !=NumOfLeds; loop++){
+ sbDisplay.rotateRight();
+ sbDisplay.displayFrame();
+ wait(0.2);
+}
+* @endcode
*/
void rotateRight();
@@ -233,6 +246,13 @@
/**shiftRight()
* is used to shift the whole display colours one step right.
* A blank dot is shifted in.
+* @code
+for(loop=0; loop !=NumOfLeds; loop++){
+ sbDisplay.shiftRight();
+ sbDisplay.displayFrame();
+ wait(0.2);
+}
+* @endcode
*/
void shiftRight();//info shifted out is lost