This library is written to work with the ColourDuino (HCDVBD0015) development board. This Arduino compatible board is specifically designed to drive a 3 colour RGB LED dot matrix displays and uses an ATmega328p device loaded with the Arduino bootloader. This allows the development board to be programmed directly from the Arduino development environment (via a suitable TTL serial adaptor). For a suitable LED matrix please see the following item in our store (HCMODU0053). This librar,y together with the development board and previously mentioned RGB dot matrix module, will allow simple control of the display from an Arduino sketch including controlling individual LED's and scrolling numbers and text in different colours. Although the library can be used on it's own, it works best when used with out HCTimer2 library also found on this forum and most of the example sketches make use of this additional library.
You will need to download (please log in to download the library) and unzip this library to the Arduino development environments library area
On Windows:
My Documents\Arduino\libraries\
My Documents\Arduino\libraries\
My Documents\Arduino\libraries\
On Mac:
Documents/Arduino/libraries/
Documents/Arduino/libraries/
Documents/Arduino/libraries/
or similarly for Linux.
To use the library just include the HCColorDuino.h header file and create an instance of the ColorDuino library. E.g:
Code: Select all
HCColorDuino HCColorDuino;
Code: Select all
HCColorDuino.Refresh();
Code: Select all
HCColorDuino.RGBColourCorrection(R, G, B);
Code: Select all
HCColorDuino.print("Text");
Code: Select all
HCColorDuino.print(number);
Code: Select all
HCColorDuino.print(number, decimalPlace);
Code: Select all
HCColorDuino.ClearMatrix();
Code: Select all
HCColorDuino.SetFontFG(R, G, B);
Code: Select all
HCColorDuino.SetFontBG(R, G, B);
Code: Select all
HCColorDuino.SetBG(R, G, B);
Code: Select all
Plot(R, G, B, col, row);
Code: Select all
HCColorDuino.ScrollOn(StartPos, StopPos, Speed, ScrollType);
StartPos sets the column start position to start scrolling from.
StopPos sets the column position to scroll to.
Speed sets the scroll speed. Valid values are from 0 to 255.
ScrollType sets how the text will be scrolled. SCROLLOFF will stop scrolling the text. SINGLESHOT will scroll the text to the specified end point and then stop. CONTINUOUS will scroll to the specified end point and then start at the beginning again.
Code: Select all
HCColorDuino.ScrollOff();
Code: Select all
HCColorDuino.GetScrollPos();
Code: Select all
HCColorDuino.ClearBuffer();
Code: Select all
HCColorDuino.DisplayPos(Position);
Example sketch:
Code: Select all
/* FILE: Hello_World.cpp
DATE: 16/07/14
VERSION: 0.1
AUTHOR: Andrew Davies
This is a basic example of how to use the ColourDuino module (HCDVBD0015 & HCMODU0053)
together with the HCColorDuino library to display a simple scrolling text message.
You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/
/* Include the HCColorDuino library */
#include "HCColorDuino.h"
/* Create an instance of the library */
HCColorDuino HCColorDuino;
void setup()
{
/* Calibrate the LED matrix display for differences in RGB luminace */
HCColorDuino.RGBColourCorrection(25, 63, 63);
/* Set the RGB colour of the font. Valid values are from 0 to 255 for
each colour */
HCColorDuino.SetFontFG(0,0,255);
/* Set the RGB colour of the fonts background. */
HCColorDuino.SetFontBG(10,0,0);
/* Turn on continuous auto-scrolling. Scroll from position 0 to 111
at a scroll speed of 230 (255 max) */
HCColorDuino.ScrollOn(0, 111, 230, CONTINUOUS);
}
/* Main program */
void loop()
{
/* Write some text to the character buffer */
HCColorDuino.print("HELLO WORLD!");
while(1)
{
/* Continuously refresh the the LED matrix */
HCColorDuino.Refresh();
delay(1);
}
}
Code: Select all
/* FILE: Hello_World_Using_HCTimer2.cpp
DATE: 16/07/14
VERSION: 0.1
AUTHOR: Andrew Davies
This is a basic example of how to use the ColourDuino module (HCDVBD0015 & HCMODU0053)
together with the HCColorDuino and HCTimer2 library to display a simple scrolling text
message. By using the HCTimer2 library the hardware timer 2 can be re-tasked to refresh
the matrix display in the background.
You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/
/* Include the HCTimer2 library */
#include <HCTimer2.h>
/* Include the HCColorDuino library */
#include "HCColorDuino.h"
/* Create an instance of the library */
HCColorDuino HCColorDuino;
void setup()
{
/* Calibrate the LED matrix display for differences in RGB luminace */
HCColorDuino.RGBColourCorrection(25, 63, 63);
/* Set the RGB colour of the font. Valid values are from 0 to 255 for
each colour */
HCColorDuino.SetFontFG(0,0,255);
/* Set the RGB colour of the fonts background. */
HCColorDuino.SetFontBG(10,0,0);
/* Turn on continuous auto-scrolling. Scroll from position 0 to 111
at a scroll speed of 230 (255 max) */
HCColorDuino.ScrollOn(0, 111, 230, CONTINUOUS);
/* Initialise the HCTimer2 library with a 2.4mS interval */
HCTimer2Init(T2_CLK_DIV_256, 150);
}
/* Main program */
void loop()
{
/* Display some text */
HCColorDuino.print("HELLO WORLD!");
/* Nothing else to do ! */
while(1);
}
/* Refresh the matrix display in the background */
void HCTimer2()
{
HCColorDuino.Refresh();
}
Library: This library can be used as is, but is best used in conjunction with our HCTimer2 library found here: http://forum.hobbycomponents.com/viewto ... =43&t=1336
This additional library is also needed for some of the example sketches.