Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 31
' download custom character map to LCD
LCDCMD LCDpin,(CGRam + (2 * 8)) ' write to CGRAM (character 2)
FOR addr = Super2 TO ( 7) ' build custom char
READ addr,temp ' get byte from EEPROM
LCDOUT LCDpin,NoCmd,[temp] ' put into LCD CG RAM
NEXT
' -----[ Main Code ]------------------------------------------------------------
'
Splash:
LCDOUT LCDpin,ClrLCD,[" BS2P <-> I",2,"C"]
LCDOUT LCDpin,Line2, [" Communications"]
PAUSE 2000
Main:
LCDOUT LCDpin,ClrLCD,["I",2,"C: Out="]
LCDOUT LCDpin,(Line2 + 10),["In="]
FOR addr = 0 TO MaxEE STEP 5 ' create addresses
RANDOM rVar ' create "random" value
tOut = rVar.HighByte
' write value then read it back
I2COUT I2Cpin,Wr2432,addrHi \addrLo,[tOut]
PAUSE 100
I2CIN I2Cpin,Rd2432,addrHi\addrLo,[tIn]
' display results
LCDOUT LCDpin,(Line1 + 4),[DEC addr]
temp = tOut : width = 3 : pos = Line1 + 13
GOSUB RJ_Print
temp = tIn : width = 3 : pos = Line2 + 13
GOSUB RJ_Print
PAUSE 250
NEXT
END
' -----[ Subroutines ]----------------------------------------------------------
'
RJ_Print: ' right justified printing
digits = width
LOOKDOWN temp,<[0,10,100,1000,65535],digits
LCDOUT LCDpin,pos,[REP " "\(width-digits),DEC temp]
RETURN