Arduino ShiftBrite Library  0.1
An object for the control of ShiftBrite modules
Public Member Functions | Static Public Attributes | List of all members
ShiftBrite Class Reference

An object for the control of ShiftBrite modules. More...

Public Member Functions

 ShiftBrite ()
 
 ShiftBrite (int cPin, int dPin, int ePin, int lPin)
 
void setColor (int iIn)
 
void setColor (int intRed, int intGreen, int intBlue)
 
void sendCommand (byte bytIn1, byte bytIn2, byte bytIn3, byte bytIn4)
 

Static Public Attributes

static const int ON = 1
 
static const int WHITE = 1
 
static const int OFF = 0
 
static const int BLACK = 0
 
static const int RED = 2
 
static const int ORANGE = 3
 
static const int YELLOW = 4
 
static const int GREEN = 5
 
static const int BLUE = 6
 
static const int VIOLET = 7
 
static const int PURPLE = 7
 

Detailed Description

This object encapsulates methods for the control of ShiftBrite modules. This object contains a method to send commands to the module, as well as methods to change the color of the module in an intuitive manner.

This implementation was created using the V2.0 module available from Pololu at https://www.pololu.com/product/2162, however, this library is expected to work with ShiftBrite modules purchased from other sources. Note that this library was developed using the V2.0 module, and has only been tested with this version. This library may or may not work with other versions of ShiftBrite module.

Constructor & Destructor Documentation

ShiftBrite::ShiftBrite ( )

A default constructor requiring no arguments. If this constructor is used, then pins nine through 12(inclusive) are used to communicate with the ShiftBrite module.

Returns
a ShiftBrite object using pins nine through 12
ShiftBrite::ShiftBrite ( int  cPin,
int  dPin,
int  ePin,
int  lPin 
)

A constructor requiring inputs for the pins to be used for the ShiftBrite module.

Parameters
cPinan integer value representing the pin used to provide a clock source to the ShiftBrite module
dPinan integer value representing the pin used to transfer data to the ShiftBrite module
ePinan integer value representing the pin used to enable the ShiftBrite module
lPinan integer value representing the pin used to latch the ShiftBrite module
Returns
a ShiftBrite object using the pins specified

Member Function Documentation

void ShiftBrite::sendCommand ( byte  bytIn1,
byte  bytIn2,
byte  bytIn3,
byte  bytIn4 
)

A method to send data to the ShiftBrite module. ShiftBrite commands are four bytes, or 32 bits, long. The data is sent most significant bit first, beginning with byte one and ending with byte four. For general use this method should not be used. The setColor(int) or setColor(int, int, int) methods should be used instead. This method may be used to place the ShiftBrite module into command mode, which allows setting current control and other module parameters. For more details on the command format please see the ShiftBrite command format documentation, or consult the Allegro A6281 datasheet.

Parameters
bytIn1a byte value representing the first byte to send to the ShiftBrite module
bytIn2a byte value representing the second byte to send to the ShiftBrite module
bytIn3a byte value representing the third byte to send to the ShiftBrite module
bytIn4a byte value representing the fourth byte to send to the ShiftBrite module
Returns
NA
void ShiftBrite::setColor ( int  iIn)

A method to set the color of the ShiftBrite module, and/or turn the module on or off. This method is intended to be used with the constants defined in ShiftBrite.h, but will accept an integer value from zero to seven(inclusive). The use of an integer value outside the specified range will cause the module to be set to a default state, which is off. This command calls the setColor(int, int, int) method internally.

Parameters
iInan integer value representing the color of the module
Returns
NA
void ShiftBrite::setColor ( int  intRed,
int  intGreen,
int  intBlue 
)

A method to set the color of the ShiftBrite module, and/or turn the module on or off. This method requires three integer values representing the red, green, and blue components, respectively, of the color to be used. The values should be from zero to 1023(inclusive). If an integer outside this range is passed, the ShiftBrite module will flash five times in the color of the component with an invalid value. For example, if the first integer passed is 1073, the ShiftBrite module will flash red five times to indicate that the red component value is out of range. If multiple values are out of range the module will only flash for the first out of range value encountered, in the order of red, green, blue.

This method calls the sendCommand(byte, byte, byte, byte) method internally.

Parameters
intRedan integer value in the range of zero to 1023(inclusive) representing the red component value of the color desired
intGreenan integer value in the range of zero to 1023(inclusive) representing the green component value of the color desired
intBluean integer value in the range of zero to 1023(inclusive) representing the blue component value of the color desired
Returns
NA