This is a simple Arduino library for use specifically with SparkFun Electronics' Color LCD Shield. It'll no doubt work with other incarnations of LCD breakouts and what not, you just might have to do some modifying of the pin defintions.
The Color LCD Shield interfaces your Arduino with a knock-off 132x132 Nokia 6100 LCD. The LCD is available with one of two controlling drivers - a Philips PCF8833 or an Epson S1D15G10. This library attempts to function with either of the controllers.
A really great resource for working with both the Epson and Philips controllers is Jim Lynch's Display Driver tutorial. Much of this example code stems from that document.
For a more in-depth look at this library, check out my Color LCD Shield Quickstart Guide on SparkFun.
Creative Commons Share-alike 3.0 (CC-BY SA 3.0). Use this code however you'd like, just keep this license and attribute. Let us know if you make hugely, awesome, great changes.
The code gives you access to the following LCD functions:
The library's constructor. An instance of the lcd must be created at the beginning of any code. e.g:
This initializes an LCD. Either EPSON or PHILLIPS should be passed as the type variable. This function should be called near the beginning of any sketch (setup()!). Turns on the display, sets the contrast and initializes the LCD into 12-bit RGB color mode.
An optional variable, colorSwap, is useful if your blues and reds are swapped. By default this boolean variable is 0, and you don't have to specify it. Try making it 1 if you need to fix colors though (through my experience, I've seen Philips controllers go both ways.
lcd.init(PHILIPS); // Initialize an LCD with a PHILIPS controller lcd.init(EPSON); // Initialize and LCD with an EPSON controller lcd.init(PHILIPS, 1); // Initialize with a PHILIPS controller, but swap all reds and blues.
Clears the entire screen, filling it with the 12-bit RGB color passed to it. There are a number of predefined colors in ColorLCDShield.h.
Manually adjusts the contrast. The setting variable is different for Philips or Epson LCDs.
For Philips, a signed value between -64 and 63 should be passed. I've found about -51 to work best.
For Epson, a value between 0 and 63 should be passed. 40 works pretty well for me.
Draws a single pixel at the specified x, y location. Color is a 12-bit RGB value.
Draws a circle centered around x0, y0, of the specified radius and color. Radius is in pixels, color is a 12-bit RGB value.
Sets a single character down at the specified x/y coordinate. You can pick both the foregroundand background color, they're 12-bit RGB values. Only one font is available in this library. Definitely room for growth, though at an added cost of memory.
Sets a string of characters down, beginning at x/y coordinates. You can pick both the foreground and background color, they're 12-bit RGB values. Only one font is available in this library. Definitely room for growth, though at an added cost of memory.
Draws a line from x0,y0 to x1,y1. Color is a 12-bit RGB value.
Draws a rectangle with opposing corners at x0,y0 and x1,y1. A 1 for fill will fill the entire rectangle, a 0 will only draw the border. Color is a 12-bit RGB value.
Prints the SparkFun logo. Good example of how to print a bitmap, though!
Turns the display on.
Turns the display off. You'll still see the backlight on!