#include "correlation.h" #include "buffers.h" #include #include void find_longestmatch(tOutput* output,tCorrelation* correlation,tBuffer* buf1,tBuffer* buf2,tInt64* cursorpos1,tInt64* cursorpos2) { tInt64 idx1; tInt64 idx2; tInt64 match; tInt64 sumpos; tInt64 pos1; tInt64 pos2; tInt16 offsx; tInt16 offsy; WINDOW* smallwin=NULL; tInt64 diff; tBool found=0; if (output) { offsx=COLS/2-22; offsy=LINES/2-3; drawcenterframe(output,6,44,"correlating..."); setcolor(output,COLOR_TEXT); smallwin=subwin(output->win,6,19,offsy,offsx+24); mvwprintw(output->win,offsy+1,offsx+1,"pos1:"); mvwprintw(output->win,offsy+4,offsx+1,"longest match:"); mvwprintw(output->win,offsy+5,offsx+1,"at"); if (smallwin) mvwprintw(smallwin,4,1,"%18lli",0); wrefresh(output->win); } correlation->bestmatch=0; correlation->mindiff=MAX(buf1->bufsize,buf2->bufsize); for (pos1=-(tInt64)buf2->bufsize;pos1<(tInt64)buf1->bufsize;pos1++) { match=0; diff=0; if (smallwin) mvwprintw(smallwin,1,3,"%16lli",((tInt64)buf1->bufsize-pos1)); else fprintf(stderr,"%16lli\r",((tInt64)buf1->bufsize-pos1)); if (smallwin) wrefresh(smallwin); for (pos2=0;pos2bufsize;pos2++) { sumpos=pos1+pos2; if (sumpos>=0 && sumposbufsize) { idx1=getbufferidx(buf1,sumpos); idx2=getbufferidx(buf2,pos2); if (buf1->data[idx1]==buf2->data[idx2]) match++; else { diff++; if (match>correlation->bestmatch) { correlation->bestmatch=match; correlation->bestmatchpos=pos1; correlation->mindiff=diff; if (smallwin) mvwprintw(smallwin,4,1,"%18lli",match); if (smallwin) mvwprintw(smallwin,5,3,"%16llx",pos1); if (smallwin) wrefresh(smallwin); found=1; } match=0; } if (match>correlation->bestmatch) { correlation->bestmatch=match; correlation->bestmatchpos=pos1; correlation->mindiff=diff; if (smallwin) mvwprintw(smallwin,4,1,"%18lli",match); if (smallwin) mvwprintw(smallwin,5,3,"%16llx",pos1); if (smallwin) wrefresh(smallwin); found=1; } } } if (smallwin) wrefresh(smallwin); } if (found) { if (correlation->bestmatch>=0) { *cursorpos1=correlation->bestmatchpos; *cursorpos2=0; } else { *cursorpos1=0; *cursorpos2=-correlation->bestmatchpos; } } if (smallwin) delwin(smallwin); } void find_bestmatch(tOutput* output,tCorrelation* correlation,tBuffer* buf1,tBuffer* buf2,tInt64* cursorpos1,tInt64* cursorpos2) { tInt64 idx1; tInt64 idx2; tInt64 match; tInt64 sumpos; tInt64 pos1; tInt64 pos2; tInt16 offsx; tInt16 offsy; WINDOW* smallwin=NULL; tInt64 diff; tBool found=0; if (output) { offsx=COLS/2-22; offsy=LINES/2-3; drawcenterframe(output,6,44,"correlating..."); setcolor(output,COLOR_TEXT); smallwin=subwin(output->win,6,19,offsy,offsx+24); mvwprintw(output->win,offsy+1,offsx+1,"pos1:"); mvwprintw(output->win,offsy+4,offsx+1,"best match:"); mvwprintw(output->win,offsy+5,offsx+1,"at"); if (smallwin) mvwprintw(smallwin,4,1,"%18lli",0); wrefresh(output->win); } correlation->bestmatch=0; correlation->mindiff=MAX(buf1->bufsize,buf2->bufsize); for (pos1=-(tInt64)buf2->bufsize;pos1<(tInt64)buf1->bufsize;pos1++) { match=0; diff=0; if (output) mvwprintw(smallwin,1,3,"%16lli",((tInt64)buf1->bufsize-pos1)); else fprintf(stderr,"%16lli\r",((tInt64)buf1->bufsize-pos1)); for (pos2=0;pos2bufsize;pos2++) { sumpos=pos1+pos2; if (sumpos>=0 && sumposbufsize) { idx1=getbufferidx(buf1,sumpos); idx2=getbufferidx(buf2,pos2); match+=(buf1->data[idx1]==buf2->data[idx2]); diff+=(buf1->data[idx1]!=buf2->data[idx2]); } else { diff++; } } if (match>correlation->bestmatch) { correlation->bestmatch=match; correlation->bestmatchpos=pos1; correlation->mindiff=diff; if (smallwin) mvwprintw(smallwin,4,1,"%18lli",match); if (smallwin) mvwprintw(smallwin,5,3,"%16llx",pos1); found=1; } if (output) wrefresh(smallwin); } if (found) { if (correlation->bestmatch>=0) { *cursorpos1=correlation->bestmatchpos; *cursorpos2=0; } else { *cursorpos1=0; *cursorpos2=-correlation->bestmatchpos; } } if (smallwin) delwin(smallwin); } void find_mindiff(tOutput* output,tCorrelation* correlation,tBuffer* buf1,tBuffer* buf2,tInt64* cursorpos1,tInt64* cursorpos2) { tInt64 idx1; tInt64 idx2; tInt64 diff; tInt64 sumpos; tInt64 pos1; tInt64 pos2; tInt16 offsx; tInt16 offsy; WINDOW* smallwin=NULL; tBuffer* smallbuf; tBuff
#
# $Id: README.Drivers,v 1.4 2001/03/09 13:08:11 ltoetsch Exp $
#

