// LCD display module for IASI, BV4108 etc. // // Needs the asi.bas library utilities to work. // To do this load "asi.bas", using tload and then type fsave all, this // will save those utilities to flash. // // ******************************************************************* // Initailisation, run first, this will also return the LCD address // for use in all other functions. Example of use // adr$=asi_lcd_init$(38400) // ******************************************************************* function asi_lcd_init$(baud) dim rv$[:6] // check to see if asi.bas is loaded by looking for "asi_find$" if fexists("asi_find$") = 0 then print "Need to load asi.bas and save to Flash, first" exitf endif rv$=asi_find$(baud) if len(rv$) <> 0 then // strip '>' not needed for address rv$=chr$(asc(rv$,1)) else print "Device not found" endif result rv$ endf // ******************************************************************* // clears display // ******************************************************************* function asi_lcd_clr(addr$) dim t$[:6] t$=asi_write$(addr$+"c1") if t$<>">" then print "error writig to LCD" endif endf // ******************************************************************* // turns on/off back light // use: asi_lcd_bl(1) // turns on BL // ******************************************************************* function asi_lcd_bl(addr$,on) if on=1 then asi_write$(addr$+"b1") else asi_write$(addr$+"b0") endif endf // ******************************************************************* // moves cursor to a particular point on the display, works with // up to 4 lines and assuems the standard constants. pos is the // position along the line starting at 0 // line 1-4, pos 0-? (depends on display, 16, 20 or 40) // example // isa_lcdLine("a",2,5) // move cursor to 2nd line, 6th postion // ******************************************************************* // Change these for your particular display constant line1 0x80 constant line2 0xc0 constant line3 0x94 constant line4 0xd4 // function asi_lcd_line(addr$,line, pos) dim d, t$[:6] select line case 1 d=line1+pos case 2 d=line2+pos case 3 d=line3+pos case 4 d=line4+pos default print "what? max of 4 lines, line=";line endselect // 'c' is the command write, see BV4108 datasheet t$=asi_write$(addr$+"c"+hex$(d)) if t$<>">" then print "error writig to LCD" endif endf // ******************************************************************* // sends a string to the display at the current cursor position // ******************************************************************* function asi_lcd_string(addr$,s$) // uses the t'data' command, could also use // the 'd' command asi_write$(addr$+"t"+*39+s$+*39) endf // ===================== TEST // use an a 4 line display, writes numbers to all for corners function xx dim addr$, j addr$ = asi_lcd_init$(38400) asi_lcd_clr(addr$) asi_lcd_line("a",2,4) asi_lcd_string(addr$,"Hello World") for j = 1 to 100 asi_lcd_line(addr$,1,0) asi_lcd_string(addr$,j) asi_lcd_line(addr$,1,17) asi_lcd_string(addr$,j) asi_lcd_line(addr$,4,0) asi_lcd_string(addr$,j) asi_lcd_line(addr$,4,17) asi_lcd_string(addr$,j) next endf