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

📄 inputbox.c

📁 在ARM7和UC/OSII的平台上实现了GPS自动报站的功能,涉及GPS模块LEA_4S的驱动,位置速寻算法,语音芯片ISD4004的录放音驱动,LED页面管理等等.从启动代码到操作系统的移植以及到业
💻 C
字号:
/*
******************************************************************
*                  XIAMEN YAXON NETWORK CO.LTD.  
*                   XINXI BUILDING,HULI,XIAMEN
*      (c) Copyright 2002,XIAMEN YAXON NETWORK CO.LTD. ,XIAMEN
*                     All Rights Reserved
*
* FileName     :  INPUTBOX.C
* Programmer(s):  WuJingYu
* Description  : 
******************************************************************
*/

/*
*****************************************************************
*                  REVISION HISTORY
*                 
* Date:    2002-10-29
*****************************************************************
*/ 

#define INPUTBOX_GLOBALS 
#include "includes.h"
#include "Timetask.h"
#include "ctype.h"
#include "LCD.H"
#include "tools.h"
/*
static INT8U KEY_ABC[]  = {"abc"};
static INT8U KEY_DEF[]  = {"def"};
static INT8U KEY_GHI[]  = {"ghi"};
static INT8U KEY_JKL[]  = {"jkl"};
static INT8U KEY_MNO[]  = {"mno"};
static INT8U KEY_PQRS[] = {"pqrs"};
static INT8U KEY_TUV[]  = {"tuv"};
static INT8U KEY_WXYZ[] = {"wxyz"};*/
static INT8U KEY_ABC[]  = {"ABC"};
static INT8U KEY_DEF[]  = {"DEF"};
static INT8U KEY_GHI[]  = {"GHI"};
static INT8U KEY_JKL[]  = {"JKL"};
static INT8U KEY_MNO[]  = {"MNO"};
static INT8U KEY_PQRS[] = {"PQRS"};
static INT8U KEY_TUV[]  = {"TUV"};
static INT8U KEY_WXYZ[] = {"WXYZ"};
//static INT8U KEY_SIGN[] = {",.?!:;'-()@#$%^&*_+=\|~`<>/[]{}"};
static INT8U KEY_SIGN[] = {",.?!:;'-()@#$%^&*_+=\\|~`<>/[]{}"};

static INT8U *KEY_ADDR[] = {KEY_ABC,KEY_DEF,KEY_GHI,KEY_JKL,KEY_MNO,KEY_PQRS,KEY_TUV,KEY_WXYZ,KEY_SIGN};

