It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

Create this code without a loop

Moderator: dafunkymunky

Create this code without a loop

Postby santon on Tue Oct 21, 2008 9:25 pm

Dear all,

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()
santon
 
Posts: 0
Joined: Tue Oct 21, 2008 9:15 pm
Location: Netherlands

Who is online

Users browsing this forum: No registered users and 4 guests