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

📄 getkey.c

📁 收集了一些按键扫描程序,希望对大家在按键学习上有所帮助
💻 C
字号:
  /***********************************************************************/
/*  This file is part of the C51 Compiler package                      */
/*  Copyright KEIL ELEKTRONIK GmbH 1993 - 1999                         */
/***********************************************************************/
/*                                                                     */
/*  GETKEY.C:  This routine is the general character input of C51.     */
/*                                                                     */
/*  To translate this file use C51 with the following invocation:      */
/*                                                                     */
/*     C51 GETKEY.C  <memory model>                                    */
/*                                                                     */
/*  To link the modified GETKEY.OBJ file to your application use the   */
/*  following L51 invocation:                                          */
/*                                                                     */
/*     L51 <your object file list>, GETKEY.OBJ <controls>              */
/*                                                                     */
/***********************************************************************/

#include <reg52.h>
#include <stdio.h>
#include <zno.h>
unsigned char xdata port2_a  _at_ 0xf800;
unsigned char xdata port2_b  _at_ 0xf801;
unsigned char xdata port2_c  _at_ 0xf802;
unsigned char xdata port2_i  _at_ 0xf803;
unsigned char xdata port1_a  _at_ 0xfa00;
unsigned char xdata port1_b  _at_ 0xfa01;
unsigned char xdata port1_c  _at_ 0xfa02;
unsigned char xdata port1_i  _at_ 0xfa03;

char flagkey;
char _getkey ()
{ unsigned int n;  
  char c;
  
//  port1_i=control1_word;
//  port2_i=control2_word;
  if (flagkey==1)
  {
    c=port2_c;
    c=c|0xca;
    if(c!=0xff)
    { 
      for (n=0;n<0x6ff;n++){}
      c=port2_c;
      c=c|0xca;
      if (c!=0xff)
      { flagkey=0;
        switch(c)
        { case 0xdf:c=ret;break;
          case 0xfb:c=r_move;break;
          case 0xef:c=dec;break;
          case 0xfe:c=inc;break;
          default:c=0;flagkey=1;
          }
        }
      else c=0;
      }
    else c=0;
    }
  else                /*flagkey =0 check turn off*/
  { 
    if((port2_c|0xca)==0xff)
    {
     for (n=0;n<0x6ff;n++){}
     if((port2_c|0xca)==0xff)flagkey=1;    
     }   
    c=0;
    }
  return (c);
  }


⌨️ 快捷键说明

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