To use this file copy and paste this:    // #URL-lib "http://pin1.org/forthlib/flb/IASI/BV4103.fth"   into BV Terminal 3 or here to download.

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 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 is a demonstartion of using the library NOTE: There are // no public words <0> for the BV4103 library so use the same SID // to extend it and provide <0> for your application if required. // 1) use set-lcd ONCE to set up IASI or do this manualy // 2) use go-time // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// HISTORY: // Mar 2008 * replaced [char] : ba with 58 ba, limitation on BVT

// REQUIRES: // #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" sid=98 // #URL-lib "http://pin1.org/forthlib/flb/General/rtc.flb" sid=99 // #URL-lib "http://pin1.org/forthlib/flb/IASI/IASI-L-a.flb" sid=100 // #URL-lib "http://pin1.org/forthlib/flb/IASI/BV4103.flb" sid=100 //

// CONSTANTS:


Full Contents of File

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// 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 is a demonstartion of using the library NOTE: There are
// no public words <0> for the BV4103 library so use the same SID
// to extend it and provide <0> for your application if required.
// 1) use set-lcd ONCE to set up IASI or do this manualy
// 2) use go-time
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// REQUIRES:
// #URL-lib "http://pin1.org/forthlib/flb/General/soft1.flb" sid=98
// #URL-lib "http://pin1.org/forthlib/flb/General/rtc.flb" sid=99
// #URL-lib "http://pin1.org/forthlib/flb/IASI/IASI-L-a.flb" sid=100
// #URL-lib "http://pin1.org/forthlib/flb/IASI/BV4103.flb" sid=100
//

// HISTORY:
// Mar 2008 * replaced [char] : ba with 58 ba, limitation on BVT

// CONSTANTS:

// extend above libraries
// #CurrentSID sid=100
 
// use setup first as required to make the display more friendly to
// CPU use, i.e 1 0 setup will set the display to address 1 baud rate 9600
: set-lcd// only use once, will set address to 1 and baud rate to 9600
    1  0  setup
;   

// This display is 2 lines by 16, address has been prevoiusly set using
// setup to a value of 1
: init
    1  =>  address            // set address variable
    i-cbuff
    2  bn        // lines
    16  br      // characters
;   

// this is different for differnt dsipays
: l264  bp  ;  // sends cursor to line 2

// hello world
: hello
    dh        // clear display
    s"  Hello"  bt    // top line
    l2        // next line
    s"  World"  bt    // botomm line
;
 
// ============ Clock example ============================
// shows the use of tables to display day of week.
// display:
// Mon 23 Sep 2007
// 12:47:22
//
: dayss"  MonTueWedThuFriSatSun"  ;
: monthss"  JanFebMarAprMayJunJulAugSepOctNovDec"  ;

// only send 3 characters to display
: p3 ( string -- )
    3  for
        dup  i  +  c@  ba
    next
    drop
;       
     
// prints out the day at position 0, 0 is Mon
// ( day ---)
: pday
        0  bp        // set cursor
        3  *          // offset into table
        days        // address of string
        +
        p3        // print out
;

// prints month at 7
// ( month [1 to 12] -- )
: pmonth
        7  bp        // cursor
        1-            // because table starts at 0
        3  *  months  +    // address offset
        p3        // print it
;

// -------- e.g Mon 23 Sep 2007 ------------
//
// prints current day
: c-dayrtc.dow  @  pday  ;

// prints current day of month at 4
: c-dom
        4  bp
        rtc.date    // get day of month
        pnum  // print
        2drop  // year and month
;

// prints out current month
: c-mon
    rtc.date  drop  swap  drop  // get month bit
    pmonth
;

// prints out current year to 4 places
: c-year
    11  bp          // move cursor
    rtc.date  2drop        // get year
    pnum4      // print
;

: topline ( -- )   c-day  c-dom  c-mon  c-year  ;  // whole of top line

// ------------ 12:47:22 ---------------------------------

// current hour, assumes second line starts at &c0
: c-hour 
    64  bp      // move cursto
    rtc.time  2drop  pnum2
    58  ba      // the :
;
   
: c-min 
    67  bp      // move cursto
    rtc.time  drop  pnum2
    drop    // hour
    58  ba      // the :
;

: c-sec 
    70  bp      // move cursto
    rtc.time  pnum2
    2drop  // hrs and mins
;

: bottomline ( -- )   c-hour  c-min  c-sec  ;  // bottom line, time

: go-time
    init
    dh
    begin
        topline
        bottomline
        100  ms    // very simple update every 10th of second
        key?
    until
;