Parallax, Inc. • BS2p “Plus Pack” (#45184) • 10/2001
Page 48
pos = Line2 + 10
rjNum = tempC
IF (TempType = TC) THEN Print_Temp
rjNum = tempF
Print_Temp:
GOSUB RJ_Print
LCDOUT LCDpin,NoCmd,[DegSym,TempType * ("F" - "C") + "C"]
Next_Sensor:
sensor = 1 // NumSensors
PAUSE 5000
GOTO Show_Sensors
END
' -----[ Subroutines ]----------------------------------------------------------
'
Get_Temp:
FOR idx = 0 TO 7 ' load ROM pattern
READ (idx),romData(idx)
NEXT
OWOUT OWpin,OW_FERst,[MatchROM,STR romData\8,CnvrtTemp]
PAUSE 500
OWOUT OWpin,OW_FERst,[MatchROM,STR romData\8,RdScratch]
OWIN OWpin,OW_BERst,[tInLow,tInHigh]
tSign = sign ' save sign bit
tempC = tempIn
tempC = tempC >> 4 ' round to whole degrees
IF (tSign = 0) THEN NoNeg1
tempC = tempC | $FF00 ' extend sign bits for negs
NoNeg1:
tempF = tempC */ $01CD ' multiply by 1.8
IF (tSign = 0) THEN NoNeg2 ' if neg, extend sign bits
tempF = tempF | $FF00
NoNeg2:
tempF = tempF + 32 ' finish C -> F conversion
RETURN
Print_Label:
READ eeAddr,char ' get a character
IF (char = 0) THEN Print_Done ' if 0, exit
LCDOUT LCDpin,NoCmd,[char] ' send to LCD
eeAddr = 1 ' move to next char address
GOTO Print_Label
Print_Done:
RETURN
RJ_Print:
rjSign = rjNum.Bit15 ' save sign
rjNum = ABS(rjNum) ' convert to positive
digits = width
LOOKDOWN rjNum,<[0,10,100,1000,65535],digits
LCDOUT LCDpin,pos,[REP " "\(width-digits-1),13 * " ",DEC rjNum]
RETURN