by Gabi M.
Introduction
This article is a re-write of the Amicus18 posted articles "LS020-Sharp-TFT-display-driver" and represents a Proton+ port of the original code written by Hagen Reddmann (HaReddmann At T-Online dot de) and it is using the font files that are created with the FontEditor program , also written by Hagen Reddmann.
I will omit the description of programming for the TFT LS020, as there are sites that have dedicated a special importance to this type of graphic display. You might want to look though at Christian’s Krantz article .
Here, with Proton+ compiler and the possibility of using different type of micro controllers one can achieve some new functions like embedding full screen images in the code (i.e. using "ACCESS_UPPER_64K = On") and many more.
What I personally like in this code approach is that:
- Fonts to be used can be: multi-colored , compressed or un-compressed, proportional or fixed width, and practically “any” font in size and shape can be imported;
- It can be transposed to virtually any graphic LCD, and I will show you in a future article the port for the Nokia 3310.
HARDWARE
We have used for our tests an LS020 mounted display on a Amicus18 shield type of board, on which we had to make some small modifications to the connecting pins between the two boards. To begin with, I drew (by hand because of lack of time ) the schematic pin connections of each plate, as you would see it in a vertical overlap.
Result expected
After compilation and programming the board (as further explained in this article) will get the results that can be seen in the following clip:
Positioning data on the display (display mapping)
Screen dimensions for this type of display are 172 x 136 pixels. Being a rectangular display type can be used both in "landscape" format and "portrait".
Also, each type of format mentioned above can also be used in "mirror", resulting in four modes of positioning coordinates of reference.
To set this in code we use two variables, namely the "Mirror" and "Rotate" , and the combination are as follows:
Code:
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; T F T M A P P I N G - O P T I O N S S E C T I O N S
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Screen positioning modes
(*
0 ----------------- > X HORIZONTAL MODE
|
| +------------+-+
| | | | MIRROR = 0
| | | | ROTATE = 0
| | | | X = 176
| +------------+-+ Y = 132
Y
^ Y HORIZONTAL MODE
+------------+-+ |
| | | | MIRROR = 1
| | | | ROTATE = 0
| | | | X = 176
+------------+-+ | Y = 132
|
X ---------------- 0 VERTICAL MODE
|
+------------+-+ |
| | | | MIRROR = 0
| | | | ROTATE = 1
| | | | X = 132
+------------+-+ | Y = 176
X
X VERTICAL MODE
^
| +------------+-+
| | | | MIRROR = 1
| | | | ROTATE = 1
| | | | X = 132
| +------------+-+ Y = 176
|
0------------------> Y
*)
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
There is the possibility to select certain functions by setting some bits of a variable. We have declared in the code a variable called glcd_FlagsBits that contains the next bit sequence:
- Bit.0 AutoLineFeed (text printing routines will execute a so-called "wrap around" on the window defined by glcd_Window)
- Bit.1 FixedFont (be = 0 for proportional fonts and will be = 1 for fixed width fonts)
- Bit.2 Clipping (activation function respectively restricting display outside the window defined by glcd_Clip_x1, glcd_Clip_x2, glcd_Clip_y1, glcd_Clip_y2 )
COLORS (Define)
LS020 accept encoding 8-bit RGB color format, 16 bit and even 24 bits. The submitted code will be referred only to 16-bit RGB format. The8-bit RGB format is RGB 3 - 3 - 2 and can form mix shades of colors: 3 bits of red, 3 bits green and two blue bits. The 16-bit RGB format allow the use of up to 65,000 colors in combination of RGB 5 - 6 - 5 respectively 5 bits red, 6 green bits and 5 bits blue.
Code:
;============================================================================== ; Definition of the coded RGB 5-6-5 and some of the most used colors ; Note: ; For 8 Bit colors R,G,B 3,3,2 bits ; For 16 Bit colors R,G,B 5,6,5 bits ;============================================================================== ; define the RGB coding for 5 red | 6 green | 5 blue $define RGB(r,g,b) ((( r & $F8)<<8)|(( g & $FC)<<3)|(( b & $F8)>>3 )) ; and now some colors $define NONE RGB($00, $40, $00) ; use this as transparent color $define BLACK RGB($00, $00, $00) $define WHITE RGB($FF, $FF, $FF) $define RED RGB($FF, $00, $00) $define GREEN RGB($00, $FF, $00) $define BLUE RGB($01, $00, $FF) $define YELLOW RGB($FF, $FF, $00) $define MAGENTA RGB($FF, $00, $FF) $define CYAN RGB($00, $FF, $FF) $define GRAY RGB($80, $80, $40) $define SILVER RGB($A0, $A0, $80) $define GOLD RGB($A0, $A0, $40) $define ORANGE RGB($FF, $6D, $00) $define VIOLET RGB($85, $00, $DF) ;==============================================================================
Code:
$define MY_COLOR RGB($3B,$CF,$0C) ; #3BCF0C
The Other RGB Color Chart
Wiki - List of Colors
Name That Color
GLCD Functions (Macros)
Next, will try to explain each function (macro) of the Code.
glcdWriteCmd
has two byte type parameters ( __param and __reg) and the function is to set a parameter for a target register;
glcdWriteData
parameter is a variable of type word and is used for sending information type "DATA" to display;
glcdSetArea
has four parameters, namely pairs x0 x1 y0 and y1, which are positions defining the corners (diagonally) to the area in which data will be displayed. Also, the cursor will position the coordinates of x0, y0;
glcdSetCursor
has the parameters x and y coordinates, which will position the cursor;
glcdDrawStart
placing the display in a reception mode for the data stream (representing color values, using 16 bits per pixel);
glcdDrawCmd
to transmit a variable of type word, representing the 16-bit color of the respective pixel;
glcdDrawStop
the display will exit from the continuous receive data stream;
glcdClear
accept a word variable type parameter representing the pixel color that will be filling the screen, the effect is similar to "erase" the screen;
glcdDrawPixel
the parameters are the coordinates x (byte) and y (byte) of the cursor and the color (Word) of the pixels to be written on the screen;
glcdPutPixel
is the color parameter (word) for the printed pixel. The Cursor position is not set with this function;
glcdSelectFont
parameter is a variable that represents the font name (LABEL type variable) to be used further;
glcdNewLine
no parameter.It is executing a <LF> <CR> inside the window defined by glcdWindow;
glcdDrawChar
parameter is the character to be printed, as defined within the previously selected font file;
glcdFillRectangle
has as parameters the coordinates x0, y0 and x1, y1 rectangle of the display, and color that will be 'filling' it (16-bit format);
glcdDrawRectangle
has as parameters the coordinates x0, y0 and x1, y1 rectangle of the display, and plotting its color (16 bit format);
glcdDrawLine
has as parameters the coordinates x0, y0 and x1, y1 line display, and plotting its color (16 bit format);
glcdDrawCircle
has as parameters the coordinates x0, y0 of the circle to display, the radius of the circle (in pixels) and its plotting color (16 bit format);
glcdFillCircle
has as parameters the coordinates x0, y0 of the circle to display, the radius of the circle (in pixels) and the color that will be 'filling' it (16-bit format);
glcdPrint
parameter is the string that contains the data to be displayed;
glcd65K
informs the display that will use RGB 5-6-5 format, that is 16-bit of color information per pixel;
glcd8
informs the display that will use 332 RGB format, that is 8-bit of color information per pixel;
the screen will display in negative mode the image that was on display before using this feature;
glcdPozitive
the screen will display a positive image after it was turned glcdNegative;
glcdPowerOff
display should execute this command before powering off. It is recommended to use it so to keep a longer display operation duration;
glcdSleepBlack
execute display "Sleep" function, sending "Black" color for all pixels on the screen. During this period you can send commands and data to display;
glcdSleepWhite
execute display "Sleep" function, sending "White" color for all pixels on the screen. During this period you can send commands and data to display;
glcdDisplayOn
display out of sleep function induced state above and returns to normal display;
To be continued:
In the next article the following will be tackled:
- Function "Scroll";
- Producing/editing fonts;
- Printing Images;
- Conclusions
Find attached the related code for the this LS020 - Sharp TFT display driver. You have though to change some declares to reflect your own hardware setup.
Please enjoy and improve it if possible for the benefit of all interested.
As these articles are automatically translated into English I would like to thank Paul V for the support.
More details and pictures you can find on my Amicus18 Friendly Site.


Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit