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

📄 key.h

📁 Bitek 公司 bit1611b模拟屏驱动芯片外接MCU驱动DEMO源码
💻 H
字号:
/* **********************************************************************

         Copyright (c) 2002-2006 Beyond Innovation Technology Co., Ltd

        All rights are reserved. Reproduction in whole or in parts is
    prohibited without the prior written consent of the copyright owner.
   ----------------------------------------------------------------------

    Module: KEY.H

    Purpose: Interface of KEY module.

    Version: 0.01                                   07:20PM  2005/05/13

    Compiler: Keil 8051 C Compiler v8.01

    Reference:

   ----------------------------------------------------------------------
    Modification:

    R0.01 07:20PM  2005/05/13 Jeffrey Chang
    Reason:
        1. Original.
    Solution:

   ********************************************************************** */

#ifndef _KEY_H_
#define _KEY_H_

/* ------------------------------------
    Header Files
   ------------------------------------ */
#include "common.h"
#include "platform.h"


/* ------------------------------------
    Macro Definitions
   ------------------------------------ */
#undef EXTERN

#ifdef _KEY_C_
    #define EXTERN
#else
    #define EXTERN  extern
#endif






/* ....................................
    KEY Configuration
   .................................... */
#define KEY_AUTO_REPEAT         ON
#define KEY_RELEASE_DETECTION   ON
#define KEY_STILL_DETECTION     ON


// Keypad Port
#define KEY_IOPORT              P2

// Keypad Attribute
#define KEY_MASK                0xF8            // 5 keys
#define KEY_MASK_IR             0x03
#define KEY_MASK_STILL          0x02            // Key Still Pressed !
#define KEY_MASK_RELEASE        0x01            // Key Released !

/* KEY CODE by Keypad */
#define KEY_NULL                0x00

#define KEY_POWER               0x80            // P2.7 Power   Active Low
#define KEY_MENU                0x40            // P2.6 Menu    Active Low
#define KEY_SELECT              0x20            // P2.5 Select  Active Low
#define KEY_UP                  0x10            // P2.4 Up      Active Low
#define KEY_DOWN                0x08            // P2.3 Down    Active Low


// Combined KEY CODE by Keypad !
#define KEY_UP_DOWN             (KEY_UP | KEY_DOWN)

// Still KEY CODE by Keypad !
#define KEY_STILL_POWER         (KEY_MASK_STILL     | KEY_POWER)
#define KEY_STILL_MENU          (KEY_MASK_STILL     | KEY_MENU)
#define KEY_STILL_SELECT        (KEY_MASK_STILL     | KEY_SELECT)

#define KEY_RELEASE_POWER       (KEY_MASK_RELEASE   | KEY_POWER)
#define KEY_RELEASE_MENU        (KEY_MASK_RELEASE   | KEY_MENU)
#define KEY_RELEASE_SELECT      (KEY_MASK_RELEASE   | KEY_SELECT)

// KEY CODE by IR
#define KEY_IR_POWER            (KEY_MASK_IR        | KEY_POWER)
#define KEY_IR_MENU             (KEY_MASK_IR        | KEY_MENU)
#define KEY_IR_SELECT           (KEY_MASK_IR        | KEY_SELECT)
#define KEY_IR_UP               (KEY_MASK_IR        | KEY_UP)
#define KEY_IR_DOWN             (KEY_MASK_IR        | KEY_DOWN)


/* Size of the KEYPAD buffer */
#define KEY_BFR_SIZE            4

/* Number of system ticks for key delay to start repeat, normally 1 second */
#define KEY_REPEAT_START_DELAY  16      // 16 Key Scan Periods = 16 x 48 ms

/* Number of system ticks between each key repeat interval */
/* Key rate is 20 keys per second */
#define KEY_REPEAT_INTERVAL     1       // 1 Key Scan Periods = 1 x 48 ms

#define KEY_STILL_INTERVAL      36      // 36 Key Scan Periods = 36 x 48 ms



#define KEY_VR_DEFAULT              100


/* ------------------------------------
    Type Definitions
   ------------------------------------ */


/* ------------------------------------
    Variables Definitions/Declarations
   ------------------------------------ */
sbit KEY_iPOWER         = P2 ^ 7;           // Active LOW
sbit KEY_iMENU          = P2 ^ 6;           // Active Low
sbit KEY_iSELECT        = P2 ^ 5;           // Active Low
sbit KEY_iUP            = P2 ^ 4;           // Active Low
sbit KEY_iDOWN          = P2 ^ 3;           // Active Low



EXTERN UB8  bKeyCnt;             /* Number of keys read from the keypad */
EXTERN BOOL fKeyReleased;
EXTERN UB8  bKeyScanState;       /* Current state of key scanning function */

#if (KEY_AUTO_REPEAT)
EXTERN UB8  bTimerKeyAuto;
#endif

EXTERN UB8  bTimerKeyPressed;
EXTERN UB8  bLastKey;

#if (KEY_STILL_DETECTION)
EXTERN UB8  bKEY_STILL_INTERVAL;        // Addedd by JC 09:37AM  2004/11/26
#endif

#if (KEY_VR_AIN21)
EXTERN UB8  bKEY_VR_ADJUSTMENT;
#endif


/* ------------------------------------
    Function Prototypes
   ------------------------------------ */
EXTERN void KEY_BufferFlush(void);      /* Flush the keypad buffer */
EXTERN void KEY_BufferIn(UB8 bCode);    /* Put a Keycode in the buffer  */
EXTERN UB8  KEY_BufferOut(void);        /* Get a scan code from buffer  */
EXTERN UB8  KEY_Decode(void);
EXTERN BOOL KEY_Hit(void);              /* Check whether any key was pressed */
EXTERN void KEY_Init(void);             /* Initialize the keypad module */
EXTERN BOOL KEY_Pressed(void);
EXTERN void KEY_Scan(void);             /* Background process for key scan */


#endif /* _KEY_H_ */


/* **********************************************************************

    Description:

   ********************************************************************** */

/* %% End Of File %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */

⌨️ 快捷键说明

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