[lcd4linux @ 2005-04-30 06:02:09 by reinelt]

LCD-Linux display size set up from lcd4linux.conf

git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@534 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
reinelt
2005-04-30 06:02:09 +00:00
parent cc9c2bd243
commit 733a1141da
3 changed files with 44 additions and 15 deletions
+33 -5
View File
@@ -1,4 +1,4 @@
/* $Id: drv_LCDLinux.c,v 1.5 2005/04/09 07:36:42 reinelt Exp $
/* $Id: drv_LCDLinux.c,v 1.6 2005/04/30 06:02:09 reinelt Exp $
*
* driver for the LCD-Linux HD44780 kernel driver
* http://lcd-linux.sourceforge.net
@@ -24,6 +24,9 @@
*
*
* $Log: drv_LCDLinux.c,v $
* Revision 1.6 2005/04/30 06:02:09 reinelt
* LCD-Linux display size set up from lcd4linux.conf
*
* Revision 1.5 2005/04/09 07:36:42 reinelt
* updated LCD-Linux driver to version 0.8.8
*
@@ -142,10 +145,23 @@ static void drv_LL_defchar (const int ascii, const unsigned char *matrix)
}
static int drv_LL_start (const int quiet)
static int drv_LL_start (const char *section, const int quiet)
{
char *s;
int rows=-1, cols=-1;
struct lcd_driver buf;
/* get size from config file */
s=cfg_get(section, "Size", NULL);
if (s != NULL || *s != '\0') {
if (sscanf(s, "%dx%d",&cols,&rows) != 2 || rows < 1 || cols < 1) {
error ("%s: bad %s.Size '%s' from %s", Name, section, s, cfg_source());
free (s);
return -1;
}
}
free (s);
/* open device */
lcdlinux_fd = open(Device, O_WRONLY);
if (lcdlinux_fd == -1) {
@@ -156,11 +172,23 @@ static int drv_LL_start (const int quiet)
/* get display size */
memset(&buf, 0, sizeof(buf));
if (ioctl(lcdlinux_fd, IOCTL_GET_PARAM, &buf) != 0) {
error ("%s: ioctl() failed: %s", Name, strerror(errno));
error ("%s: ioctl(IOCTL_GET_PARAM) failed: %s", Name, strerror(errno));
error ("%s: Could not get display geometry!", Name);
return -1;
}
info("%s: %dx%d display, %d controllers", Name, buf.disp_cols, buf.cntr_rows, buf.num_cntr);
info("%s: %dx%d display (%d controllers)", Name, buf.disp_cols, buf.cntr_rows, buf.num_cntr);
/* overwrite with size from lcd4linux.conf */
if ((rows > 0 && rows != buf.cntr_rows) || (cols > 0 && cols != buf.disp_cols)) {
buf.cntr_rows = rows;
buf.disp_cols = cols;
if (ioctl(lcdlinux_fd, IOCTL_SET_PARAM, &buf) != 0) {
error ("%s: ioctl(IOCTL_SET_PARAM) failed: %s", Name, strerror(errno));
error ("%s: Could not set display geometry!", Name);
return -1;
}
info("%s: size changed to %dx%d", Name, buf.disp_cols, buf.cntr_rows);
}
DROWS = buf.cntr_rows;
DCOLS = buf.disp_cols;
@@ -231,7 +259,7 @@ int drv_LL_init (const char *section, const int quiet)
/* start display */
if ((ret=drv_LL_start (quiet))!=0)
if ((ret=drv_LL_start (section, quiet))!=0)
return ret;
/* initialize generic text driver */
+6 -7
View File
@@ -1,6 +1,6 @@
/* lcd.h
*
* $Id: drv_LCDLinux.h,v 1.1 2005/04/09 07:36:42 reinelt Exp $
* $Id: drv_LCDLinux.h,v 1.2 2005/04/30 06:02:09 reinelt Exp $
*
* LCD driver for HD44780 compatible displays connected to the parallel port.
*
@@ -27,7 +27,7 @@
#ifndef LCD_H
#define LCD_H
#define LCD_LINUX_VERSION "0.8.8" /* Version number */
#define LCD_LINUX_VERSION "0.8.9-CVS" /* Version number */
#define LCD_MAJOR 120 /* Major number for this device
* Set this to 0 for dynamic allocation
@@ -55,11 +55,10 @@ struct lcd_driver {
#define IOCTL_GET_PARAM _IOR(LCD_MAJOR, 1, struct lcd_driver *)
#define LCD_PROC_ON 0x0001 /* Enable the /proc filesystem support */
#define LCD_READ_ON 0x0002 /* Enable the read functions */
#define LCD_ETTY_ON 0x0004 /* Enable the tty support */
#define LCD_CONSOLE 0x0008 /* Enable the console support */
#define LCD_4BITS_BUS 0x0010 /* Set the bus length to 4 bits */
#define LCD_5X10_FONT 0x0020 /* Use 5x10 dots fonts */
#define LCD_ETTY_ON 0x0002 /* Enable the tty support */
#define LCD_CONSOLE 0x0004 /* Enable the console support */
#define LCD_4BITS_BUS 0x0008 /* Set the bus length to 4 bits */
#define LCD_5X10_FONT 0x0010 /* Use 5x10 dots fonts */
+5 -3
View File
@@ -8,6 +8,7 @@ Display Trefon {
Display LCD-Linux {
Driver 'LCD-Linux'
Size '20x2'
}
Display LK204 {
@@ -75,8 +76,9 @@ Display Curses {
Display HD44780-generic {
Driver 'HD44780'
Model 'generic'
Port '/dev/parport0'
Port '/dev/parports/0'
Size '20x4'
asc255bug 1
Wire {
RW 'GND'
RS 'AUTOFD'
@@ -737,7 +739,7 @@ Layout testMySQL {
}
#Display 'LCD-Linux'
Display 'LCD-Linux'
#Display 'LK204'
#Display 'MI240'
#Display 'CW12232'
@@ -756,7 +758,7 @@ Layout testMySQL {
#Display 'USBLCD'
#Display 'BWCT'
#Display 'Image'
Display 'Trefon'
#Display 'Trefon'
#Layout 'Default'
Layout 'L16x2'