Tag Archives: GLCD

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;
}
}
}
}
}

Resize and then Import a graphic into the Work Canvas

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

Resize and then Import a graphic into the Work Canvas

 

Bitmap2LCD Resize Preview

Since v2.6B, there’s a new toolbar at the top of the graphic (blue arrow)

When importing a graphic file, you can choose to resize the graphic size in the graphic preview (yellow arrow) or turn the graphic or reload the original graphic.

If the graphic is much larger in size than the work canvas, you will see a “blue frame” in the preview, frame which shows the size of the Work Canvas. You can move this area to the graphic detail you wish to import. In this case, the later message box resize to fit should be answered with NO.

When you want to resize the graphic, click on the selection button (yellow button) and then define the size on the image with mouse. The preview will be resized.

When ready import the graphic (red arrow) to the floating selection layer above the work canvas. When ready paste the floating selection layer.

 

 

 

GLCD Data array output options

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

Output of the GLCD data array in a binary file
The converter data output feeds a built in hexadecimal editor and is saved to disk in a binary file (*.hex)

bitmap2LCD GLCD to binary file output

Output of the GLCD data array in a text file for the compiler or assembler, format 8, 16 or 32 bit data

The converter data output feeds a built in text editor and can saved to disk in a text file
( *.c , *.h , *.asm , “.lib etc..)

bitmap2LCD GLCD to text file output

Next to the data file, a rich text file (*.rtf) which contains all GLCD conversion parameters is written to disk, in the user defined “Documents folder”.

Convert a range of unicode chars for GLCD Font

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

Convert a range of unicode chars for GLCD Font

Obsolete article, only for previous versions < V3.7

Another way to convert unicode chars by defining a range of them:

  • Enter font script mode
  • Enter Range Mode (yellow arrow)
  • If necessary, erase the from Hex and to Hex addresses with the clr button
  • Select Range Start in the char grid (red arrow), address appears in From Hex (blue Arrow)
  • Select Range End the same way in the char grid -> To Hex
  • Then Validate Address (blue arrow)
  • Encode the Font Range (orange Arrow)

Note : You can define Start and End of range addresses in different Fonts blocks. The condition is that the Start address is below the end address.

Version 3.0+

Bitmap2lcd Unicode Font Range

 

 

Before Version 3.0

 

 

About the touch panel function in Bitmap2LCD

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

Touch panel regions (green arrow) can be graphically defined in the work canvas.

  • If not already displayed, load the correct bitmap into the work canvas ( sample)
  • Create a Touch panel script (orange arrow)

The editor gutter becomes green = Touch Panel Script.

  • A region can be defined using the mouse with the area selection tool (green arrow)
  • When the touch panel region size and location are correct, convert the area to a region with the “Make touch region” button (yellow arrow)
  • When all regions where defined , convert the script to an output file (black arrow)

Note that you can edit, move, resize defined regions.

Bitmap2lcd Touch Screen Feature

Configuration settings for touch panel data output (see fig2)

  • In the Touch panel main menu (orange arrow) you can define the data direction and the Touch Screen controller resolution (8,10 or 12 bit)
  • In the toolTouch Configuration Settings Panel, under tab Touch Panel, you can define your favorite output syntax.
  • When converting the defined regions with the button (green arrow) the data in the editor then contains the regions, with field number and the 4 coordinates of each region.

Bitmap2lcd Touch Screen Settings

Start touch Then convert the Touch Panel Regions to Data :

Bitmap2lcd Touch Screen Data

 

Grayscale GLCD >> 16 gray levels basics

Bitmap2LCD is a universal programming tool for converting bitmaps/images to GLCD for most graphic LCD controllers.

This software tool can be used for programming embedded systems connected to a Grayscale Small Graphic LCD ( OLED ) with a built-in COG LCD controller similar to the ST7528.

For a start, here’s a short article about 4bpp grayscale (4-bits per pixel ) for displaying 16 levels of gray.

The values from 0  through 15 decimal (00 to 0F hex) correspond to lightest (white) through darkest (black) as shown in the representation below.

A single byte in the DDRAM can be used to store 2 pixels of information.

When using a module with an on glass ST7528 LCD controller, in the source code data byte, the first pixel data comes after the second pixel data :  22221111

With bitmap2LCD [from v2.0 upwards] you can set ON the automatic pixel data nibble swapping, for a correct ordering in the source code output.

 

Bitmap to GLCD Hex file >> Output settings

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

Go to the Main Settings (v2.5 +):

bitmap2lcd settings

From V2.5, the below settings can also be found on the file explorer window, outputs tab : there’s a button at the top right to hide or show this toolbar.


fig 1. Hex file output settings buttons [ Bitmap2LCD from V2.0 upwards ]

 

Bitmap2LCD is a universal programming tool for converting bitmaps/images to GLCD for most graphic LCD controllers. (Monochrome,Grayscale, and Color ->[Color from V2.0] )

The software converts the bitmap and generates a hexadecimal file according to the previously defined user settings.

Here’s a short description of the available settings :

The hexadecimal output format can be selected with a series of buttons located in the output panel (fig 1.)

Description of the settings:

  • The choice of 8 different vertical or horizontal pagings ( the buttons with the arrows ) , your choice depends of the GLCD controller which is built in your LCD module. ( Please refer to the GLCD controller datasheet )
  • Most significant bit is first or is last (Data bit 7) — or in other words the data endianness.
  • Byte nibble swap On/Off, for example for 16 gray level grayscale mode for Sitronix ST7528 controller compatibility. ( In the case of 2 pixel per data byte, 4 bit per pixel data, gray levels )
  • Negative or positive output setting
  • GLCD zero corner selection (Corner where the conversion starts)
  • Output File Header Editor , (A small script to configure Hex file header)
  • Enable/Disable of the Output Data for compression for monochrome GLCD.
  • Enable/Disable 6 or 8 bit Data byte wide output for T693C Controller

As the converted output can just contain a part of the display size, there are other selectable options (not on fig1.)

  • Enable/disable X,Y area coordinate data insertion in the Hex ouptut file
  • Enable/disable area size data insertion in the Hex output file

These configuration settings are saved when you quit the application and restored on application launch. These settings are also a part of the project specific configuration.

Find other available settings in this topic.