Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 13
PAUSE 500 ' let the LCD settle
LCDCMD LCDpin,%00110000 : PAUSE 5 ' 8 -bit mode
LCDCMD LCDpin,%00110000 : PAUSE 0
LCDCMD LCDpin,%00110000 : PAUSE 0
LCDCMD LCDpin,%00100000 : PAUSE 0 ' 4-bit mode
LCDCMD LCDpin,%00101000 : PAUSE 0 ' 2 -line mode
LCDCMD LCDpin,%00001100 : PAUSE 0 ' no crsr, no blink
LCDCMD LCDpin,%00000110 ' inc crsr, no disp shift
cNum = OdoChar
addr = 0
GOSUB Update_CC ' put "0" into custom character
' -----[ Main Code ]------------------------------------------------------------
'
Main:
LCDOUT LCDpin,ClrLCD,["ROLLER COUNTER"]
LCDOUT LCDpin,Line2, [" 0",OdoChar," 0.00"]
PAUSE 1000
Show_Counters:
FOR counter = 0 TO 999
FOR hundreds = 0 TO 99
temp = counter ' display odometer version
width = 3
pos = Line2 + 1
GOSUB RJ_Print
addr = hundreds
GOSUB Update_CC ' update rolling character
pos = Line2 + 10 ' display digital version
GOSUB RJ_Print
LCDOUT LCDpin,NoCmd,[".",DEC2 hundreds]
PAUSE 100
NEXT
NEXT
GOTO Main
END
' -----[ Subroutines ]----------------------------------------------------------
'
Update_CC: ' update custom character
LCDCMD LCDpin,(CGRam + (cNum * CLines)) ' point to character map
FOR idx = 0 TO (CLines - 1)
READ Ma (addr + idx // 100),char
LCDOUT LCDpin,NoCmd,[char] ' write to LCD CGRAM
NEXT
RETURN
RJ_Print: ' right justified printing
digits = width
LOOKDOWN temp,<[0,10,100,1000,65535],digits
LCDOUT LCDpin,pos,[REP " "\(width-digits),DEC temp]
RETURN