From 9213e38c6738eaa787ad6a5349f103e36363dd44 Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Mon, 1 Mar 2004 04:29:51 +0000 Subject: [lcd4linux @ 2004-03-01 04:29:51 by reinelt] cfg_number() returns -1 on error, 0 if value not found (but default val used), and 1 if value was used from the configuration. HD44780 driver adopted to new cfg_number() Crystalfontz 631 driver nearly finished --- cfg.c | 10 ++++++++-- drv_Crystalfontz.c | 38 ++++++++++++++++++++++++++------------ drv_HD44780.c | 10 ++++++++-- lcd4linux.conf.sample | 21 +++++++++++++-------- 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/cfg.c b/cfg.c index 355022b..5fb0087 100644 --- a/cfg.c +++ b/cfg.c @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.34 2004/02/18 06:39:20 reinelt Exp $^ +/* $Id: cfg.c,v 1.35 2004/03/01 04:29:51 reinelt Exp $^ * * config file stuff * @@ -23,6 +23,12 @@ * * * $Log: cfg.c,v $ + * Revision 1.35 2004/03/01 04:29:51 reinelt + * cfg_number() returns -1 on error, 0 if value not found (but default val used), + * and 1 if value was used from the configuration. + * HD44780 driver adopted to new cfg_number() + * Crystalfontz 631 driver nearly finished + * * Revision 1.34 2004/02/18 06:39:20 reinelt * T6963 driver for graphic displays finished * @@ -504,7 +510,7 @@ int l4l_cfg_number (char *section, char *key, int defval, int min, int max, int return -1; } - return 0; + return 1; } diff --git a/drv_Crystalfontz.c b/drv_Crystalfontz.c index b1d7a09..ed26896 100644 --- a/drv_Crystalfontz.c +++ b/drv_Crystalfontz.c @@ -1,4 +1,4 @@ -/* $Id: drv_Crystalfontz.c,v 1.11 2004/02/14 11:56:17 reinelt Exp $ +/* $Id: drv_Crystalfontz.c,v 1.12 2004/03/01 04:29:51 reinelt Exp $ * * new style driver for Crystalfontz display modules * @@ -23,6 +23,12 @@ * * * $Log: drv_Crystalfontz.c,v $ + * Revision 1.12 2004/03/01 04:29:51 reinelt + * cfg_number() returns -1 on error, 0 if value not found (but default val used), + * and 1 if value was used from the configuration. + * HD44780 driver adopted to new cfg_number() + * Crystalfontz 631 driver nearly finished + * * Revision 1.11 2004/02/14 11:56:17 reinelt * M50530 driver ported * changed lots of 'char' to 'unsigned char' @@ -329,13 +335,13 @@ static void drv_CF_write2 (unsigned char *string, int len) { // limit length if (Col+len>16) len=16-Col; + if (len<0) len=0; // sanity check if (Row>=2 || Col+len>16) { error ("%s: internal error: write outside linebuffer bounds!", Name); return; } - memcpy (Line+16*Row+Col, string, len); drv_CF_send (7+Row, 16, Line+16*Row); } @@ -344,6 +350,8 @@ static void drv_CF_write2 (unsigned char *string, int len) static void drv_CF_write3 (unsigned char *string, int len) { debug ("write3(<%.*s>,%d)", len, string, len); + + } @@ -401,25 +409,31 @@ static int drv_CF_contrast (int contrast) if (contrast == -1) return Contrast; if (contrast < 0 ) contrast = 0; - if (contrast > 100) contrast = 100; Contrast=contrast; switch (Protocol) { case 1: + // contrast range 0 to 100 + if (contrast > 100) contrast = 100; buffer[0] = 15; // Set LCD Contrast - buffer[1] = Contrast; + buffer[1] = contrast; drv_CF_write1 (buffer, 2); break; case 2: + // contrast range 0 to 50 + if (contrast > 50) contrast = 50; + drv_CF_send (13, 1, &contrast); + break; case 3: - // Contrast goes from 0 to 50 only - if (Contrast>50) Contrast=50; - drv_CF_send (13, 1, &Contrast); + // contrast range 0 to 50 + if (contrast > 255) contrast = 255; + drv_CF_send (13, 1, &contrast); break; } + Contrast=contrast; return Contrast; } @@ -501,13 +515,13 @@ static int drv_CF_autodetect (void) if (drv_CF_poll()) { // display type if (Packet.type==0x41) { - char t[7]; float h, v; + char t[7], c; float h, v; info ("%s: display identifies itself as '%s'", Name, Packet.data); - if (sscanf(Packet.data, "%6s:h%f,v%f", t, &h, &v)!=3) { + if (sscanf(Packet.data, "%6s:h%f,%c%f", t, &h, &c, &v)!=4) { error ("%s: error parsing display identification string", Name); return -1; } - info ("%s: display type '%s', hardware version %3.1f, firmware version %3.1f", Name, t, h, v); + info ("%s: display type '%s', hardware version %3.1f, firmware version %c%3.1f", Name, t, h, c, v); if (strncmp(t, "CFA", 3)==0) { for (m=0; Models[m].type!=-1; m++) { // omit the 'CFA' @@ -709,12 +723,12 @@ static int drv_CF_start (char *section) memset (Line, ' ', sizeof(Line)); // set contrast - if (cfg_number(section, "Contrast", 0, 0, 100, &i)==0) { + if (cfg_number(section, "Contrast", 0, 0, 100, &i)>0) { drv_CF_contrast(i); } // set backlight - if (cfg_number(section, "Backlight", 0, 0, 100, &i)==0) { + if (cfg_number(section, "Backlight", 0, 0, 100, &i)>0) { drv_CF_backlight(i); } diff --git a/drv_HD44780.c b/drv_HD44780.c index a942de7..62b5e3b 100644 --- a/drv_HD44780.c +++ b/drv_HD44780.c @@ -1,4 +1,4 @@ -/* $Id: drv_HD44780.c,v 1.13 2004/02/15 21:43:43 reinelt Exp $ +/* $Id: drv_HD44780.c,v 1.14 2004/03/01 04:29:51 reinelt Exp $ * * new style driver for HD44780-based displays * @@ -29,6 +29,12 @@ * * * $Log: drv_HD44780.c,v $ + * Revision 1.14 2004/03/01 04:29:51 reinelt + * cfg_number() returns -1 on error, 0 if value not found (but default val used), + * and 1 if value was used from the configuration. + * HD44780 driver adopted to new cfg_number() + * Crystalfontz 631 driver nearly finished + * * Revision 1.13 2004/02/15 21:43:43 reinelt * T6963 driver nearly finished * framework for graphic displays done @@ -639,7 +645,7 @@ static int drv_HD_start (char *section) // maybe set brightness if (Capabilities & CAP_BRIGHTNESS) { int brightness; - if (cfg_number(section, "Brightness", 0, 0, 3, &brightness)==0) { + if (cfg_number(section, "Brightness", 0, 0, 3, &brightness)>0) { drv_HD_brightness(brightness); } } diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 68416aa..1147236 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -9,12 +9,13 @@ Display LK204 { Display CF631 { - Icons 2 + Icons 5 Driver 'Crystalfontz' Model '631' Port '/dev/usb/tts/0' - Port '/dev/tts/0' Speed 115200 + Contrast 95 + Backlight 100 } Display CF632 { @@ -370,7 +371,11 @@ Layout L16x2 { Col1 'Busy' Col11 'BusyBar' } -# Row2 { + Row2 { + Col1 'Disk' + Col11 'DiskBar' + } +# Row2 { # Col1 'Heartbeat' # Col2 'EKG' # Col3 'Karo' @@ -378,7 +383,7 @@ Layout L16x2 { # Col5 'Blob' # Col6 'Wave' # Col7 'Squirrel' -# } +# } } Layout Test { @@ -403,15 +408,15 @@ Layout Test { #Display 'LK204' #Display 'HD44780-20x4' #Display 'M50530-24x8' -#Display 'CF631' +Display 'CF631' #Display 'CF632' #Display 'CF633' #Display 'USBLCD' -Display 'T6963-240x64' +#Display 'T6963-240x64' #Display 'XWindow' -Layout 'Default' -#Layout 'L16x2' +#Layout 'Default' +Layout 'L16x2' #Layout 'Test' -- cgit v1.2.3