Tag Archives: LCD

About GLCD Data Compression

Bitmap2LCD is a tool for programming small Graphic LCDs in embedded systems.

About GLCD Data Compression

Update V3.7c

A simple data compression feature, for the output of GLCD data arrays is implemented in Bitmap2LCD

bitmap2lcd-data-compression

This function is only available for monochrome mode and 8 bit output format.

The 8 bit microcontrollers for price sensitive projects are circuits with often less onchip memory space than most of the 16 or 32 bit devices.

The target is to save as many as microcontroller flash memory as possible. As tables for full display patterns of for example a 128 x 64 dot matrix LCD need 1024 bytes each, the goal of this function was to save flash space for more code or graphics or just to reduce the overall flash capacity and therefore to sink the price of the MCU chip.

The microcontroller firmware has to be able to handle these tables with a special code, which decodes the compressed data. Processing time for decompression has to be allowed.

 

How does it work ?

Instead of only converting the black and white pixels found in the work canvas to a linear list of n bytes, with the data compression method explained here, the data array is split into two separate arrays in one single output file : one as usual for the data stream and another for the pointers of each data groups.

Compr1

The basic concept of this compression is based on making groups of consecutive identical data bytes in the data array.

 

Consecutive identical byte chains, and consecutive different byte chains are handled, the goal here is to save data bytes when a consecutive identical byte chain is found. While the first pointer of a consecutive different bytes chain is a loss of one data byte stored as a pointer, a consecutive identical byte chain of 10 bytes is a win of 8 bytes, the data being written only once in the data array. The count of them is then stored in the pointer byte array part.

The maximum count of consecutive data, identical or different is limited to 127 ( pointer bits 6 to 0 ). If a data count in a group reaches 127, a new group is encoded.

compr2

The bit 7 of the pointer byte is the flag for the compression decoder. A 1 (high) is for a chain of identical data bytes, and a 0 (low) is for an chain of different data.

 

When data compression is active, Bitmap2LCD converts all data and shows the compression rate in the compression statistics at the end of the output file.

 

This method of compression shows different results in vertical or horizontal orientation conversion, it depends of the LCD graphic !

If possible, before to choose the LCD controller and its specific data orientation in Display RAM , you could try both orientations and compare the possible compression ratios.

 

In the Header Include file, the example script below shows how to setup the compression table information.

bitmap2lcd-header-include_1

bitmap2lcd-header-include_2

( It is an example for a GNU-C compiler for ATMEL AVR family )

Everything after the tag [&COMPRESSION] is a script information for the data compression function.

The tag [&CNAME] is replaced in the output table name, by the data array name

with an additional suffix _x ( For example : Newfile_x )

The tag [&CSIZE] is not used yet (v2.3)

In the Header Include file :

