To use this file copy and paste this:
// #URL-lib "http://pin1.org/forthlib/flb/I2C/bv4219-term.fth" into BV Terminal 3
or here to download.
// Example of using the BV4219 as a terminal, this will also
// respond to some VT100 escape codes
// Go word is 'term'
// REQUIRES:
// #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" sid=0
// #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb" sid=101
// #URL-Lib "http://pin1.org/forthlib/flb/I2C/i2c.flb" sid=102
// #URL-lib "http://pin1.org/forthlib/flb/I2C/bv4219.flb" sid=103
// CONSTANTS:
// set this to the device address
&42 constant dev_address
Full Contents of File
&42  constant  dev_address
: getnum
v$:  buf  16
int#:  bcount  0
        begin
                key  dup  48  57  between
        while       
                %@  buf  bcount  +  c!
                1  +>  bcount
        repeat       
        0  %@  buf  bcount  +  c! 
        %@  buf  ?number  drop 
;       
: vt100
int:  p1  p2  p3  p4
        key  [char]  [  <>  if  drop  escape  then
        getnum  =>  p1  =>  p2 
        p2  [char]  ;  =  if  getnum  =>  p3  =>  p4  then
        p4  [char]  H  =  if  p1  p3  a25  then
        p2  [char]  A  =  if  a28  p1  -  0  max  a8  then 
        p2  [char]  J  =  if  p1  2  =  if  a5  then  then 
;       
: device?
        dev_address  4219-init
        if
                400000  i2speed  ; 
        else
                ."  Can't  initialise  device"
                abort
        then
;                       
: term
int:  curr_pos
        device?  50  ms
        a5  50  ms 
        begin       
            key
            dup  27  =  if 
                drop  vt100
            else   
                dup  3  =  if  abort  then 
                dup  13  =  if 
                                a28  7  = 
                                if
                                        0  0  a25
                                else
                                        a28  1+  0  a25
                                then         
                        then                 
                dup  8  =  if 
                        a27  1-  6 
                        a28  curr_pos  a25      50  ms
                        32  a20    50  ms 
                        a28  curr_pos  a25    50  ms       
                        then
                a20
            then   
        again       
;