;***************************************
;**************按键扫描管理*************
key_scan_man:
mov a,keydwn_t
sub a,251
snz c
inc keydwn_t ;按键扫描计数:1~251
clr out0 ;先扫描第1行(低电平有效)
set out1
set out2
set out3
nop ;延时(必须要,当8MHZ时)
nop
nop
nop
nop
snz input0
jmp scan_key1 ;数字键1按下
snz input1
jmp scan_key2 ;数字键2按下
snz input2
jmp scan_key3 ;数字键3按下
set out0 ;再扫描第2行
set out1
set out2
clr out3
nop
nop
nop
nop
nop
snz input0
jmp scan_key4 ;数字键4按下
snz input1
jmp scan_key5 ;数字键5按下
snz input2
jmp scan_key6 ;数字键6按下
set out0 ;然后扫描第3行
clr out1
set out2
set out3
nop
nop
nop
nop
nop
snz input0
jmp scan_key7 ;数字键7按下
snz input1
jmp scan_key8 ;数字键8按下
snz input2
jmp scan_key9 ;数字键9按下
set out0 ;最后扫描第4行
set out1
clr out2
set out3
nop
nop
nop
nop
nop
snz input0
jmp scan_delete ;delete(reset)键按下
snz input1
jmp scan_key0 ;数字键0按下
snz input2
jmp scan_enter ;enter(lock)键按下
clr keydwn_t ;都没有按键按下,则清按键次数变量
ret
scan_enter:
mov a,keydwn_t
sub a,10 ;2ms*10=20ms?
sz z
set enter_key ;置#键按下标志位为1
ret
clr sw_bz |