// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // BV4103 LCD. This device is the same form a software point // of view as the BV4108, the BV103 is a BV4108 with an LCD // already attached. // LCD are slow devixces and so expect to see delays in the // software. This particular library expects the set up to have // an ACK value of 6 and the configuration slot to be YNNNNNN // if setup is used this will set the device to that // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // REQUIRED: // #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" // #URL-lib "http://pin1.org/forthlib/flb/IASI/IASI-L-a.flb" // // HISTORY: // Feb 2008 - created new library // CONSTANTS: // Integers integer address // holds device address : ack? ( -- t|f ) i-cbuff // clear buffer address i-address cr1 // just send cr i-in 6 = ; // This is a helper for setting up the diplay to have its own // address. The address should be a number from 1 to 99. Baud // should be a number between 0 and 5, 0=9600 : setup { addr baud -- } i-zf // factory reset cr ." The display now needs to be reset by power cycling (off and on)" cr ." press any key when done" key drop cr ." Wait.." i-det 214 <> abort" There is a problem: device not set, try again" s" ZK6" stype1 cr1 200 ms i-cbuff // ack to 6 s" ZA" stype1 addr <# # # #> stype1 cr1 30 ms i-cbuff // set address s" ZB" stype1 baud iu. cr1 600 ms i-cbuff // set baud rate s" ZC6 -w ynnnnnn" stype1 cr1 1000 ms // set config, slot 6 i-det dup . 214 <> abort" Cant reset after changing config" s" ZC6 -r " stype1 cr1 // fix it addr => address ack? if cr ." set up sucess" else cr ." possible problem with set up" cr ." recycle power and see if ACK? returns -1" then ; // ------- Basic commands ----------------- // send cr1 and wait for ack, add an extra potential dealy because LCD's // are slow devices : wfa ( -- ) cr1 // send terminator -1 // for error 50 for i-in 6 = if drop 0 leave then next abort" error" ; // sends address if set up, otherwise reports : ad ( -- ) address dup 0= abort" Address has not been setup" i-address ; // send colon adress first // ---- Basic commands : ba ( ascii -- ) ad s" BA" stype1 iu. wfa ; // send ascii : bli ( 0|1 -- ) ad s" BL" stype1 iu. wfa ; // back light : bm ( command -- ) ad s" BM" stype1 iu. wfa ; // send command : bn ( #l -- ) ad s" BN" stype1 iu. wfa ; // number of lines : bp ( v -- ) ad s" BP" stype1 iu. wfa ; // move cursor : br ( #c -- ) ad s" BR" stype1 iu. wfa ; // number of characters : bt ( string -- ) ad s" BT " stype1 34 emit1 stype1 34 emit1 wfa ; // string : bx ( v -- ) ad s" BX" stype1 iu. wfa ; // contarst // : dh ( -- ) ad s" DH" stype1 wfa ; // home and clear : dl ( v -- ) ad s" DL" stype1 iu. wfa ; // shift left : dr ( v -- ) ad s" DR" stype1 iu. wfa ; // shift right // // ----- Derived commands : c-off &0c bm ; // cursor off : c-blk &0d bm ; // block type cursor : c-nrm &0e bm ; // normal type cursor // // Prints numer : pnum ( num -- ) ad s" BT" stype1 34 emit1 <# #s #> stype1 34 emit1 wfa ; // prints number : pnum2 ( num -- ) ad s" BT" stype1 34 emit1 <# # # #> stype1 34 emit1 wfa ; // 2 places : pnum4 ( num -- ) ad s" BT" stype1 34 emit1 <# # # # # #> stype1 34 emit1 wfa ; // 4 places