How to write new display drivers for lcd4linux

If you plan to write a new display driver for lcd4linux, you should follow
this guidelines:

* use Skeleton.c as a start point.
  You might also have a look at Text.c

* create a new sourcefile <drivername>.c and add it to the bottom of
  Makefile.am

* add an entry to configure.in

* there's no need for a <drivername>.h

* create one (or more) unique display names (your driver will be selected by
  this name in the 'Display'-line of lcd4linux.conf).

* include "display.h" in your driver, to get the LCD structure and various 
  BAR_ definitions

* include "cfg.h" if you need to access settings in the config file.

* create a LCD table at the bottom of your driver, and fill it with the
  appropriate values. Take care that you specify the correct bar capabilities
  of your display or driver:

  BAR_L:  horizontal bars headed left
  BAR_R:  horizontal bars headed right
  BAR_H2: driver supports horizontal dual-bars
  BAR_U:  vertical bars bottom-up
  BAR_D:  vertical bars top-down
  BAR_V2: driver supports vertical dual-bars

* edit display.c and create a reference to your LCD table:

     external LCD YourDriver[];

* extend the FAMILY table in display.c with your driver:

     FAMILY Driver[] = {
       { "Skeleton",      Skeleton },
       { "MatrixOrbital", MatrixOrbital },
       { "YourFamily",    YourDriver },
       { "" }
     };

* write the correspondig init(), clear(), put(), bar(), quit() and
  flush()-functions. There's no need to use a framebuffer and display its
  contents with the flush()- call (as in MatrixOrbital.c), you can directly
  write to the display in the put()- and bar()-functions, and use an empty
  flush()-function. But if you have a limited number of user-defined
  characters, and therefore you have to do some sort of 'character reduction'
  or similar stuff, you will have to use a framebuffer and the flush()-call.