I’m fortunate enough to live right down the street from Crystalfontz America (Crystalfontz.com), a supplier of high-quality LCD, OLED and other types of display modules. It is entirely thanks to their sponsorship of the current engineering project I’m apart of, that I now have the opportunity to work with their CFA835 graphical LED displays with integrated keypad.
For our project, we will be interfacing one of these displays to an Arduino Mega 2560 board. However, as you’ll see below, I’ll be utilizing an Arduino Uno for initial prototyping and testing purposes.
Testing The Display Via USB and CF Software
For initial evaluation of the display, I connected the CFA835 to my computer via USB. The USB connection on the board is located on the backside, next to the cutout:
There are several Crystalfontz provided software programs that are compatible with the CFA835, including:
- cfTest – Most handy one of all… allows full interaction with display.
- CFA835 Graphic Test – Demonstration of some graphical features.
- CFA835 Font Editor – Will convert windows font to CFA835 font format.
- CFA835 Video Encoder – Converts standard video files to compatible format.
Out of the above four programs, cfTest is extremely helpful for getting to know the display and its command sets. It also allows you to quickly test many of it’s available features, such as writing text, drawing (circles, rectangles, lines), clearing the display, adjusting both the display and keypad lighting (brightness/contrast), adjusting the four indicator LED’s on the left side of the board, etc.
Prior to connecting the display to the computer, you should first install the required driver, available here.
Once I had a good feel for the display, I moved onto interfacing it with the Arduino Uno.
Wiring For Serial Communication
Only four wired connections are needed, including +5V, Ground, Tx and Rx. The CFA835 data sheet shows the complete pin definitions, however, here are the four required ones for serial communication:
As of this writing, I only know of a single code sample for the Arduino, available here and here. It is a great piece of ready-to-use code, and it works well. The only bit of that code that may need to be changed are the serial pin assignments and also the baud rate. The baud rate can be change using the provided cfTest program listed above.
Arduino Library For CFA835
I’ve been working to greatly expand upon this base code with additional useful functions to take advantage of all the features the display has to offer. I’ve now completed a full-fledged library, which I will maintain the library code here:
Download Library (direct link): CFA835_Arduino
The following are the functions available in the library. The (*) symbol designates the functions written by Crystalfontz. The rest I have added.
CFA835_Arduino Library Functions:
- sendPacket() *
- writeText(x, y, text) *
- drawPixel(x, y, shade)
- drawCircle(x, y, radius, line, fill)
- drawLine(x1, y1, x2, y2, shade)
- drawRectangle(x, y, width, height, line, fill)
- setBacklights(lcdDisplay, keypad)
- setLED( LED, state)
- The following numerical values are returned for the respective action:
- 1 = KEY_UP_PRESS
- 2 = KEY_DOWN_PRESS
- 3 = KEY_LEFT_PRESS
- 4 = KEY_RIGHT_PRESS
- 5 = KEY_ENTER_PRESS
- 6 = KEY_EXIT_PRESS
- 7 = KEY_UP_RELEASE
- 8 = KEY_DOWN_RELEASE
- 9 = KEY_LEFT_RELEASE
- 10 = KEY_RIGHT_RELEASE
- 11 = KEY_ENTER_RELEASE
- monitorKeypress ()
- Bit values are as follows (add them up for combination presses):
- 1 = UP
- 2 = ENTER
- 4 = EXIT or CANCEL
- 8 = LEFT
- 16 = RIGHT
- 32 = DOWN
- Example: this function will return integer 6 for combo EXIT+ENTER buttons
- setCursorPosition(column, row)
- 0 = no cursor
- 1 = blinking block cursor
- 2 = underscore cursor
- 3 = blinking block plus underscore
- 4 = inverting, blinking block
Included with the library are two example scripts. Those being Keypad_Demo and Graphics_Demo.
Update: See this blog post from Crystalfontz about this project!
Questions? Feedback? Suggestions? (you’ll have to manually type this for SPAM protection)