Bitmap font editor for graphic LCD

Bitmap font editor, C code, for graphic LCD

I reinvented this wheel several years ago, since I couldn't find anything online, and I keep tweaking it for new projects. This editor will create/edit fonts that are 8 or 16 pixels high, up to 16 pixels wide (variable). The bitmaps are compatible with common graphic LCD controllers that use 8 pixel high "pages". The output can include a "C" or "asm" style text file, to use in your programs.

Since I see people asking about where to find font tables, I decided to make this available. If you have complaints, bug reports or suggestions, PM or email me.

NOTICE: The ancient program attached here has been superceeded by a much slicker version. If you have downloaded this old version, you should switch to the newest CFE_64 version (as of 04/29/2014) here:
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 

Attachments

Last edited:
C code text driver for graphic LCD

This C driver is designed to put text strings on a graphic LCD. It will handle small (8 pixel high) and large (16 pixel high) fonts. There are several justification modes (left, right, centered at different locations) and display options.

The initialization section is designed for use with Epson SED1565 controllers (as used in several Optrex displays) and Samsung KS0713/1713 controllers (as used in Crystalfontz CFAX type displays), but can probably be modified for others.

Note: this C code is a translation of my assembler source, which has been thoroughly tested, and is in use in commercial products. Since I don't currently use C for embedded projects, I have not actually tested this version. It compiles without error, but since it needs to be customized for your target processor and environment anyway, you will have to do the real testing.

If you have questions or suggestions, PM or email me.
 

Attachments

Last edited:
BTW, I notice that my C code init routine, RESET got inverted in the translation, here is the corrected version of the hardware reset portion:

Code:
    LCD_CTRL(RESET, 0);     // assert hardware reset
    Sleep(1);
    LCD_CTRL(RESET, 1);     // de-assert reset
sorry about that.
 
I don't have any fonts other than the 8x? and the 16x?. Note that the fonts are actually shorter than 8/16 because the inter-row spacing is included in the character cells (which makes for simple display writes). The whole point of the editor is that you can make the fonts whatever size you want within the limits of the editor array sizes. The height limit of 8x and 16x are purely for practical reasons of storing the result as byte lists and word lists. For graphic controllers with a 8 pixel page size, you'd also have to do a lot of byte shifts/rotates to accomodate odd font row heights, and I didn't want to go there.

So if you want 10 or 12 pixel high fonts, just use the 16 pixel editor and leave blank rows at the top or bottom.
 

juanwor

New member
Question regarding sed1565

When you wrote grlcd_code.zip, what microprocessor speed were you using?
Thanks.
 
The assembler version of that code currently runs on two processors: a HC12B32 @ 8MHz, and a HC12C32 @ 24MHz.

Of course the assembler code has some time-wasting added to meet minimum display timing requirements, which is not shown in the "C" code. For example:
Code:
gr_cmd	bclr LCD_CTRL LCD_A0	;select = cmd
		LCD_OUT
		bset LCD_CTRL LCD_E
		nop
#ifdef BUS24MHZ
		nop
#endif
#ifdef KS1713
		nop
#endif
		bclr LCD_CTRL LCD_E
		rts
So if your C complier does not produce bloated code, you may have to add some NOPs.
 

juanwor

New member
Thanks, one more ...

This is my write routine for controller sed1565 (PIC16f877), ccs compiler:
Code:
void Write_Display(UINT8 command, UINT8 datax)
{
    UINT8 status = 0;

    /*Start BUS_RELEASE*/
    output_high(DISPLAY_WRITE);/*WR line*/
    output_high(DISPLAY_READ);/*RD line*/
    output_high(DISPLAY_A0);/*Command line*/
    /*End BUS_RELEASE*/

    /*LCD busy or reset?*/
    DIRECTION_8(INPUT_BUS);/*set port D as inputs*/
    output_low(DISPLAY_A0);/*CMD*/
    do
    {
        output_low(DISPLAY_READ);/*put RD to low*/
        NOP_CCS; /*asm NOP*/
        NOP_CCS;
        NOP_CCS;
        status = DATA_8;
        NOP_CCS;
        output_high(DISPLAY_READ);
    }while(status&BUSY_F);/*0x80?*/

    /*LCD ready to write*/
    DIRECTION_8(OUTPUT_BUS);

    /* Load the control signals and data for a particular command. */
    if(command == CMD)
        output_low(DISPLAY_A0);
    else
        output_high(DISPLAY_A0);
    /* Place the data on the bus. */
    DATA_8 = datax;
    NOP_CCS;
    output_high(DISPLAY_READ);
    output_low(DISPLAY_WRITE);
    NOP_CCS;
    output_high(DISPLAY_WRITE);
    NOP_CCS;
    /* After the microcontroller is finished, it will always release the bus to the display. */
    DIRECTION_8(INPUT_BUS);
    /*BUS_RELEASE*/
    output_high(DISPLAY_WRITE);
    output_high(DISPLAY_READ);
    output_high(DISPLAY_A0);
    /*End BUS_RELEASE*/
}
I´m getting -9.5 V as LCD voltage reference level, it looks like the power ctrl command was taken by the LCD, however it never showed me any data. The write command to send data or commands is the same that I showed you above !!!
Any advice or suggestion?
 

