validcal: ldhx #N2
jsr wrflash
ldhx #msg05
jsr lcdstro
lda N1
;burn N2 into flash
;and display new current cal values from flash
;0mm value
;160mm value
;done!
jsr lcdbyto
lda #'/'
jsr lcdchro
lda N2
jsr lcdbyto
jsr del1s
jsr del1s
jmp nocalib
;__________________________________________________________
;__________________________________________________________
LEVEL: lda #$01
jsr lcdcmdo
lda #$0C
;===LEVEL=== main routine: displays level, flow & graphics
;clear screen
jsr lcdcmdo
;cursor off
lda #$88
jsr lcdcmdo
clra
;position cursor at LCD graphics portion
;(2nd half of first line)
;and write ascii $00 through $07
;which contain the graphics related to
;40 different readings
fillgfx: jsr lcdchro
inca
cmp #$08
bne fillgfx
;do all 8
LVL:
ldhx #ramfree
lda #$28
;point to 40 pressure readings
;count down from 40
purge: clr 0,x
incx
;clear all those locations
;next (H cannot change: we are in page0 RAM)
dbnza purge
jsr adcbyta
jsr LfNx
;get averaged A/D reading (i.e. NX)
;convert to level and
sta Lgfx
;store in "Level graphics"
LVLwarm: bset 4,porta
bset 5,porta
;LEDs on during this cycle
ldhx #ramfree
mov #$27,RA
shiftgfx: lda 1,x
;point to 40 pressure readings
;count down from 39
;take location+1
sta 0,x
incx
;and move to location+0, i.e. shift graphics left
;next X (once again: we are in page 0, no need to worry about H)
dbnz RA,shiftgfx ;do this 39x
jsr adcbyta
jsr LfNx
mov RA,OA
;get averaged A/D reading (i.e. NX)
;LX:=(NX-N1)*ConversionValue/(N2-N1)
;store result in OA
clr RB
;RB will contain graphic pixels (default=$00)
;if <UnitEmpty (preset value = empty or almost)
;then "empty" (no pixels)
;if >=UnitFull (preset value = full or almost)
;then "full" (pixel $80=bit 7)
cmp UnitEmpt
bcs Lzero
cmp UnitFull
bcc Lsat
clrh
ldx UnitDiv
div
;otherwise determine one of 8 graphic values
;UnitDiv is roughly full range/8
;in order to give 8 values
mov #$01,RB
;but now value has to be converted to pixel
AN1950
Sensors
Freescale Semiconductor
11