Presentation
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.
Code
#include "mbed.h"
#include "TFT_4DGL.h"
TFT_4DGL my_screen (p9, p10, p11); // serial tx, serial rx, reset pin;
Demo
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
Notes
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
Dear Stephane,
Thank you for your program and library, it allowed me to evaluate the effectiveness of mbed with a 4D TFT touch display. There are however a couple of minor points about the documentation.
It seems that you have written a wrapper around the SGC commands, where the mbed is the host microcontroller. This is in contrast to GFX, which creates a standalone module out of the display, and 4DGL is a programming language for GFX-based displays. Please find the definitions of SGC (Serial) and GFX (4DGL) platforms below, which has come from 4D Systems:
"(SGC) Serial Platform: The (SGC) Serial-Platform modules are based on the PICASO-SGC Serial Graphics Controller chip. In this mode, the PICASO-SGC becomes the slave device controlled by an external host controller. This allows you to develop your graphics applications using the host controller’s development platform and software tools. The PICASO-SGC chip has a rich set of serial commands built inside the chip and the commands are sent from the host controller via the serial (UART) interface. All it takes is a few bytes of serial data from the host controller and you can quickly and easily draw lines, circles, text and even display Images as well as play Video clips.
(GFX) 4DGL Platform: The (GFX) 4DGL-Platform modules are based on the PICASO-GFX2 Graphics Controller chip. In this mode, the PICASO-GFX2 becomes a standalone device and all application code is written in 4DGL (4D Graphics Language). Don't let the name scare you off, 4DGL is an easy to learn but a powerful high level language. It allows the developer to write applications in a high level syntax similar to popular languages such as BASIC, C and Pascal and run it directly on the PICASO-GFX2 processor. The (GFX) modules are stand alone devices. It allows the user to take complete control of all available resources on the module such as the Serial Port, the graphics display and the micro-SD memory card. It provides the user complete control over the display module allowing them to offload a lot of overhead from the host processor by creating the 'work horse' objects within the display module itself.
NOTE: There is only a single PICASO chip on the module. The chip can be configured to be either a PICASO-SGC or a PICASO-GFX2 by programming the appropriate PmmC configuration file (Personality module micro Code) in to the chip. Think of it as a soft silicon where the silicon can be reconfigured via the PmmC file."
Would it be possible to please change the references from 4DGL to 4D SGC in your documentation, to avoid confusion for other users?
Thanks and regards, Anna.