RayAbram

New member
Display not showing any data

You did not say if you actually turned ON the display... most LCD Display controllers require that you send a "Display ON" command before thay actually begin driving the display...

eg: for the TL0313, i use:
Code:
(0xAE) Display Off                
(0xC0) SHL Select                 
(0xA0) ADC Select                 
(0xA3) LCD Bias Select            
(0x2C) Power Control              
(0x2E)                            
(0x2F)                            
(0x27) Regulator Resistor Select  
(0x81) Set Reference Voltage Mode
(0x0C) Set Reference Resistor     
(0xA6) Reverse Display On/Off     
(0x40) Initial Display Line       
(0xAF) Display On
and for the PCF8548:
Code:
(0x00) many command bytes follow - see pcf8548 data sheet
(0x29) Function Set => MX=0, MY=1 (Vertical Mirror), PD=0 (Chip Active), V=0 (Horizontal Addressing), H=1 (extended set command)
(0x04) Temperature Coefficient 0
(0x15) bias = 5
(0x80) Vop  (Unused)
(0x0C) DO=1 (LSB on Top), TRS=0 (top rows are not mirrored), BRS=0 (bottom rows are not mirrored)
(0x28) Function Set => MX=0, MY=1 (Vertical Mirror), V=0 (Horizontal Addressing), H=0 (normal command set)
(0x0C) Display control => D and E = 10 (normal lcd mode)  (01=all display segments on)  (11=inverse video mode)
as you can see, Both LCDs require the LCD to be turned ON...
--->>> check to see if your one does....
 
Re: Thanks, one more ...

This thread is not really about helping folks with their code. This post should have gone into the general tech support forum.

I will make a few suggestions, however.
void Write_Display(UINT8 command, UINT8 datax)
{
.....
/*Start BUS_RELEASE*/
output_high(DISPLAY_WRITE);/*WR line*/
output_high(DISPLAY_READ);/*RD line*/
output_high(DISPLAY_A0);/*Command line*/
/*End BUS_RELEASE*/
It's not necessary to do this "bus release" here.
/*LCD busy or reset?*/
DIRECTION_8(INPUT_BUS);/*set port D as inputs*/
output_low(DISPLAY_A0);/*CMD*/
do
{
output_low(DISPLAY_READ);/*put RD to low*/
NOP_CCS; /*asm NOP*/
NOP_CCS;
NOP_CCS;
status = DATA_8;
NOP_CCS;
output_high(DISPLAY_READ);
}while(status&BUSY_F);/*0x80?*/
You could simplify this by putting the strobe outside the loop, like this:
Code:
DIRECTION_8(INPUT_BUS);/*set port D as inputs*/
output_low(DISPLAY_A0);/*CMD*/
output_low(DISPLAY_READ);/*put RD to low*/

do
{
     status = DATA_8;
} while(status&BUSY_F);/*0x80?*/

output_high(DISPLAY_READ);
DIRECTION_8(OUTPUT_BUS);
/* After the microcontroller is finished, it will always release the bus to the display. */
DIRECTION_8(INPUT_BUS);
/*BUS_RELEASE*/
output_high(DISPLAY_WRITE);
output_high(DISPLAY_READ);
output_high(DISPLAY_A0);
/*End BUS_RELEASE*/
Why bother? The display is a slave and setting the bus to inputs will leave a high impedance state, which is not a good idea for CMOS inputs. Toss that section out.
I´m getting -9.5 V as LCD voltage reference level, it looks like the power ctrl command was taken by the LCD, however it never showed me any data. The write command to send data or commands is the same that I showed you above !!!
Any advice or suggestion?
You will need to post your init parameters in order to answer this.
 

naga_ks

New member
Font Set

Hi,

Is there any script/tool, by which I coudl generate bitmap font sets. i.e., I'm looking for fonts for a LCD display device.

I need to try out various bitmap fonts.
Could you guide me on the same.

Thanks & rgds
nagaraj
 
The only suggestion I have is to download the file in the first post in this thread, and see if it does what you need. You will need a Windows PC to run it.
 

etomber

New member
SED1565 assembler code

Would you be willing to provide the assembler source code (versus the C code) for your SED 1565 initialization, read/write routines? This is my first time working with an LCD, and I would prefer to stick with assembly language.
 

motnamser

New member
Font Editor

I'm having problems downloading your files. I cannot unzip them with Winzip. The program says that they are corrupted.

Anyone else experiencing this?

Thanks
 

toastedcrumpets

New member
Thanks!

First, thanks for a great tool. It's saved me so much development time when making a character set for my graphical LCD project. Its so good I thought I'd try to give back...

I've made a smaller font set based on your original font8 (I wanted enough room to put a box around the text in a 8 pixel high row for buttons). I also made a small C converter to PIC assembly tables as I don't use C in my microprocessor devices.

The source file for the smaller font is here and a snapshot is available here.

Once again thanks for a great tool.
 
Top