Arduino ShiftBrite Library
0.1
An object for the control of ShiftBrite modules
|
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) |
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.
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.
ShiftBrite::ShiftBrite | ( | int | cPin, |
int | dPin, | ||
int | ePin, | ||
int | lPin | ||
) |
A constructor requiring inputs for the pins to be used for the ShiftBrite module.
cPin | an integer value representing the pin used to provide a clock source to the ShiftBrite module |
dPin | an integer value representing the pin used to transfer data to the ShiftBrite module |
ePin | an integer value representing the pin used to enable the ShiftBrite module |
lPin | an integer value representing the pin used to latch the ShiftBrite module |
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.
bytIn1 | a byte value representing the first byte to send to the ShiftBrite module |
bytIn2 | a byte value representing the second byte to send to the ShiftBrite module |
bytIn3 | a byte value representing the third byte to send to the ShiftBrite module |
bytIn4 | a byte value representing the fourth byte to send to the ShiftBrite module |
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.
iIn | an integer value representing the color of the module |
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.
intRed | an integer value in the range of zero to 1023(inclusive) representing the red component value of the color desired |
intGreen | an integer value in the range of zero to 1023(inclusive) representing the green component value of the color desired |
intBlue | an integer value in the range of zero to 1023(inclusive) representing the blue component value of the color desired |