Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 47
tempIn VAR Word ' raw temperature
sign VAR tempIn.Bit11 ' 1 = negative temperature
tInLow VAR tempIn.LowByte
tInHigh VAR tempIn.HighByte
tSign VAR Bit
tempC VAR Word ' Celsius
tempF VAR Word ' Fahrenheit
char VAR Byte ' character for LCD
rjNum VAR tempIn ' right justified number
rjSign VAR Bit ' sign for rj number
pos VAR Byte ' position to print
digits VAR Nib ' digits in rjNum
width VAR Nib ' width of display
' -----[ EEPROM Data ]----------------------------------------------------------
'
' ROM codes for connected sensors
' -- these values MUST be edited for your sensors
T_ID0 DATA $22,$30,$34,$01,$00,$00,$00,$6C
T_ID1 DATA $22,$85,$42,$01,$00,$00,$00,$71
' labels for temperature sensors
T_Label0 DATA "INSIDE ",0
T_Label1 DATA "OUTSIDE ",0
' -----[ Initialization ]-------------------------------------------------------
'
Initialize:
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
' -----[ Main Code ]------------------------------------------------------------
'
Main:
LCDOUT LCDpin,ClrLCD,[" DS1822"] ' splash screen
LCDOUT LCDpin,Line2, [" Thermometer"]
PAUSE 2000
LCDCMD LCDpin,ClrLCD
Show_Sensors:
LOOKUP sensor,[T_ID0,T_ID1],eeAddr ' point to ROM code
GOSUB Get_Temp ' get temperature
LOOKUP sensor,[T_Label0,T_Label1],eeAddr ' display sensor label
LCDCMD LCDpin, Line1
GOSUB Print_Label
width = 4