Administrative

Projects

Active

Future

Finished

Reference

Abandoned

C Library for Epson SED1530 displays

This library provides functions for (mainly) text output on Liquid Crystal Displays using the Epson SED1530 LCD controller.

Installing

Using

To use the library in a program, you first need to include some definitions in your main source file. Please note that the two font types are declared globally there, that is, not inside any function.

#include <libsed1530.h>

...

font_t *font;
font_t *graphfont;

Before using the display, the fonts have to be initialized, the ppi(4) device must be opened, and the display has to be initialized:

  font = tmalloc(256 * sizeof(font_t));
  initfont("/usr/local/share/libsed1530/el-1.fnt");
  graphfont = tmalloc(256 * sizeof(font_t));
  initgraphfont("/usr/local/share/libsed1530/el-gr.fnt");
  if ((lcd_fd = open("/dev/ppi0", O_RDWR)) < 0) {
    fprintf(stderr, "Error opening /dev/ppi0: %s\n", strerror(errno));
    exit(1);
  }
  initSED(lcd_fd);
  PutCtrl(lcd_fd, CMD_RESET);
  setupSED(lcd_fd);
  clearSED(lcd_fd, 1);

When linking the program, remember to specify the libsed1530, e.g.

cc -L/usr/local/lib -o mylcdprog mylcdprog.o lcdsub.o foosub.o -lsed1530

Available functions

Global variables

u_int8_t backlight

If software backlight control is used, this controls the backlight setting. Backlight is toggled when the next write access to the LCD takes place. Default 0.

u_int8_t invert

If set to 1, the display contents are displayed white on black. Default 0.

u_int8_t contrast

Contrast setting, possible values are 1 to 29. Default 15.

Initialisation

void initSED()

Initializes the display with some basic settings.

void setupSED()

Basically, this function sets (or re-sets) the contrast setting.

void initfont(char *fname)

Loads the text character font data from the file given in fname into the font structure. The font structure has to be allocated as shown above before calling initfont().

On error, this function prints an error message to stderr, exits the program and sets the exit code to 13.

void initgraphfont(char *fname)

Loads the graphical character font data from the file given in fname into the graphfont structure. The graphfont structure has to be allocated as shown above before calling initgraphfont().

On error, this function prints an error message to stderr, exits the program and sets the exit code to 13.

void doneSED(int fd)

This function turns off the LCD and, if software controlled, the backlight.

fd is the ppi device's file descriptor, which has to be open for writing.

Text and high-level operations

void textSED(int fd, int row, char *intext, int linebreak)

Writes the text pointed to by intext to row number row of the display connected to the ppi device given in fd as file descriptor open for writing. If linebreak is not 0, an automatic linebreak is performed when a display line is full, making the text continue in the next row.

void graphSED(int fd, int row, char *intext, int linebreak)

Writes the graphical characters pointed to by intext to row number row of the display connected to the ppi device given in fd as file descriptor open for writing. If linebreak is not 0, an automatic linebreak is performed when a display line is full, making the text continue in the next row.

void fonttest(int fd)

Shows all text font characters on the display connected to fd.

void graphfonttest(int fd)

Shows all graphical font characters on the display connected to fd.

void blinkSED(int fd, int cnt)

When software backlight control is enabled (which is done through the appropriate data line connection on the parallel port, as shown in the hardware notes ( missing here!), the backlight of the display connected to fd is blinked off and on cnt times.

void clearSED(int fd, int full)

Clears the display connected to fd. If full is not 0, line 0 (which I usually use as the status line) is also cleared.

Logbook