diff options
author | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-02-18 06:39:20 +0000 |
---|---|---|
committer | reinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2004-02-18 06:39:20 +0000 |
commit | 347ac211c9bb0365d8a5c3a1b943cbd2856c4df3 (patch) | |
tree | 9affd3c010dc849cb9a31932aa8f92f8a99d3451 | |
parent | b909b6b46370442faf358fd8507ad96798051644 (diff) | |
download | lcd4linux-347ac211c9bb0365d8a5c3a1b943cbd2856c4df3.tar.gz |
[lcd4linux @ 2004-02-18 06:39:20 by reinelt]
T6963 driver for graphic displays finished
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@371 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
-rw-r--r-- | cfg.c | 7 | ||||
-rw-r--r-- | drv_T6963.c | 106 | ||||
-rw-r--r-- | drv_generic_graphic.c | 72 | ||||
-rw-r--r-- | drv_generic_graphic.h | 14 | ||||
-rw-r--r-- | drv_generic_text.h | 7 | ||||
-rw-r--r-- | lcd4linux.conf.sample | 30 | ||||
-rw-r--r-- | widget.c | 7 | ||||
-rw-r--r-- | widget_text.c | 7 |
8 files changed, 167 insertions, 83 deletions
@@ -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; i<len; i++) { - drv_T6_write_auto(data); + drv_T6_write_auto(0); if (bug) { bug=0; debug("bug occured at byte %d of %d", i, len); @@ -279,7 +284,7 @@ static void drv_T6_memset(unsigned short addr, unsigned char data, int len) } -static void drv_T6_memcpy(unsigned short addr, unsigned char *data, int len) +static void drv_T6_copy(unsigned short addr, unsigned char *data, int len) { int i; @@ -293,14 +298,51 @@ static void drv_T6_memcpy(unsigned short addr, unsigned char *data, int len) } } drv_T6_status2(); - drv_T6_write_cmd(0xb2); // Auto Reset + drv_T6_write_cmd(0xb2); // Auto Reset } +static void drv_T6_blit(int row, int col, int height, int width) +{ + int i, j, e, m; + int r, c; + + for (r=row; r<row+height; r++) { + for (c=col; c<col+width; c++) { + unsigned char mask = 1<<(XRES-1-c%XRES); + //if (c<8) debug ("c=%d c%%XRES=%d mask=%d", c, c%XRES, mask); + if (drv_generic_graphic_FB[r*LCOLS+c]) { + // set bit + Buffer1[(r*DCOLS+c)/XRES] |= mask; + } else { + // clear bit + Buffer1[(r*DCOLS+c)/XRES] &= ~mask; + } + } + } + + // max address + m=((row+height)*DCOLS+col+width)/XRES; + + for (i=(row*DCOLS+col)/XRES; i<=m; i++) { + if (Buffer1[i]==Buffer2[i]) continue; + for (j=i, e=0; i<=m; i++) { + if (Buffer1[i]==Buffer2[i]) { + if (++e>4) 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; row<LROWS; row++) { for (col=0; col<LCOLS; col++) { - newFB[row*cols+col]=LayoutFB[row*LCOLS+col]; + newFB[row*cols+col]=drv_generic_graphic_FB[row*LCOLS+col]; } } - free (LayoutFB); + free (drv_generic_graphic_FB); } - LayoutFB = newFB; + drv_generic_graphic_FB = newFB; LCOLS = cols; LROWS = rows; } -static void drv_generic_graphic_flush (int row0, int col0, int rows, int cols) -{ - debug ("flushing from (%d, %d) size (%d, %d)", row0, col0, rows, cols); -} - - int drv_generic_graphic_draw (WIDGET *W) { WIDGET_TEXT *Text=W->data; @@ -142,7 +137,7 @@ int drv_generic_graphic_draw (WIDGET *W) int mask=1<<XRES; for (x=0; x<XRES; x++) { mask>>=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<<XRES; for (x=0; x<XRES; x++) { mask>>=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; y<YRES; y++) { len=y<YRES/2 ? val1 : val2; for (x=0; x<max; x++) { - LayoutFB[(row+y)*LCOLS+col+x] = x<len ? !rev : rev; + drv_generic_graphic_FB[(row+y)*LCOLS+col+x] = x<len ? !rev : rev; } } break; @@ -250,7 +245,7 @@ int drv_generic_graphic_bar_draw (WIDGET *W) for (y=0; y<max; y++) { for (x=0; x<XRES; x++) { len=x<XRES/2 ? val1 : val2; - LayoutFB[(row+y)*LCOLS+col+x] = y<len ? !rev : rev; + drv_generic_graphic_FB[(row+y)*LCOLS+col+x] = y<len ? !rev : rev; } } break; @@ -258,9 +253,9 @@ int drv_generic_graphic_bar_draw (WIDGET *W) // flush area if (dir & (DIR_EAST|DIR_WEST)) { - drv_generic_graphic_flush (row, col, YRES, XRES*len); + drv_generic_graphic_real_blit (row, col, YRES, XRES*len); } else { - drv_generic_graphic_flush (row, col, YRES*len, XRES); + drv_generic_graphic_real_blit (row, col, YRES*len, XRES); } return 0; @@ -273,21 +268,32 @@ int drv_generic_graphic_bar_draw (WIDGET *W) int drv_generic_graphic_init (char *section, char *driver) { + char *font; + Section=section; Driver=driver; - - // init display framebuffer - DisplayFB = malloc(DCOLS*DROWS*sizeof(char)); - memset (DisplayFB, 0, DROWS*DCOLS*sizeof(char)); + font=cfg_get(section, "Font", "6x8"); + if (font==NULL || *font=='\0') { + error ("%s: no '%s.Font' entry from %s", Driver, section, cfg_source()); + return -1; + } + + XRES = -1; + YRES = -1; + if (sscanf(font, "%dx%d", &XRES, &YRES)!=2 || XRES<1 || YRES<1) { + error ("%s: bad Font '%s' from %s", Driver, font, cfg_source()); + return -1; + } + // init layout framebuffer LROWS = 0; LCOLS = 0; - LayoutFB=NULL; + drv_generic_graphic_FB=NULL; drv_generic_graphic_resizeFB (DROWS, DCOLS); // sanity check - if (LayoutFB==NULL || DisplayFB==NULL) { + if (drv_generic_graphic_FB==NULL) { error ("%s: framebuffer could not be allocated: malloc() failed", Driver); return -1; } @@ -298,15 +304,9 @@ int drv_generic_graphic_init (char *section, char *driver) int drv_generic_graphic_quit (void) { - - if (LayoutFB) { - free(LayoutFB); - LayoutFB=NULL; - } - - if (DisplayFB) { - free(DisplayFB); - DisplayFB=NULL; + if (drv_generic_graphic_FB) { + free(drv_generic_graphic_FB); + drv_generic_graphic_FB=NULL; } return (0); diff --git a/drv_generic_graphic.h b/drv_generic_graphic.h index 3850b7f..209e1a8 100644 --- a/drv_generic_graphic.h +++ b/drv_generic_graphic.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_graphic.h,v 1.1 2004/02/15 21:43:43 reinelt Exp $ +/* $Id: drv_generic_graphic.h,v 1.2 2004/02/18 06:39:20 reinelt Exp $ * * generic driver helper for graphic displays * @@ -23,6 +23,9 @@ * * * $Log: drv_generic_graphic.h,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 @@ -50,13 +53,14 @@ extern int DROWS, DCOLS; // display size extern int LROWS, LCOLS; // layout size extern int XRES, YRES; // pixel width/height of one char -extern int GOTO_COST; // number of bytes a goto command requires -// these functions must be implemented by the real driver -// Fixme: -void (*drv_generic_graphic_real_memcpy)(void); +// framebuffer +extern unsigned char *drv_generic_graphic_FB; +// these functions must be implemented by the real driver +void (*drv_generic_graphic_real_blit)(int row, int col, int height, int width); +// generic functions and widget callbacks int drv_generic_graphic_init (char *section, char *driver); int drv_generic_graphic_draw (WIDGET *W); int drv_generic_graphic_icon_draw (WIDGET *W); diff --git a/drv_generic_text.h b/drv_generic_text.h index f6c8099..05d7fd5 100644 --- a/drv_generic_text.h +++ b/drv_generic_text.h @@ -1,4 +1,4 @@ -/* $Id: drv_generic_text.h,v 1.6 2004/02/15 21:43:43 reinelt Exp $ +/* $Id: drv_generic_text.h,v 1.7 2004/02/18 06:39:20 reinelt Exp $ * * generic driver helper for text-based displays * @@ -23,6 +23,9 @@ * * * $Log: drv_generic_text.h,v $ + * Revision 1.7 2004/02/18 06:39:20 reinelt + * T6963 driver for graphic displays finished + * * Revision 1.6 2004/02/15 21:43:43 reinelt * T6963 driver nearly finished * framework for graphic displays done @@ -77,7 +80,7 @@ void (*drv_generic_text_real_goto)(int row, int col); void (*drv_generic_text_real_write)(unsigned char *buffer, int len); void (*drv_generic_text_real_defchar)(int ascii, unsigned char *buffer); - +// generic functions and widget callbacks int drv_generic_text_init (char *section, char *driver); int drv_generic_text_draw (WIDGET *W); int drv_generic_text_icon_init (void); diff --git a/lcd4linux.conf.sample b/lcd4linux.conf.sample index 73cf1fc..567970e 100644 --- a/lcd4linux.conf.sample +++ b/lcd4linux.conf.sample @@ -252,6 +252,13 @@ Widget Squirrel { } } +Widget Test { + class 'Text' + expression '1234567890123456789012345678901234567890' + #expression '|' + width 40 +} + Layout Default { Row1 { @@ -296,6 +303,25 @@ Layout L16x2 { # } } +Layout Test { + Row01.Col1 'Test' + Row02.Col1 'Test' + Row03.Col1 'Test' + Row04.Col1 'Test' + Row05.Col1 'Test' + Row06.Col1 'Test' + Row07.Col1 'Test' + Row08.Col1 'Test' + Row09.Col1 'Test' + Row10.Col1 'Test' + Row11.Col1 'Test' + Row12.Col1 'Test' + Row13.Col1 'Test' + Row14.Col1 'Test' + Row15.Col1 'Test' + Row16.Col1 'Test' +} + #Display 'LK204' #Display 'HD44780-20x4' #Display 'M50530-24x8' @@ -305,8 +331,10 @@ Layout L16x2 { #Display 'USBLCD' Display 'T6963-240x64' -Layout 'Default' +#Layout 'Default' #Layout 'L16x2' +Layout 'Test' + Variables { tick 500 @@ -1,4 +1,4 @@ -/* $Id: widget.c,v 1.11 2004/01/30 20:57:56 reinelt Exp $ +/* $Id: widget.c,v 1.12 2004/02/18 06:39:20 reinelt Exp $ * * generic widget handling * @@ -21,6 +21,9 @@ * * * $Log: widget.c,v $ + * Revision 1.12 2004/02/18 06:39:20 reinelt + * T6963 driver for graphic displays finished + * * Revision 1.11 2004/01/30 20:57:56 reinelt * HD44780 patch from Martin Hejl * dmalloc integrated @@ -141,7 +144,7 @@ int widget_add (char *name, int row, int col) section=malloc(strlen(name)+8); strcpy(section, "Widget:"); strcat(section, name); - + // get widget class class=cfg_get(section, "class", NULL); if (class==NULL || *class=='\0') { diff --git a/widget_text.c b/widget_text.c index c2112e8..a936feb 100644 --- a/widget_text.c +++ b/widget_text.c @@ -1,4 +1,4 @@ -/* $Id: widget_text.c,v 1.12 2004/02/09 19:49:38 nicowallmeier Exp $ +/* $Id: widget_text.c,v 1.13 2004/02/18 06:39:20 reinelt Exp $ * * simple text widget handling * @@ -21,6 +21,9 @@ * * * $Log: widget_text.c,v $ + * Revision 1.13 2004/02/18 06:39:20 reinelt + * T6963 driver for graphic displays finished + * * Revision 1.12 2004/02/09 19:49:38 nicowallmeier * Minor bugfix * @@ -303,7 +306,7 @@ int widget_text_init (WIDGET *Self) { char *section; char *c; WIDGET_TEXT *Text; - + // prepare config section // strlen("Widget:")=7 section=malloc(strlen(Self->name)+8); |