⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 key_display.l

📁 使用三星芯片的控制程序,可供三星8位MCU初学者参考!
💻 L
📖 第 1 页 / 共 3 页
字号:
  197  0B74   E6 04 00           ld  key_first_flag,#00H         ;no key clear key_first_flag
  198  0B77   E6 03 00           ld  key_press_time,#00H         ;no key clear key_press_time
  199  0B7A   E6 0A 00           ld  key_press_down,#00H         ;no key press down
  200  0B7D   E6 05 00           ld  key_hold_down,#00H          ;first press or already press
  201  0B80   E6 08 00           ld  key_delay_time1,#00H
  202  0B83   E6 09 00           ld  key_delay_time2,#00H
  203  0B86   E6 0C 00           ld  key_release,#00H            ;key realease
  204  0B89   8D 0C 46           jp  key_scan_end
  205                          
  206  0B8C              key_operation:
  207  0B8C   A6 04 01           cp  key_first_flag,#01H         ;if already press 
  208  0B8F   6B 09              jr  eq,key_delay_time           ;yes,to test delay time
  209  0B91   E6 04 01           ld  key_first_flag,#01H         ;no,to dalay time 
  210  0B94   E6 03 00           ld  key_press_time,#00H         ;clear key_press_time,again scan
  211  0B97   8D 0C 46           jp  key_scan_end
  212                    
  213  0B9A              key_delay_time:
  214  0B9A   A6 03 C8           cp  key_press_time,#200         ;delay 200*120us=24ms 120us use T0 count
  215  0B9D   FB 03              jr  uge,key_already_press
  216  0B9F   8D 0C 46           jp  key_scan_end
  217                            
  218  0BA2              key_already_press: 
  219  0BA2   76 1B 01           tm  led_display_flag,#01H
  220  0BA5   6B 24              jr  eq,key_relea
  221  0BA7   E6 1B 01           ld  led_display_flag,#01H
  222  0BAA   F6 0B D3           call key_validate
  223  0BAD   76 06 01           tm key_value,#01H               ;if key_value=fire+ not set key_release
  224  0BB0   6D 0C 46           jp eq,key_scan_end
  225  0BB3   76 06 02           tm key_value,#02H               ;if key_value=fire- not set key_release
  226  0BB6   6D 0C 46           jp eq,key_scan_end
  227  0BB9   76 06 06           tm key_value,#06H               ;if key_value=temp+ not set key_release
  228  0BBC   6D 0C 46           jp eq,key_scan_end
  229  0BBF   76 06 07           tm key_value,#07H               ;if key_value=temp- not set key_release
  230  0BC2   6D 0C 46           jp eq,key_scan_end
  231  0BC5   E6 0C 01           ld key_release,#01H             ;other key set key_release
  232  0BC8   8D 0C 46           jp key_scan_end
  233                                 
  234  0BCB              key_relea:
  235  0BCB   76 0B 00           tm  key_realease_flag,#00H
  236  0BCE   6B 20              jr  eq,key_value_judge
  237  0BD0   8D 0C 46           jp   key_scan_end
  238                    
  239                    
  240                    ;************************************************************
  241  0BD3              key_validate:
  242  0BD3   E6 00 FE           ld   serial_data,#0feH
  243  0BD6   0C 01              ld   r0,#01
  244  0BD8              key_scan_loop:        
  245  0BD8   F6 0D 95           call  serial_out                ;serial out 1111 1110B
  246  0BDB   38 E0              ld   r3,p0
  247  0BDD   76 C3 01           tm   r3,#01H                     ;test P0.0=0 ?
  248                            
  249  0BE0   6B 0B              jr   z, key_validate_end       ;if P0.0=0 to key_operation
  250  0BE2   0E                 inc  r0                         ;key_value add 1
  251  0BE3   90 00              rl   serial_data                ;1<-serial_data  scan again
  252  0BE5   A6 C0 08           cp   r0,#08                     ;key value<8  jump loop
  253  0BE8   FB EE              jr   uge,key_scan_loop
  254  0BEA   8D 0C 46           jp   key_scan_end               ;can not test key ,exit
  255                            
  256  0BED              key_validate_end:
  257  0BED   09 06              ld key_value,r0                 ;save key_value
  258  0BEF   AF                 ret
  259                    ;***************************************************************
  260                    
  261                    
  262  0BF0              key_value_judge:
  263  0BF0   F6 0B D3           call key_validate
  264                    
  265                    
  266  0BF3              key_hold_done:      
  267  0BF3   A6 05 01           cp key_hold_down,#01H           ;if key hold press down
  268  0BF6   6B 0E              jr eq,key_value_cp              ;yes ,to cp key_value 
  269  0BF8   E6 05 01           ld key_hold_down,#01H           ;no ,set key_hold_down flag              
  270  0BFB   E4 06 07           ld key_value_store,key_value    ;backup key_value   
  271  0BFE   E6 08 00           ld key_delay_time1,#00H         ;hold_time start 
  272  0C01   E6 09 00           ld key_delay_time2,#00H    
  273  0C04   8B 10              jr key_deal
  274                            
  275  0C06              key_value_cp:
  276  0C06   A4 06 07           cp key_value_store,key_value    ;key_value eq previous key_value
  277  0C09   6B 03              jr eq,key_hold_sub              ;eq ,to key_hold_sub judge delay time 
  278  0C0B   8D 0C 46           jp key_scan_end                 ;ne,it is other key ,exit
  279                    
  280  0C0E              key_hold_sub:
  281  0C0E   A6 09 0F           cp key_delay_time2,#15           ;delay time =102*200*15=0.36s ?
  282  0C11   BB 03              jr ugt,key_deal                  ;time up ,to key_deal
  283  0C13   8D 0C 46           jp key_scan_end                  ;no,exit
  284                            
  285  0C16              key_deal:
  286  0C16   A6 06 01           cp key_value,#01H
  287  0C19   6D 0C 47           jp eq,key_1_sub                 ;temp+
  288                                              
  289  0C1C   A6 06 02           cp key_value,#02H
  290  0C1F   6D 0C 65           jp eq,key_2_sub                 ;temp-
  291                                              
  292  0C22   A6 06 03           cp key_value,#03H
  293  0C25   6D 0C 83           jp eq,key_3_sub                 ;temp on-off   
  294                                              
  295  0C28   A6 06 04           cp key_value,#04H
  296  0C2B   6D 0C 91           jp eq,key_4_sub                 ;lamp on-off   
  297                                              
  298  0C2E   A6 06 05           cp key_value,#05H
  299  0C31   6D 0C AA           jp eq,key_5_sub                 ;fire+   
  300                                              
  301  0C34   A6 06 06           cp key_value,#06H
  302  0C37   6D 0C C8           jp eq,key_6_sub                 ;fire-   
  303                                              
  304  0C3A   A6 06 07           cp key_value,#07H
  305  0C3D   6D 0C E6           jp eq,key_7_sub                 ;fire on-off  
  306                                              
  307  0C40   A6 06 08           cp key_value,#08H
  308  0C43   6D 0D 24           jp eq,key_8_sub                 ;sound    
  309                            
  310  0C46              key_scan_end:
  311  0C46   AF                 ret
  312                    ;***************************************************************
  313                    
  314                    ;*************************************************************** 
  315  0C47              key_1_sub:
  316  0C47   76 11 01           tm temp_status,#01H
  317  0C4A   EB 18              jr ne,key_1_sub_end             ;temp off ,exit        
  318  0C4C   20 15              inc temp_value                  ;temp+
  319  0C4E   A6 15 01           cp  temp_value,#01H
  320  0C51   7B 07              jr  ult,temp_min
  321  0C53   A6 15 0A           cp  temp_value,#0AH
  322  0C56   BB 07              jr  ugt,temp_max
  323  0C58   8B 0A              jr  key_1_sub_end
  324  0C5A              temp_min:
  325  0C5A   E6 15 01           ld  temp_value,#01H
  326  0C5D   8B 05              jr  key_1_sub_end
  327  0C5F              temp_max:
  328  0C5F   E6 15 0A           ld  temp_value,#0AH
  329  0C62   8B 00              jr  key_1_sub_end
  330  0C64              key_1_sub_end:
  331                    ;        ld  I2C_data,temp_value
  332                    ;        ld  I2C_dress,#temp_value_dress
  333                    ;        call WR_24C02
  334                            
  335                    ;        ld  beep_flag,#01h
  336  0C64   AF                 ret        
  337                    ;***************************************************************         
  338                    ;*************************************************************** 
  339  0C65              key_2_sub:
  340  0C65   76 11 01           tm temp_status,#01H
  341  0C68   EB 18              jr ne,key_2_sub_end             ;temp off ,exit        
  342  0C6A   00 15              dec temp_value                  ;temp-
  343  0C6C   A6 15 01           cp  temp_value,#01H
  344  0C6F   7B 07              jr  ult,temp_min_1
  345  0C71   A6 15 0A           cp  temp_value,#0AH
  346  0C74   BB 07              jr  ugt,temp_max_2
  347  0C76   8B 0A              jr  key_2_sub_end
  348  0C78              temp_min_1:
  349  0C78   E6 15 01           ld  temp_value,#01H
  350  0C7B   8B 05              jr  key_2_sub_end
  351  0C7D              temp_max_2:
  352  0C7D   E6 15 0A           ld  temp_value,#0AH
  353  0C80   8B 00              jr  key_2_sub_end
  354  0C82              key_2_sub_end:
  355                    ;        ld  I2C_data,temp_value
  356                    ;        ld  I2C_dress,#temp_value_dress
  357                    ;        call WR_24C02
  358                     ;       ld  beep_flag,#01h
  359  0C82   AF                 ret        
  360                    ;*************************************************************** 
  361                    ;*************************************************************** 
  362  0C83              key_3_sub:
  363  0C83   A6 11 00           cp temp_status,#00H              
  364  0C86   6B 05              jr eq,temp_on                   ;if temp_status=0=off jump to temp on
  365                            
  366  0C88              temp_off:                               ;if temp_status=1=on  to temp off
  367  0C88   E6 11 00           ld temp_status,#00H
  368                            
  369  0C8B   8B 03              jr key_3_sub_end
  370                            
  371  0C8D              temp_on:
  372  0C8D   E6 11 01           ld temp_status,#01H
  373                            
  374                    
  375  0C90              key_3_sub_end:
  376                    ;        ld  beep_flag,#01h
  377  0C90   AF                 ret        
  378                    ;*************************************************************** 
  379                    ;*************************************************************** 
  380  0C91              key_4_sub:
  381  0C91   76 10 01           tm fire_status,#01H
  382  0C94   EB 13              jr ne,key_4_sub_end
  383                            
  384  0C96   A6 12 00           cp lamp_status,#00H              
  385  0C99   6B F2              jr eq,temp_on                   ;if lamp_status=0=off jump to lamp on
  386                            
  387  0C9B              lamp_off:                               ;if lamp_status=1=on  to lamp off
  388  0C9B   E6 12 00           ld lamp_status,#00H   
  389  0C9E   F6 0D 20           call lamp_close  
  390  0CA1   8B 06              jr key_4_sub_end
  391                            
  392  0CA3              lamp_on:
  393  0CA3   E6 12 01           ld lamp_status,#01H
  394  0CA6   F6 0D 1C           call lamp_open
  395                    
  396  0CA9              key_4_sub_end:
  397                    ;        ld  I2C_data,lamp_status
  398                    ;        ld  I2C_dress,#lamp_status_dress
  399                    ;        call WR_24C02
  400                     ;       ld  beep_flag,#01h        
  401  0CA9   AF                 ret        
  402                    ;***************************************************************         
  403                    ;*************************************************************** 
  404  0CAA              key_5_sub:
  405  0CAA   76 10 01           tm fire_status,#01H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -