REM ==================================================================
REM Simple Battery Check
REM --------------------
REM This is a simple program to count the number of minutes that the
REM MC400 has been running on a set of batteries. Leave it running
REM in the background. It will count the minute boundaries that pass.
REM When the machine is switched off the count stops.
REM ==================================================================
REM ------------------------------------------------------------------
REM main:
REM -----
REM The main procedure runs in a continuous loop. Most of the time the
REM process is paused but it wakes up a couple of times a minute to
REM check if a new minute has started. When it detects a minute change
REM it increments the count of minutes on this set of batteries and
REM updates the display.
REM ------------------------------------------------------------------
PROC main:
GLOBAL ver$(20)
LOCAL start&
LOCAL mins&
LOCAL now&
ver$ = "1.02 24-Dec-2004"
mins& = 0
showTime:(mins&)
mins& = 0
start& = getTime&:
WHILE 1
PAUSE 100
now& = getTime&:
IF now&-start& <> 0
mins& = mins& + 1
start& = now&
showTime:(mins&)
ENDIF
ENDWH
ENDP
REM ------------------------------------------------------------------
REM getTime&
REM --------
REM This module gets the current minute. It finds the minute in the
REM current month. This helps prevent inaccuracies that would
REM otherwise occur if the machine was switched off and then back on
REM exactly an hour later.
REM ------------------------------------------------------------------
PROC getTime&:
LOCAL mins&, hours&
hours& = DAY * 24 + HOUR
mins& = hours& * 60 + MINUTE
return mins&
ENDP
REM ------------------------------------------------------------------
REM showTime:
REM ---------
REM Update the display to show the time the machine has been running
REM on the current battery.
REM ------------------------------------------------------------------
PROC showTime:(mins&)
LOCAL hours%, minutes%, minutes$(2)
CLS
PRINT "Battery Check "; ver$
PRINT
hours% = int(mins&/60)
minutes% = mins& - 60 * hours%
minutes$ = NUM$(minutes%,2)
minutes$ = RIGHT$("0" + minutes$, 2)
PRINT "Running for ";
PRINT hours%;
PRINT ":";
PRINT minutes$
ENDP