AN1950
Sensors
Freescale Semiconductor 13
jsr lcdchro ;display "cm" for centimeters
bra goflow
dsplIN: lda #'i'
jsr lcdchro
lda #'n'
jsr lcdchro ;display "in" for inches
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
goflow: lda #$C0 ;******** now let's display the flow in decimal ********
jsr lcdcmdo ;position cursor on 1st character 2nd line
lda MA ;get flow
lsla ;test sign of rate (in MA)
bcc positiv ;if positive, then it's easy
lda MA ;otherwise 1's complement of MB
coma
inca
sta MA
cmp #$64 ;check to see if >100
bcs not2lo ;if not we are OK
lda #'<' ;otherwise display that we exceeded min rate
jsr lcdchro ;that LCD can display (<9.9)
lda #$63 ;force value to 99
sta MA
bra goconv
not2lo: lda #'-'
jsr lcdchro ;display that minus sign
bra goconv
positiv: lda MA
cmp #$64 ;check to see if >100
bcs not2hi ;if not we are OK
lda #'>' ;otherwise display that we exceeded max rate
jsr lcdchro ;that LCD can display (>9.9)
lda #$63 ;force value to 99
sta MA
bra goconv
not2hi: lda #'+'
jsr lcdchro ;display the plus sign (to keep alignment)
goconv: lda MA ;get flow
clrh
ldx #$0A ;and divide by 10
div
jsr lcdnibo ;display "tens" digit
lda #'.'
jsr lcdchro ;display decimal point
pshh
pula
jsr lcdnibo ;and first decimal
lda UnitType ;check for cm ($A0) vs. in (#3F)
cmp #$3F
beq dsplINf
dsplCMf: lda #'c'
jsr lcdchro
lda #'m'
bra reusef