Pb2
Listing index
Pb4
Routine:        Pb3     
Function:       Program B3: Timed measurements
Called by:      Main, Pb4
Calls:          Alarm, Alm2, Equals, Keyb, Meas, Print, Vischk.
Entry:          None
Exit:           None
Preserved:      None


PB3     CALL    ALM2
; Set the next alarm time.
        LD      HL,LOG
        LD      (LOGCUR),HL
; Initialise the result pointers to the start of the result area, and set measurement number zero.
        LD      HL,0
        LD      (LOGN),HL
        LD      IX,CLKFLG
        SET     7,IX
; Display the clock, and jump to the first measurement.
        JR      PB3D
PB3A    CALL    KEYB
; Ckeck the keyboard; if ´B' pressed, display the time, if 'A' pressed, display the last viscosity measured.
        LD      IX,CLKFLG
        CP      11
        JR      NZ,PB3B
        SET     7,(IX)
        JR      PB3C
PB3B    CP      10
        JR      NZ,PB3C
        RES     7,(IX)
        LD      HL,VISCTY
; Display last viscosity.
        CALL    PRINT
PB3C    CALL    ALARM
; Check to see if alarm period has expired yet. If so, take a reading.
        JR      NZ,PB3A
PB3D    LD      HL,VISCTY
        CALL    MEAS
; Measure and print the viscosity, and store it at the current result location.
        CALL    PRINT
        LD      DE,(LOGCUR)
        CALL    EQUALS
        LD      HL,(LOGCUR)
; Increment the result pointer.
        INC     HL
        INC     HL
        INC     HL
        INC     HL
        INC     HL
        LD      (LOGCUR),HL
        LD      BC,(LOGNMX)
        LD      DE,(LOGN)
        INC     DE
        LD      (LOGN),DE
; Increment the result number, and check that it does not equal the number of results requested by the user.
        LD      A,C
        CP      E
        JR      NZ,PB3E
        LD      A,B
        CP      D
; Return if all measurements are done.
        RET     Z
PB3E    CALL    VISCHK
; Check that the viscosity is within the user defined range, and return if not.
        JR      Z,PB3A
        RET
 
Pb2
Listing index
Pb4