[&COMPRESSION]
const prog_uint8_t [&CNAME][&CSIZE] = {

 Please also check the online forum for other topics about this function

Compression Decoder Example

The below example of a function in C language, decodes compressed data arrays converted with bitmap2LCD.

It is for an Atmel AVR target MCU with GCC compiler, a T6963C LCD controller ( horizontal byte orientation from left to right )
No buffer RAM.

Note : For LCD module widths greater than 255 dots, x and width variables should be long integers

 

// T6963 function for uncompressed bitmaps
void GLCD_Bitmap(unsigned char *bitmap, unsigned char x, unsigned char y, unsigned char width, unsigned char height)
{
unsigned char val;
uint8_t LcdX,LcdY,EndX,EndY;
long ip = 0; // table byte counter
LcdX=x; // LCD dot adress X
LcdY=y; // LCD dot adress Y
EndY=y+height-1;
EndX=x+width;
while (LcdY < EndY || LcdX < EndX)
{
GLCD_GraphicGoTo(LcdX, LcdY);
GLCD_WriteDisplayData(pgm_read_byte(bitmap + ip));
ip ++;
LcdX=LcdX+8;
if (( LcdX == EndX ) && ( LcdY<EndY ))
{
LcdY++;
LcdX=x;
}
}
}
// T6963 function for Bitmap2LCD compressed bitmaps
void GLCD_xBitmap(unsigned char *bitmap, unsigned char *pointer, unsigned char x, unsigned char y, unsigned char width, unsigned char height)
{
unsigned char val;
uint8_t p,pv,nb,LcdX,LcdY,EndX,EndY;
long ip = 0; // table byte counter
p = 0; // pointer
LcdX=x; // LCD dot adress X
LcdY=y; // LCD dot adress Y
EndY=y+height-1; // End pixel in Y
EndX=x+width; // End Pixel in X
while (LcdY < EndY || LcdX < EndX)
{
pv = (int)(pgm_read_byte(pointer + p)); // read the pointer byte
p++;
if (pv > 128) // bit 7 is logical high when identical bytes chain, low when different
{
val = pgm_read_byte(bitmap + ip);
ip++;
nb = pv – 128;
while ( nb > 0 ) // substract bit 7 value for number of bytes in chain
{
GLCD_GraphicGoTo(LcdX, LcdY); // bytes in chain are identical
GLCD_WriteDisplayData(val);
LcdX=LcdX+8;
nb–;
if (( LcdX == EndX ) && ( LcdY<EndY ))
{
LcdY++;
LcdX =x;
}
}
}
else // bytes in chain are different
{
while ( pv > 0 )
{
GLCD_GraphicGoTo(LcdX, LcdY);
GLCD_WriteDisplayData(pgm_read_byte(bitmap + ip));
ip ++;
LcdX=LcdX+8;
pv–;
if (( LcdX == EndX ) && ( LcdY<EndY ))
{
LcdY++;
LcdX=x;
}
}
}
}
}

The LCD Glossary

The LCD Glossary

1/4 VGA
Resolution of 320 x 240 dotsCCT
Cold Cathode Tube

C/F
Color Filter

COF
Chip-on-Flex

COB
Chip-on-Board

COG
Chip-on-Glass

CR
Contrast Ratio

DBEF
Dual Brightness Enhancement Film

DSM
Dynamic Scattering Mode

DSTN
Double Super-Twisted Nematic

EL
Electroluminescent Light

FEM
Field Emissive Mode

FSTN
Film Super-Twisted Nematic

HTN
High Quality Twisted Nematic

ISTN
Improved Super-Twisted Nematic

ITO
Indium Tin Oxide

LCD
Liquid Crystal Display

LCDP
Liquid Crystal Display Panel

LED
Light Emitting Diode

MLA
Multi-Line Addressing

MTN
Modulated TN

PLCD
Plastic Liquid Crystal Display

RGA
Returned Goods Authorization

SRC
Super Reflective Color (Birefringent Color)

STN
Super-Twisted Nematic

TAB
Tape Automated Bonding

TCRF
Temperature Compensation Retardation Film

TC-STN
Temperature Compensation Super-Twisted Nematic

TDF
Transflective Display Film

TFT
Thin Film Transistor

TN
Twisted Nematic

VGA
Resolution of 640 x 480 dots

VHC
Very High Contrast (Technology used for Static or duty automotive
products with CR 1000:1)

WTN
Wide Viewing Twisted Nematic

WVF
Wide Viewing Film

Source : Optrex Website

Temperature compensation for LCD Display

Temperature compensation for LCD Display

An application Note

The optimal contrast setting for LCD displays varies with ambient temperature. For most
applications this variation in contrast is tolerable over the “normal” temperature range of 0°C to +50°C. Most LCD modules are available with an extended temperature range option
which allows the display to operate from-20°C to +70°C. The changes in contrast are NOT
usually tolerable over this wide a range of temperatures, which means a way of adjusting the contrast voltage as the ambient temperature changes must be provided

PDF =>
http://www.newhavendisplay.com/app_notes/Temperature_Compensation.pdf

Bitmap2lcd : Output of an Array of [ Arrays of Pixel lines ]

Bitmap2LCD is a tool for programming small Graphic LCDs in embedded systems.

Output of an Array of [ Arrays of  Pixel lines ]

Data of one display line of pixels (direction can be either in colums or in rows) can be separate in a sub array (green arrow)

Example of this kind of data output   (Checkbox enabled must be set )

[[    — Array prefix example

[data for line 1]

[data for line 2]

[data for line n]

]]  — Array suffix example

 

Bitmap2LCD Configuration Settings Python