static  TMR_TSK /**GetKeyTmr,yl2003.3.5*/*GetKeyCharTmr;
//y	static  INPUTBOX *CurInput;
static  INT8U PreKey,HitTimes;
#define FLASHTIME     204
/*   yl 2003.3.5
BOOLEAN IsInRange(INT8U checkedchar,INT8U uplimit,INT8U downlimit)
{
     if ((checkedchar >= uplimit) && (checkedchar <= downlimit)) {
        return TRUE;
     } else {
        return FALSE;
     }      
}    
*/
/*
static void ShowInputBoxText(INPUTBOX *inputbox,BOOLEAN updatelcd)
{
     ClearOutBox();
     Print_Text(inputbox->asciichar,inputbox->charlen);
     UpdateOutBox_MEM();
     if (updatelcd) UpdateOutBox_LCD();
}
  
static void WaitKeyInputProc(void)
{
     INT8U charlen;
     void (*OptFunc)(void);
      
     StopTmr(GetKeyTmr);
     LockOutBox(CurInput->box);
     charlen = CurInput->charlen;
     LightOffOutBoxCursor(charlen-1);
     LightOnOutBoxCursor(charlen);
     HitTimes = 0;
     PreKey = NULL;
     OptFunc = CurInput->optfunc;
//     if (OptFunc != NULL) {
//         (*OptFunc)();
//     }  
} 


BOOLEAN InputAsciiChar(INPUTBOX *inputbox,INT8U keycode)
{ 
     INT8U  charlen,curkey;
     void (*OptFunc)(void);
     INT8U *ptr;
      
     LockOutBox(inputbox->box);
     charlen = inputbox->charlen;
     if (IsInRange(keycode,KEY_2,KEY_9)==FALSE) {
        return FALSE;  
     }
     ptr = KEY_ADDR[keycode-2];
     curkey = tolower(*ptr);
     if (curkey == PreKey) {
        HitTimes++;
        if (HitTimes >= strlen((INT8S*)ptr)) {
           HitTimes = 0;
        }   
        curkey =  tolower(*(ptr+HitTimes));
        inputbox->asciichar[charlen-1] = curkey;
     } else {
        HitTimes = 0;
        PreKey = curkey;
        if (charlen >= INPUTBOXMAXLEN) {
           return TRUE;
        } else {
            inputbox->asciichar[charlen] = curkey;
            inputbox->charlen++;
            charlen++;
        }
     }  
     //StartTmr(GetKeyTmr,MILTICK,1);//SECOND,4);
     StartTmr(GetKeyTmr,SECOND,1);
     CurInput = inputbox;
     LightOnOutBoxCursor(charlen-1);
     ShowInputBoxText(inputbox,1);
     OptFunc = inputbox->optfunc;
     if (OptFunc != NULL) {
        (*OptFunc)();
     }
     return TRUE;        
}            
    
static BOOLEAN DeleteAsciiChar(INPUTBOX *inputbox)
{
     INT8U  charlen;
     void (*EmptyFunc)(void),(*OptFunc)(void);
       
     LockOutBox(inputbox->box);
     StopTmr(GetKeyTmr);
     charlen = inputbox->charlen;
     HitTimes = 0;
     PreKey = NULL;
     if (charlen == 0) {
        return FALSE;
     } else {
        charlen--;
        inputbox->charlen--;
        ShowInputBoxText(inputbox,1);
        if (charlen == 0) {  
           EmptyFunc = inputbox->emptyfunc;
           if (EmptyFunc != NULL) {
              (*EmptyFunc)();
           }
           LightOffOutBoxCursor(charlen);
        } else { 
           LightOnOutBoxCursor(charlen);
           OptFunc = inputbox->optfunc;
           if (OptFunc != NULL) {
              (*OptFunc)();
           }   
        }
        return TRUE;
     }
}

static BOOLEAN SetTextInCharMode(INPUTBOX *inputbox,INT8U keycode)
{
     void (*OptFunc)(void);
     
     if (IsInRange(keycode,KEY_2,KEY_XING)==FALSE) {
        return FALSE;  
     }
     inputbox->inputmode = ASCIISELECTMODE;
     inputbox->charlen = strlen((INT8S*)KEY_ADDR[keycode-2]);
     memcpy(inputbox->asciichar,KEY_ADDR[keycode-2],inputbox->charlen);
     OptFunc = inputbox->optfunc;
     if (OptFunc != NULL) {
        (*OptFunc)();
     }
     return TRUE;
}

  
void  InitInputBox(INPUTBOX *inputbox)
{
      inputbox->charlen = 0;
      PreKey = NULL;
      HitTimes = 0; 
      GetKeyTmr = CreateTimer(WaitKeyInputProc,0);
}

void CreateInputBox(INPUTBOX *inputbox)
{
     LockOutBox(inputbox->box);
     ShowInputBoxText(inputbox,1);
     CreateBorder(inputbox->box);      
}
        
void DestroyInputBox(INPUTBOX *inputbox)
{
     inputbox->charlen = 0;
     StopTmr(GetKeyTmr);
     RemoveTmr(GetKeyTmr);
}    

void  IndicateInputBox(INPUTBOX *inputbox)
{
     LockOutBox(inputbox->box);
     LightOnOutBoxCursor(inputbox->charlen);
     ShowInputBoxText(inputbox,1); 
     
}
    

void  UnIndicateInputBox(INPUTBOX *inputbox)
{
     LockOutBox(inputbox->box);
     PreKey = NULL;
     HitTimes = 0; 
     StopTmr(GetKeyTmr);
     LightOffOutBoxCursor(inputbox->charlen);
     ShowInputBoxText(inputbox,1); 
     
}
    
void  ClearInputBox(INPUTBOX *inputbox)
{
     LockOutBox(inputbox->box);
     inputbox->charlen = 0;
     PreKey = NULL;
     HitTimes = 0; 
     ShowInputBoxText(inputbox,1); 
}
    
void  RefreshInputBox(INPUTBOX *inputbox)
{
     IndicateInputBox(inputbox);
}
    

BOOLEAN InputBox_HdlKey(INPUTBOX *inputbox)
{
     INT8U key;
     
     key = GetCurLcdKey();
     inputbox->inputmode  = CHINESESELECTMODE;
     if (GetSystem_EditMode() == CHARMODE) {
        return SetTextInCharMode(inputbox,key);
     }
     switch (key) {
        case KEY_CLR:
           return DeleteAsciiChar(inputbox);
        //case KEY_NCK:
          // return DeleteAsciiChar(inputbox);
        case KEY_XING:
           
           return SetTextInCharMode(inputbox,KEY_XING);
        default :
          return InputAsciiChar(inputbox,key);
    }
}  */

static void WaitKeyInput(void)
{
     StopTmr(GetKeyCharTmr);
     HitTimes = 0;
     PreKey = NULL;
}

INT8U GetAsciiChar(INT8U keycode)
{
     INT8U  curkey,asciichar;
     INT8U *ptr;
     
    // if (IsInRange(keycode,KEY_2,KEY_9)==FALSE) {
     //   return NULL;
    // }
     ptr = KEY_ADDR[keycode-2];
     curkey = tolower(*ptr);
     if (curkey == PreKey) {
        HitTimes++;
        if (HitTimes >= strlen((INT8S*)ptr)) {
           HitTimes = 0;
        }
        curkey =  tolower(*(ptr+HitTimes));
        asciichar = curkey;
     } else {
        HitTimes = 0;
        PreKey = curkey;
        asciichar = curkey;
     }
     StartTmr(GetKeyCharTmr,SECOND,1);
     return asciichar;
}

void  InitKeyCharTmr(void)
{
     PreKey = NULL;
     HitTimes = 0;
     GetKeyCharTmr = CreateTimer(WaitKeyInput,0);
}

void DestroyKeyCharTmr(void)
{
     StopTmr(GetKeyCharTmr);
     RemoveTmr(GetKeyCharTmr);
}

⌨️ 快捷键说明

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