This page presents a library to use a 3,2" touch screen from 4D Systems (http://www.4dsystems.com.au/) in Australia. The screen details are :
- Low-cost LCD display graphics user interface solution.
- 240 x 320 QVGA resolution, 65K true to life colours, TFT screen.
- Display Viewing Area: 48.6 x 64.8mm
- Integrated 4-Wire resistive Touch Panel.
- Easy 5 pin interface to any host device: VCC, TX, RX, GND, RESET.
- Asynchronous hardware serial port, TTL interface, with 300 baud to 256K baud.
- Powered by the 4D-Labs PICASO-SGC processor (also available as separate OEM IC for volume users).
- On-board micro-SD memory card adaptor for multimedia storage and data logging purposes. HC card support is also available for cards 4Gb and larger.
- DOS compatible file access (FAT16 format) as well as low level access to card memory.
- Dedicated PWM Audio pin supports FAT16 audio WAV files and complex sound generation.
- On-board audio amplifier with a tiny 8 Ohms speaker for sound generation and WAV file playback.
- Comprehensive set of built in high level graphics functions and algorithms that can draw lines, circles, text, and much more.
- Display full colour images, animations, icons and video clips.
- Supports all available Windows fonts and characters (imported as external fonts).
- 16 x General Purpose I/O pins. Upper 8 bits can be used as an I/O Bus for fast 8-bit parallel data transfers.
- 2 x 30 pin headers for I/O expansion and future plug-in daughter boards.
- 4.0V to 5.5V range operation (single supply).
- Module dimensions: 55.1 x 77.0 x 13.8mm (not including mounting tabs).
- 4 x snap-off mounting tabs with 3mm holes for mechanical support.
- RoHS Compliant.
Connecting the screen¶
- You will need to power the screen with 5V. Beware! Some screens need more power than the computer USB link can provide. For my screen, I had to use an external 5V source.
- If you use an external power source, make sure the mbed ground and external power ground are linked otherwise the serial commands will not be received correctly by the screen.
- Use one of the three Serial pairs of pins (p9, p 10) (p13, p14) or (p27, p28) from the mbed to connect them with the screen.
- Use one pin for reseting the screen.
4D SGC Library¶
You can import the 4D SGC library from here :
This is a library for 4DGL screens from 4D Systems in Autralia (http://www.4dsystems.com.au). Most graphic, touch and text functions are supported
To use it, you just have to insert the header file TFT_4DGL.h in your main.cpp and create an object using the TFT_4DGL class.
#include "mbed.h" #include "TFT_4DGL.h" TFT_4DGL my_screen (p9, p10, p11); // serial tx, serial rx, reset pin;
Even simpler, you can import this demo :
Work in progress¶
- The library has to be documented for clarity
- About 60% of the screen functions are supported, there are still some developpement work
There is a modified version of this library available which corrects the following assert
"*** assertion failed: 0, file serial_api.c, line 115". It can be found here:
Fixed a few minor issues in 4DGL library Moved pc serial port object used for debug output into 4DGL object itself. Previously it was a global object but its constructor wasn't getting run before the global constructor for the 4DGL object itself which led to an assert in the serial code. I also fixed a few potential buffer overruns that I saw in the code as well.
Forum thread discussing issue can be found here