LCD Screen

This page describes how I interfaced a Seiko M4024 LCD Character Display to both a standard PC parallel port and the GPIO of the soekris net4801 router.


Hardware Interface

The M4024 uses either a 4bit or 8bit data transfers and has 3 control lines (4 if you want to read as well as write). I run the display in 4bit mode. 7 pins are needed for output to the display.

The display also needs 5V DC power, Vlc (LCD voltage, about 0V to 1V to control the contrast), and Vcth (LED backlight voltage, about 3.9 to 4.2V to control brightness).

PC Parallel Port

The standard PC parallel port contains 12 output pins and 5 input pins. 7 output pins are used for the display. 5V power is drawn from the PC power supply.

Soekris net4801 GPIO

The Soekris net4801 contains 12 GPIO pins. 7 output pins are used for the display. 5V power is drawn from net4801 power supply.

Software API

The software API provides basic control, printf() output and bar or graphic output.

The API provides two different operatoinal modes:

  • Test mode with bar graphics
  • Text mode with 4x4 character bitmap graphic (23x38 pixels).

#define LCD_WIDTH            40
#define LCD_HEIGHT            4

#define LCD_GRAPHIC_WIDTH    23

/* initialize the lcd subsystem, call this once when you program starts up */
/* custom_mode = 0 for bars, custom_mode = 1 for graphic display */
void lcd_init(char custom_mode);

/* release resources */
void lcd_uninit(void);

/* clear the lcd */
void lcd_clear(void);

/* redraw the lcd, use this if it gets corrupted */
void lcd_redraw(void);

/* disable or enable the lcd, data is kept and writes are allowed when disabled */
/* t = 0 -> turn off, t = 1 -> turn on */
void lcd_onoff(char t);

/* place a string of text on the screen starting at row/col */
/* row is 0..LCD_HEIGHT, col is 0..LCD_WIDTH-1 */
int __attribute__ ((format(printf, 6, 7)))
     lcd_printf(int row, int col, int max_length, int min_length, int flush,
                const char *format, ...);

void lcd_flush(void);

 * if custom_mode == 0
 * place a bar on the screen starting at row/col with size wide and value val
 * row is 0..LCD_HEIGHT, col is 0..LCD_WIDTH-1, wide is 1..LCD_WIDTH, val is 0..5*wide
void lcd_putbar (int row, int col, int wide, short val, int flush);

 * if custom_mode == 1
 * define the place on the screen for a graphic starting at col, size is 4x4 chars
 * col is 0..LCD_WIDTH-4
void lcd_locategraphic (int col);

 * if custom_mode == 1
 * place graphic data on the screen of size LCD_GRAPHIC_WIDTH bits wide by
 * data is a pointer to LCD_GRAPHIC_HEIGHT longwords containing LCD_GRAPHIC_WIDTH
 * bits of data each.
void lcd_updategraphic (long *data);

/* print stastistics to the screen.  existing data is saved and restored 10 seconds later */
void lcd_printstats (void);

Software Programs

Diagnostic: lcdtest

the 'lcdtest' program provides diagnostics and stress testing of the LCD interface.

System status: lcd

The 'lcd' program was the original program. This is the program I run on my soekris router. It gathers system status and displays them using the putbar api.

Diagnostic: lcdwork2

'lcdwork2' is the latest program. This is the program I run on the LCD display at work. It monitors keyboard/mouse activity and displays status.


More Pictures