warm: brclr 1,porta,PB1 ;check for SEL
brclr 2,porta,PB2 ;or for ENT
bclr 4,porta
bset 5,porta
jsr del100ms
bset 4,porta
bclr 5,porta
jsr del100ms
bra warm
;otherwise
;turn on "SEL" LED
;delay
;toggle LEDs
;"ENT" now on: means choice is SEL ***or*** ENT
;delay and repeat until SEL or ENT
PB1:
inc RA
lda RA
cmp #$02
bne PB1ok
clr RA
;***SEL*** toggles menu choices
;menu choices are $00 and $01
;back to $00 when all others have been offered
PB1ok: bclr 4,porta
bclr 5,porta
;LEDs off
jsr del100ms
;wait a little bit
brclr 1,porta,PB1ok ;make sure they let go of SEL
bra luke
PB2:
bclr 4,porta
bclr 5,porta
lda RA
;***ENT*** confirms menu choice
;LEDs off
;get menu choice
bne skip00
jmp LEVEL
skip00: jmp UNITS
;do ===LEVEL=== if choice=$01
;do ===UNITS=== if choice=$00
;__________________________________________________________
;__________________________________________________________
CALIB: lda #$01
jsr lcdcmdo
clr ram0
ldhx #msg05
jsr lcdstro
lda N1
;===CALIB=== 2-point calibration
;Calibration current values
;0mm
jsr lcdbyto
lda #'/'
jsr lcdchro
lda N2
;160mm
jsr lcdbyto
bset 4,porta
bset 5,porta
;LEDs on
lego1: brclr 1,porta,lego1
lego2: brclr 2,porta,lego2
bclr 4,porta
bclr 5,porta
jsr del1s
;LEDs off when both SEL & ENT are released
jsr del1s
;wait 2s
ldhx #msg05a
jsr lcdstro
;show instructions
waitPB1: brset 2,porta,no2 ;if ENT is not pressed, skip
jmp nocalib ;if ENT is pressed then cancel calibration
brclr 1,porta,do1st ;if SEL is pressed then do 1st point cal
no2:
bra waitPB1
do1st: ldhx #msg05b
jsr lcdstro
;otherwise wait for SEL or ENT
;1st point cal: show values
clr CNT
;CNT will count 256 A/D readings
clr RB
clr RA
;RB:RA will contain 16-bit add-up of those 256 values
AN1950
Sensors
Freescale Semiconductor
9