To use this file copy and paste this:
// #URL-lib "http://pin1.org/forthlib/flb/General/LCD-Graphic.flb" into BV Terminal 3
or here to download.
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// LCD display driver
//
// This is the basic driver for LCD-graphic Display Modules. At
// the moment works but still needs some more work, it is included
// here so that useres may get an idea of how to drive one of these
// 128 x 64 pixel arrays, see also the LCD-Graphic-T.fth in the
// examples folder.
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// HISTORY:
// *******************************************************
//
// *******************************************************
//
// REQUIRES:
// #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb"
// CONSTANTS:
// ========= change this section to match the display ===============
// constants used for different display types, the value is
// the command + &80 to return the cursor to the start of
// the row. This can be found by trial and error using LCDDD
0 constant row0
64 constant row1
20 constant row2
84 constant row3
// constants relate pin numbers to function, note they do not
// relate the port, this is done in the actual code
-27 constant RS
-28 constant RW
23 constant E
-29 constant D0
20 constant D1
19 constant D2
18 constant D3
-30 constant D4
-20 constant D5
17 constant D6
16 constant D7
//
14 constant CS1
-22 constant CS2
13 constant /RST
//
// Variables
variable LCDpen // used for pen up/ doen in graphics section
Full Contents of File
0    constant  row0
64  constant  row1
20  constant  row2
84  constant  row3
-27  constant  RS 
-28  constant  RW   
23  constant  E 
-29  constant  D0
20  constant  D1
19  constant  D2 
18  constant  D3
-30  constant  D4 
-20  constant  D5
17  constant  D6 
16  constant  D7 
14  constant  CS1 
-22  constant  CS2 
13  constant 
variable  LCDpen     
: LCDctrl
        RS  io-out    RW  io-out    E    io-out    CS1  io-out 
        CS2  io-out 
;
: LCDdin
        D0  io-in  D1  io-in  D2  io-in  D3  io-in
        D4  io-in  D5  io-in  D6  io-in  D7  io-in 
;
: LCDdout
        D0  io-out  D1  io-out  D2  io-out  D3  io-out 
        D4  io-out  D5  io-out  D6  io-out  D7  io-out
;
: LCDrsRS  p!  ;
: LCDrwRW  p!  ; 
: LCDeE  p!  ;
: LCDcs1CS1  p!  ;
: LCDcs2CS2  p!  ; 
: LCDrst
: LCDout
        1  LCDe 
       
        dup  1  and  D0  p!       
        1  rshift                       
        dup  1  and  D1  p!       
        1  rshift                       
        dup  1  and  D2  p!       
        1  rshift                       
        dup  1  and  D3  p!       
        1  rshift                       
        dup  1  and  D4  p!       
        1  rshift                       
        dup  1  and  D5  p!       
        1  rshift                       
        dup  1  and  D6  p!       
        1  rshift                       
        1  and  D7  p!               
       
        0  LCDe
   
;
: LCDread
        LCDdin
        1  LCDrw                 
        1  LCDrs
        1  LCDe  0  LCDe     
        1  LCDe
        0             
       
        D7  p@  if  1+  then     
        1  lshift                       
        D6  p@  if  1+  then     
        1  lshift                       
        D5  p@  if  1+  then     
        1  lshift                       
        D4  p@  if  1+  then     
        1  lshift                       
        D3  p@  if  1+  then     
        1  lshift                       
        D2  p@  if  1+  then     
        1  lshift                       
        D1  p@  if  1+  then     
        1  lshift                       
        D0  p@  if  1+  then     
        0  LCDrw         
        LCDdout         
;       
     
: LCDreset0  LCDrst  1  ms  1  LCDrst  ; 
: LCDdata
        1  LCDrs
        0  LCDrw               
        LCDout
;
: LCDcmd
        0  LCDrs
        0  LCDrw               
        LCDout
;
: LCDinit
        LCDctrl               
        LCDdout
        0  LCDrs               
        0  LCDrw               
        LCDreset             
        1  LCDcs1
        1  LCDcs2               
        &3f  LCDcmd  10  ms       
        1  LCDrs               
;           
: LCDpanelif  0  LCDcs1  1  LCDcs2  else  1  LCDcs1  0  LCDcs2  then  ;
: LCDxpos7  min  &b8  +  LCDcmd  ;
: LCDypos
                127  min  dup  63  > 
                if
                        1  LCDpanel  64  -
                else
                        0  LCDpanel
                then
                &40  +  LCDcmd 
;
: LCDxy  LCDypos  LCDxpos  ;
: LCDfill
        8  for             
                128  for         
                        j  i  LCDxy
                        dup  LCDdata
                next
        next
        drop
;                                                                                       
: LCDcls&ff  LCDfill  ;
: LCDpenDown1  LCDpen  !  ;
: LCDpenUp0  LCDpen  !  ;
: LCDpix
       
        8 
       
        rot  2dup  LCDxy  LCDread  >r  LCDxy           
        1  swap  lshift     
        LCDpen  @               
        if
                &ff  swap  bic  r>  and  LCDdata 
        else
                r>  or  LCDdata 
        then       
;
: LCDver
        for
                2dup       
                LCDpix
                1+           
        next
        2drop
;                                                                           
: LCDhor
        for
                2dup       
                LCDpix
                1  +under   
        next
        2drop
;
: #LCDhl#drop  swap  drop  swap  -  1+  ;     
: #LCDvl#swap  drop  swap  -  swap  drop  1+  ;       
: #4dup#2over  2over  ;
: #x2y1#drop  rot  drop  swap  ;
: #x1y2#swap  drop  swap  drop  ;
: LCDbox
        #4dup#  #LCDhl#  >r  2over  r>  LCDhor   
        #4dup#  #LCDvl#  >r  2over  r>  LCDver   
        #4dup#  #LCDhl#  >r  #4dup#  #x1y2#  r>  LCDhor 
        #4dup#  #LCDvl#  >r  #x2y1#  r>  LCDver 
;
: #LCDmap#
        32  for
                1  lshiftc  lcdpen  !  >r
                2dup  LCDpix
                1  +under   
                r>
        next
        2drop  drop
;
: LCDmap
        for
                dup  >r  @  >r  2dup  r>  #LCDmap#
                1+           
                r>  4  +   
        next
        drop  2drop
;