This is probably a very newbie question, but I can't figure out how to get about it. I have created the code below to print a time and a temperature to a LCD display. This display can be programmed using Basic++.
I can't find out how to print both the time and a temperature reading in this display beacause both functions are in a loop (one for updating the time and one for updating the temperature) and therefore only the first function is displayed in this LCD.
Anyone who can help? Please advise me on how to do this.
- Code: Select all
'--------------------------
'------ I/O PORTS ---------
'--------------------------
define LIGHT port[16]
'--------------------------
'---- SYSTEM MEMORY -------
'--------------------------
define TEMP as word
define TEMPHI as byte
define TEMPLO as byte
#INIT
LIGHT=on
LCD.INIT
LCD.CLR
LCD.OFF
const DS1631=158 'Adresse
import "DS1631_GENERIC.blib"
'-------- ARBITRARY PRESET -------------
hour=23
minute=59
second=58
day=31
month=12
year=3
'-------------------------------------------------------------
DS1631RESET(DS1631)
DS1631SET_STATUS(DS1631,1)
'--------------------------------------------------------------------
' SHOW TIME
'--------------------------------------------------------------------
FUNCTION TIJD()
#TIJDLOOP
LCD.INIT SWITCHONLY
LCD.POS 1,5
if HOUR<10 then LCD.PRINT "0" 'LEADING ZERO
LCD.PRINT HOUR 'HOURS
LCD.PRINT ":" 'SEPARATOR
if MINUTE<10 then LCD.PRINT "0" 'LEADING ZERO
LCD.PRINT MINUTE
LCD.PRINT ":" 'SEPARATOR
if SECOND<10 then LCD.PRINT "0" 'LEADING ZERO
LCD.PRINT SECOND
LCD.PRINT " "
LCD.OFF
goto TIJDLOOP
END FUNCTION
'-------------------------------------------------------------
'----- LOOP READING TEMPERATURE ---
'-------------------------------------------------------------
FUNCTION SHOW_TEMP()
#LOOP
pause 5
DS1631CONVERT(DS1631)
DS1631WAIT_READY(DS1631)
TEMP=DS1631GET_TEMP(DS1631)
LCD.INIT switchonly
LCD.POS 2,1
TEMP=TEMP SHR 7
if (TEMP and 0100h) = 0100h then TEMP=(TEMP or FE00h)
LCD.PRINT "TEMP: " & TEMP/2 & "." & (TEMP and 1)*5 & " C "
LCD.OFF
goto LOOP
END FUNCTION
TIJD()
SHOW_TEMP()


