GLCDcmd : GLCD libraries BackPack class

Hi, I made a Fast GLCD backpack device for myself and wanted to share with community.

It’s fully compatible with GLCD v3 Library. No code porting required for run current applications. Just change glcd header will do the job.
#include <GLCDcmd.h>
instead of
#include <glcd.h>

Currently only I2C protocol implemented.
Power and communication requires 4 wire to GLCD backpack device.

Wire library is available in the GLCDcmd package because arduino’s
wire library is defected. It doesn’t allow clock skewing. It is needed for GLCDSlave code other wise you can drop some of your packets.
Package has alternative Wire and twi files, needed to be replaced with arduino ones when you are compiling slave devices firmware.Master device doesn’t require the patch since it’s slave controlled mechanism so your device will work on any Arduino has un-patched Wire library.

Soon, I wanted to support Serial interface.
And thinking about to support one wire connection. But this requires OneWire slave code for arduino which is not available yet AFAIK…

It runs just %8 slower than native GLCD library as a overhead.
I use 20Mhz xtal for Slave device. It works faster and reduces the overhead.

Via GLCDcmd class, I2C connection : 13.88 fps
Via Native GLCD Library on arduino : 15.08 fps
So Only 1.2 fps difference.

I believe you will have faster times with speedy GLCDs. Since slave running on 20Mhz.

Slave device requires ~18Kb if you put all fonts in it that comes with GLCD library. But you can use ATmega168 too if you crop some fonts.

Only known limitation is that you cannot use fonts that stored at Master device. Library doesn’t allow any font upload to slave device now.


Here is the GLCDcmd library.

Special thanks to user mem for helps.

is it just an arduino acting as a controller?

Yes but it's less than "arduino". Just ATmega168 chip with 20Mhz xtal. Also a button for reset device, a variable resistor for brightness control, a resistor for led back light, and cap for the stability. Total budget is nearly ~$5.

what needs to be on the backpack device and what needs to be on the arduino sending the backback data.

Looks interesting.

On Backpack device, I use GLCDslave firmware at examples folder. That program implements all required functions for slave device via GLCD Library v3 Beta (you needed to have glcd v3 beta installed on your arduino too and you needed to patch Wire library bug 335 for proper slave device. You could simply change Wire files that provided with the GLCDcmd library )…

On master device, you just need GLCDcmd library installed on your arduino IDE. (No GLCD library needed!). You can use GLCDcmd library as a original “glcd” library. No difference on API side. I only add some extra functions like SetBacklight() and PulseBacklight() functions to control backlight led, driven by a PWM pin of slave device, nothing more…

All data prepare & sending function buried in the class. So you don’t need to touch any Wire protocols on master device code… For example open glcd library example “GLCDdemo” and change
#include <glcd.h>
line with
#include <GLCDcmd.h>
and compile it. Your device will draw same graphics via i2c port on backpack device. That’s all.

I will have to wire one up and play with it a little. :)

Very cool. I had thought about doing something very similar. Impressive that it is 90% the speed of the native interface. (Still quite a bit faster than the pre V3 GLCD library).

There are some things that you could do to speed it up quite a bit. For example, the GLCD low level timing could be tweaked to probably get you close to the stock V3 native timing.

If you are a bit more adventurous, you could use a write through read cache and get better performance than the native interface. It is a very small tweak to the low level glcd code to modify it to use a RAM buffer as a read cache. When used, writes go to both the RAM buffer and the physical display, but reads come from the "cache" (RAM buffer) instead, which is much faster than reading the memory inside the physical display.

UPDATE: The v3 glcd library now includes the read cache code. It was added in build 395 on March 10, 2011. RC1 built on March 24 has the read cache code in it.

It is disabled by default.

To turn it on all you need to do is modify the master config file (glcd/glcd_Config.h) and down near the bottom you will see the define GLCD_READ_CACHE. Uncomment that line to enable the read cache code. It will use an extra 1k of RAM which means you can not use a m168 but must jump up to a m328p. You can read the comment in the master config file for further details.

--- bill