Newzed
02-11-2007, 03:02 AM
This post will read better if you expand the screen.
I have a menu-driven program that, among other things, returns the temperture from 3 locations if I press "N".· I wanted to introduce a delay so that if no menu option was selected within 5 minutes, the program would automatically execute the "N" routine.· I wrote the following:
---------------------------------------------------------------------
PRI getChoice : selectedOption
· repeat
··· rxtime(2)
···· if rxtime(25000) == 0
······ senddata("Q")··· '"N" routine
······ waitcnt(clkfreq/10 + cnt)····
······ senddata("Q")
······ recdata
······ start
··· repeat until selectedOption := key.key··
··· if (selectedOption => "a") and (selectedOption =< "z"")························
····· selectedOption -= 32··· '32 = ("a" - "A")·
···· ' Convert letters to··uppercase·····························
· until (lookdown (selectedOption : "TGNRS"))
PUB rxtime(ms) : rxbyte | t
'' Wait ms milliseconds for a byte to be received
'' returns·0 if no byte received, $00..$FF if byte
· t := cnt
· repeat until (rxbyte := key.key) or (cnt - t) / (clkfreq / 1000) > ms
---------------------------------------------------------------------------
With the above, the program waits for about 25 seconds.· If there is no key press within that time, then it executes the "N" routine.· The program will not execute an rxtime of greater than 25000 because a 32 bit compare is only good for about 50/2 seconds.
Can anyone·modify the above so that I can get a wait period of up to 5 minutes?· If I want to select another menu option during the 25 seconds wait, I can do·so, ·but I have to press the selected key twice.· I can live with that if there is no alternative.
Sid
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)
·
I have a menu-driven program that, among other things, returns the temperture from 3 locations if I press "N".· I wanted to introduce a delay so that if no menu option was selected within 5 minutes, the program would automatically execute the "N" routine.· I wrote the following:
---------------------------------------------------------------------
PRI getChoice : selectedOption
· repeat
··· rxtime(2)
···· if rxtime(25000) == 0
······ senddata("Q")··· '"N" routine
······ waitcnt(clkfreq/10 + cnt)····
······ senddata("Q")
······ recdata
······ start
··· repeat until selectedOption := key.key··
··· if (selectedOption => "a") and (selectedOption =< "z"")························
····· selectedOption -= 32··· '32 = ("a" - "A")·
···· ' Convert letters to··uppercase·····························
· until (lookdown (selectedOption : "TGNRS"))
PUB rxtime(ms) : rxbyte | t
'' Wait ms milliseconds for a byte to be received
'' returns·0 if no byte received, $00..$FF if byte
· t := cnt
· repeat until (rxbyte := key.key) or (cnt - t) / (clkfreq / 1000) > ms
---------------------------------------------------------------------------
With the above, the program waits for about 25 seconds.· If there is no key press within that time, then it executes the "N" routine.· The program will not execute an rxtime of greater than 25000 because a 32 bit compare is only good for about 50/2 seconds.
Can anyone·modify the above so that I can get a wait period of up to 5 minutes?· If I want to select another menu option during the 25 seconds wait, I can do·so, ·but I have to press the selected key twice.· I can live with that if there is no alternative.
Sid
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?
Newzed@aol.com (mailto:Module?Newzed@aol.com)
·