Have not tried slower serial/i2d lcds
Code: Select all
'' I'm coding a serial lcd for 115200 baud [checking busy bit] and needed a test program, I created the
'' following program in Liberty Basic 4.5.1 pro, which completes in 43+ seconds..
'' This tests a 20 x 4 Serial LCD @ 115200 baud
'' I tried LBB before and after compiling, which in 73+ seconds, I suspect the
'' serial handling , but not sure ....why slower
nomainwin
com = 512 '' LB runs test in 43+ seconds '' LBB runs test in 73++
pn=12
''open "com";str$(pn);":115200,n,8,1" for random as #serial
open "COM12: baud=115200 parity=n data=8 stop=1" for random as #serial
'' open "COMn: [115200] [n] [8] [1]" for random as #serial '' not work
'' LBB Com OPEN
'' open "com12:115200,n,8,1 " for random as #serial
'' Cannot get any to work
'' open "com12:115200,n,8,1, [odsr=on] [octs=off] [rts=off]" for random as #serial
'' open "COMn: baud=115200, parity=n, data=8, stop=1" for random as #serial
'' open "COMn: [baud=115200] [parity=n] [data=8] [stop=1]
'' [odsr=on] [octs=off] [rts=off] " for random as #serial
'' LB Com OPEN requires the following for this pgm and comm adapter
'' open "com12:115200,n,8,1,ds0,cs0,rs" for random as #serial
'' q is a crap return var
q= LcdClearLine(1) ' clear line 1
q= LcdClearLine(2) ' clear line 2
q= LcdSetBackLight(0) ' 0xB3 @ 0% set back light -- works
q= DelayMS(1000)
FOR ZIP = 5 to 100 step 5
q= LcdSetCursor(10,1) ' set cur 128[Line1] + 10
q= LcdSendBytes(ZIP)
q= LcdSendStr(" ")
q= LcdSetBackLight(ZIP) ' 0xB3 @ x% set back light -- works
q= DelayMS(500)
next ZIP
FOR ZIP = 100 to 0 step -5
q= LcdSetCursor(10,2) ' set cur 192[Line2] + 10
q= LcdSendBytes(ZIP) ' print #serial, ZIP;" "
q= LcdSendStr(" ")
q= LcdSetBackLight(ZIP) ' 0xB3 @ x% set back light -- works
q= DelayMS(300)
next ZIP
q= DelayMS(1000)
q= LcdSetBackLight(75) ' 0xB3 @ 75% set back light -- works
q= DelayMS(500)
q= Beepx()
first = time$("milliseconds")
FOR ZIP = 500 TO 0 step -5
NN = ZIP-425 ' create variable delay
if NN >0 then
NN = NN * 4
else
NN=0
end if
q= LcdClearDisplay() ' 0xB1 clear display ???????? B1=177
q= DelayMS(NN)
q= LcdSetCursor(0,1) ' L=1 P=0 print #serial, chr$(128)
q= LcdSendStr("ABCDEFGHIJKLMNOPQRST") ' Line1 Data
q= LcdSetCursor(0,2) ' L=2 P=0 print #serial, chr$(192)
q= LcdSendStr("ABCDEFGHIJKLMNOPQRST") ' Line2 Data
q= LcdSetCursor(0,3) ' L=3 P=0 print #serial, chr$(148)
q= LcdSendStr("ABCDEFGHIJKLMNOPQRST") ' Line3 Data
q= LcdSetCursor(0,4) ' L=4 P=0 print #serial, chr$(212)
q= LcdSendStr("ABCDEFGHIJKLMNOPQRST") ' Line4 Data
q= DelayMS(NN)
q= LcdClearDisplay() ' 0xB1 clear display ?????????? B1=177
q= DelayMS(NN)
q= LcdSetCursor(0,1)
q= LcdSendStr("01234567890123456789") ' Line1 Data
q= LcdSetCursor(0,2)
q= LcdSendStr("01234567890123456789") ' Line2 Data
q= LcdSetCursor(0,3)
q= LcdSendStr("01234567890123456789") ' Line3 Data
q= LcdSetCursor(0,4)
q= LcdSendStr("01234567890123456789") ' Line4 Data
q= DelayMS(NN)
q= LcdClearLine(1)
q= LcdSendStr("11111111111111111111") ' Line1 Data
q= DelayMS(NN)
q= LcdClearLine(2)
q= LcdSendStr("22222222222222222222") ' Line2 Data
q= DelayMS(NN)
q= LcdClearLine(3)
q= LcdSendStr("33333333333333333333") ' Line3 Data
q= DelayMS(NN)
q= LcdClearLine(4)
q= LcdSendStr("44444444444444444444") ' Line4 Data
q= DelayMS(NN)
q= LcdClearLine(1) ' B9 clr line 1
q= LcdSetCursor(19,1) ' 128 + 19 = 147 => x80 + x13 = x93
q= LcdSendStr("W")
q= LcdSetCursor(0,1)
q= LcdSendStr("Line-1 ")
q= DelayMS(NN)
q= LcdClearLine(2)
q= LcdSetCursor(19,2) ' 192 + 19 = 211 => x80 +x64 +x13 = D3
q= LcdSendStr("X")
q= LcdSetCursor(0,2) ' 192 - C0
q= LcdSendStr("Line-2 ")
q= DelayMS(NN)
q= LcdClearLine(3) ' BB clr line 3
q= LcdSetCursor(19,3) ' 148 + 19 = 167 => x94 + x13 = xA7
q= LcdSendStr("Y")
q= LcdSetCursor(0,3) ' 148 => x94
q= LcdSendStr("Line-3 ")
q= DelayMS(NN)
q= LcdClearLine(4) ' 188 => xBC clr line 4
q= LcdSetCursor(19,4) ' 212 + 19 = 231 => xD4 + x13 = xE7
q= LcdSendStr("Z")
q= LcdSetCursor(0,4) ' 212 = xD4
q= LcdSendStr("Line-4 ") ' display Line-4
q= LcdSetCursor(8,4) ' 212 + 8 = 220 => xd4 + 8 = xDC
q= LcdSendBytes(ZIP) ' display the count
q= DelayMS(NN)
next ZIP
last = time$("milliseconds") ' get last time
total = int(last-first) ' compute elapsed MS
q= LcdSetCursor(8,3) ' set curspr @ Line3 Total ms
q= LcdSendBytes(total) ' print elapsed MS
q= LcdSendStr("-ms") '
close #serial
end
'=========================================================================================
' q= DelayMS(xxx) Delay xxx milliseconds -- not ideal but works
'-----------------------------------------------------------------------------------------
function DelayMS(value)
td = time$("milliseconds") + value
do
loop until time$("milliseconds") >= td
end function
'-----------------------------------------------------------------------------------------
function LcdSetCursor(Position,LineX)
select case LineX
case 1
Cpos = 128 ' 128 x80
case 2
Cpos = 192 ' 192 xC0
case 3
Cpos = 148 ' 148 x94
case 4
Cpos = 212 ' 212 xD4
end select
print #serial, chr$(Cpos + Position)
end function
'===========================================================================================
function LcdSendBytes(zip)
PRINT #serial,str$(zip)
end function
'-------------------------------------------------------------------------------------------
function LcdSendStr(X$)
print #serial, X$
end function
'-------------------------------------------------------------------------------------------
function LcdClearLine(LineX)
PRINT #serial,chr$(LineX + 184)
end function
'-------------------------------------------------------------------------------------------
function LcdClr()
PRINT #serial,chr$(1)
end function
'-------------------------------------------------------------------------------------------
function LcdClearDisplay()
PRINT #serial,chr$(177)
end function
'-------------------------------------------------------------------------------------------
function LcdSetBackLight(percent) ' percent max is 100
print #serial, chr$(179);chr$(percent)
end function
'-------------------------------------------------------------------------------------------
function Beepx()
print #serial,chr$(7)
end function
'----------