; macros for OI OPTREX LCD control
;-------------------------------------------------------
lcdClear macro
;       this macro clears the LCD display
        movlw 0x01
        call lcdCmd
        endm
;-------------------------------------------------------
lcdLine1 macro
;       this macro moves the csr to 1st line
        movlw 0x80
        call lcdCmd
        movlw 1
        movwf LCDLINE
        endm
;-------------------------------------------------------
lcdLine2 macro
;       this macro moves the csr to 2nd line
        movlw 0xC0
        call lcdCmd
        movlw 2
        movwf LCDLINE
        endm
;-------------------------------------------------------
lcdLine3 macro
;       this macro moves the csr to 3rd line
        movlw 0x94
        call lcdCmd
        movlw 3
        movwf LCDLINE
        endm
;-------------------------------------------------------
lcdLine4 macro
;       this macro moves the csr to 4th line
        movlw 0xD4
        call lcdCmd
        movlw 4
        movwf LCDLINE
        endm
;-------------------------------------------------------
lcdmsg macro msgtblname
;       displays a null-terminated message on the LCD module
;       message is contained in retlw-type table function msgtblname
;       based on code in microchip handbook app note AN587 p. 3-49

        local lm0,lm1,lmnotnewline
        movlw HIGH msgtblname
        movwf PCLATH
        movlw 0
lm0
        movwf LCDTMP    ; contains offset into message
        call msgtblname ; refers to a retlw-type routine w/ text to display
        andlw 0xFF
        btfsc STATUS,Z
        goto lm1

        sublw '\n'      ; check for newline char
        btfss STATUS,Z
        goto lmnotnewline
        call lcdNewline         ; it's a newline char
        movfw LCDTMP
        addlw 1
        goto lm0
lmnotnewline
        movfw LCDTMP
        call msgtblname         ; re-fetch message char (not very efficient)
        call lcdWrite
        movfw LCDTMP
        addlw 1
        goto lm0
lm1
        endm
;-------------------------------------------------------
