From 14a16b9f66c6e8c144f300e07d0ddb5b6787a11a Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Wed, 18 Feb 2004 06:39:20 +0000 Subject: [lcd4linux @ 2004-02-18 06:39:20 by reinelt] T6963 driver for graphic displays finished --- cfg.c | 7 +++- drv_T6963.c | 106 ++++++++++++++++++++++++++++++++++---------------- drv_generic_graphic.c | 72 +++++++++++++++++----------------- drv_generic_graphic.h | 14 ++++--- drv_generic_text.h | 7 +++- lcd4linux.conf.sample | 30 +++++++++++++- widget.c | 7 +++- widget_text.c | 7 +++- 8 files changed, 167 insertions(+), 83 deletions(-) diff --git a/cfg.c b/cfg.c index fd94052..355022b 100644 --- a/cfg.c +++ b/cfg.c @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.33 2004/02/01 18:08:50 reinelt Exp $^ +/* $Id: cfg.c,v 1.34 2004/02/18 06:39:20 reinelt Exp $^ * * config file stuff * @@ -23,6 +23,9 @@ * * * $Log: cfg.c,v $ + * Revision 1.34 2004/02/18 06:39:20 reinelt + * T6963 driver for graphic displays finished + * * Revision 1.33 2004/02/01 18:08:50 reinelt * removed strtok() from layout processing (took me hours to find this bug) * further strtok() removind should be done! @@ -464,7 +467,7 @@ char *l4l_cfg_get (char *section, char *key, char *defval) return R2S(&result); } } - return defval; + return strdup(defval); } diff --git a/drv_T6963.c b/drv_T6963.c index 2706805..5a0e6a7 100644 --- a/drv_T6963.c +++ b/drv_T6963.c @@ -1,4 +1,4 @@ -/* $Id: drv_T6963.c,v 1.1 2004/02/15 21:43:43 reinelt Exp $ +/* $Id: drv_T6963.c,v 1.2 2004/02/18 06:39:20 reinelt Exp $ * * new style driver for T6963-based displays * @@ -23,6 +23,9 @@ * * * $Log: drv_T6963.c,v $ + * Revision 1.2 2004/02/18 06:39:20 reinelt + * T6963 driver for graphic displays finished + * * Revision 1.1 2004/02/15 21:43:43 reinelt * T6963 driver nearly finished * framework for graphic displays done @@ -81,6 +84,8 @@ static unsigned char SIGNAL_CD; static unsigned char SIGNAL_RD; static unsigned char SIGNAL_WR; +unsigned char *Buffer1, *Buffer2; + // Fixme: static int bug=0; @@ -261,14 +266,14 @@ static void drv_T6_send_word (unsigned char cmd, unsigned short data) } -static void drv_T6_memset(unsigned short addr, unsigned char data, int len) +static void drv_T6_clear(unsigned short addr, int len) { int i; drv_T6_send_word (0x24, addr); // Set Adress Pointer drv_T6_write_cmd(0xb0); // Set Data Auto Write for (i=0; i4) break; + } else { + e=0; + } + } + memcpy (Buffer2+j, Buffer1+j, i-j-e+1); + drv_T6_copy (j, Buffer1+j, i-j-e+1); + // sleep (1); + } +} + static int drv_T6_start (char *section) { char *model, *s; - int rows, cols; + int rows, TROWS, TCOLS; model=cfg_get(section, "Model", "generic"); if (model!=NULL && *model!='\0') { @@ -319,6 +361,7 @@ static int drv_T6_start (char *section) return -1; } + // read display size from config s=cfg_get(section, "Size", NULL); if (s==NULL || *s=='\0') { error ("%s: no '%s.Size' entry from %s", Name, section, cfg_source()); @@ -332,19 +375,25 @@ static int drv_T6_start (char *section) return -1; } - s=cfg_get(section, "Font", "6x8"); - if (s==NULL || *s=='\0') { - error ("%s: no '%s.Font' entry from %s", Name, section, cfg_source()); + TROWS=DROWS/8; // text rows, assume 6x8 font + TCOLS=DCOLS/6; // text cols, assume 6x8 font + + Buffer1=malloc(DCOLS*TROWS); + if (Buffer1==NULL) { + error ("%s: framebuffer #1 could not be allocated: malloc() failed", Name); return -1; } - XRES = -1; - YRES = -1; - if (sscanf(s, "%dx%d", &XRES, &YRES)!=2 || XRES<1 || YRES<1) { - error ("%s: bad Font '%s' from %s", Name, s, cfg_source()); + Buffer2=malloc(DCOLS*TROWS); + if (Buffer2==NULL) { + error ("%s: framebuffer #2 could not be allocated: malloc() failed", Name); return -1; } + + memset(Buffer1,0,TCOLS*DROWS*sizeof(*Buffer1)); + memset(Buffer2,0,TCOLS*DROWS*sizeof(*Buffer2)); + if (drv_generic_parport_open(section, Name) != 0) { error ("%s: could not initialize parallel port!", Name); return -1; @@ -362,15 +411,12 @@ static int drv_T6_start (char *section) drv_generic_parport_direction (0); // initialize display - - rows=DROWS/8; // text rows, assume 6x8 font - cols=DCOLS/6; // text cols, assume 6x8 font drv_T6_send_word (0x40, 0x0000); // Set Text Home Address - drv_T6_send_word (0x41, cols); // Set Text Area + drv_T6_send_word (0x41, TCOLS); // Set Text Area drv_T6_send_word (0x42, 0x0200); // Set Graphic Home Address - drv_T6_send_word (0x43, cols); // Set Graphic Area + drv_T6_send_word (0x43, TCOLS); // Set Graphic Area drv_T6_write_cmd (0x80); // Mode Set: OR mode, Internal CG RAM mode drv_T6_send_word (0x22, 0x0002); // Set Offset Register @@ -382,17 +428,17 @@ static int drv_T6_start (char *section) // clear display // upper half - if (rows>8) rows=8; - drv_T6_memset(0x0000, 0, cols*rows); // clear text area - drv_T6_memset(0x0200, 0, cols*rows*8); // clear graphic area + rows=TROWS>8?8:TROWS; + drv_T6_clear(0x0000, TCOLS*rows); // clear text area + drv_T6_clear(0x0200, TCOLS*rows*8); // clear graphic area // lower half - if (DROWS>8*8) { - rows=DROWS/8-8; - drv_T6_memset(0x8000, 0, cols*rows); // clear text area #2 - drv_T6_memset(0x8200, 0, cols*rows*8); // clear graphic area #2 + if (TROWS>8) { + rows=TROWS-8; + drv_T6_clear(0x8000, TCOLS*rows); // clear text area #2 + drv_T6_clear(0x8200, TCOLS*rows*8); // clear graphic area #2 } - + return 0; } @@ -437,14 +483,8 @@ int drv_T6_init (char *section) WIDGET_CLASS wc; int ret; - // display preferences - GOTO_COST = 2; // number of bytes a goto command requires - // real worker functions - // Fixme: which one? - // drv_generic_text_real_write = drv_T6_write; - // drv_generic_text_real_goto = drv_T6_goto; - // drv_generic_text_real_defchar = drv_T6_defchar; + drv_generic_graphic_real_blit = drv_T6_blit; // start display if ((ret=drv_T6_start (section))!=0) diff --git a/drv_generic_graphic.c b/drv_generic_graphic.c index 058b83c..ac27be9 100644 --- a/drv_generic_graphic.c +++ b/drv_generic_graphic.c @@ -23,6 +23,9 @@ * * * $Log: drv_generic_graphic.c,v $ + * Revision 1.2 2004/02/18 06:39:20 reinelt + * T6963 driver for graphic displays finished + * * Revision 1.1 2004/02/15 21:43:43 reinelt * T6963 driver nearly finished * framework for graphic displays done @@ -71,10 +74,8 @@ static char *Driver=NULL; int DROWS, DCOLS; // display size (pixels!) int LROWS, LCOLS; // layout size (pixels!) int XRES, YRES; // pixels of one char cell -int GOTO_COST; // number of bytes a goto command requires -static unsigned char *LayoutFB = NULL; -static unsigned char *DisplayFB = NULL; +unsigned char *drv_generic_graphic_FB = NULL; // **************************************** @@ -99,27 +100,21 @@ static void drv_generic_graphic_resizeFB (int rows, int cols) memset (newFB, 0, rows*cols*sizeof(char)); // transfer contents - if (LayoutFB!=NULL) { + if (drv_generic_graphic_FB!=NULL) { for (row=0; rowdata; @@ -142,7 +137,7 @@ int drv_generic_graphic_draw (WIDGET *W) int mask=1<>=1; - LayoutFB[(row+y)*LCOLS+col+x] = Font_6x8[c][y]&mask ? 1:0; + drv_generic_graphic_FB[(row+y)*LCOLS+col+x] = Font_6x8[c][y]&mask ? 1:0; } } col+=XRES; @@ -150,7 +145,7 @@ int drv_generic_graphic_draw (WIDGET *W) } // flush area - drv_generic_graphic_flush (row, col, YRES, XRES*len); + drv_generic_graphic_real_blit (YRES*W->row, XRES*W->col, YRES, XRES*len); return 0; } @@ -178,12 +173,12 @@ int drv_generic_graphic_icon_draw (WIDGET *W) int mask=1<>=1; - DisplayFB[(row+y)*LCOLS+col+x] = Icon->visible ? 0 : bitmap[y]&mask ? 1 : 0; + drv_generic_graphic_FB[(row+y)*LCOLS+col+x] = Icon->visible ? 0 : bitmap[y]&mask ? 1 : 0; } } // flush area - drv_generic_graphic_flush (row, col, YRES, XRES); + drv_generic_graphic_real_blit (row, col, YRES, XRES); return 0; @@ -236,7 +231,7 @@ int drv_generic_graphic_bar_draw (WIDGET *W) for (y=0; yname)+8); -- cgit v1.2.3