直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx

上传人:b****4 文档编号:16643694 上传时间:2022-11-25 格式:DOCX 页数:16 大小:44.32KB
下载 相关 举报
直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx_第1页
第1页 / 共16页
直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx_第2页
第2页 / 共16页
直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx_第3页
第3页 / 共16页
直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx_第4页
第4页 / 共16页
直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx

《直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx(16页珍藏版)》请在冰豆网上搜索。

直接在Keil下仿真的T9拼音输入法完整版Word文档下载推荐.docx

wxyz 

-:

前翻页 

4:

ghi 

5:

jkl 

6:

mno 

+:

后翻页 

1:

?

2:

abc 

3:

def 

回车键:

输入状态和选字状态切换 

0:

.和空格及回车键:

*/

//请把这个帖子的内容保存为51t9py.c

//--------------------------------------------------------------------------//

// 

源程序大公开 

(c)Copyright2001-2003xuwenjun 

AllRightsReserved 

V1.00 

//标 题:

T9拼音输入法模块 

//文件名:

51t9py.c 

//版 本:

V1.00 

//修改人:

徐文军 

E-mail:

xuwenjun@ 

//日 期:

05-4-8 

//描 述:

//声 明:

以下代码仅免费提供给学习用途,但引用或修改后必须在文件中声明出处.//

如用于商业用途请与作者联系. 

有问题请mailtoxuwenjun@ 

欢迎与我交流!

//老版本:

无 

老版本文件名:

//创建人:

02-11-05 

1、很久以前的程序,根据网友张凯、李强的51py输入法子程序改编, 

增加索引、完善主程序、测试程序,使之在Keil下直接仿真 

2、在Keil环境下可以直接按“Ctrl+F5”键仿真,切换到在串口依次输入:

3、由于Keil的模拟串口是单字节显示,汉字显示为乱码,所以要加挂 

RICHWIN或RichView这种会重新刷新显示的中文平台,或手工刷新屏幕 

(RichView可以到下载) 

#include<

string.h>

stdio.h>

#include"

PY_mb.h"

//#include"

51t9_MB.h"

51t9py_indexa.h"

#defineCNTLQ 

0x11

#defineCNTLS 

0x13

#defineDEL 

0x7F

#defineBACKSPACE 

0x08

#defineCR 

0x0D

#defineLF 

0x0A

unsignedcharcpt9PY_Mblen;

structt9PY_indexcode 

*cpt9PY_Mb[16];

unsignedchart9PY_ime(char*strInput_t9PY_str)

{

structt9PY_index*cpHZ,*cpHZedge,*cpHZTemp;

unsignedchari,j,cInputStrLength;

cpt9PY_Mblen=0;

//完全匹配组数

j=0;

//j为匹配最大值

cInputStrLength=strlen(strInput_t9PY_str);

//输入拼音串长度//

if(*strInput_t9PY_str=='

\0'

)return(0);

//如果输入空字符返回0//

cpHZ=&

(t9PY_index2[0]);

//查首字母索引//

cpHZedge=t9PY_index2+sizeof(t9PY_index2)/sizeof(t9PY_index2[0]);

strInput_t9PY_str++;

//指向拼音串第二个字母//

while(cpHZ<

cpHZedge) 

//待查询记录条数

for(i=0;

i<

cInputStrLength;

i++)

if(*(strInput_t9PY_str+i)!

=*((*cpHZ).t9PY_T9+i)) 

//检查字符串匹配

if(i+1>

j)

j=i+1;

cpHZTemp=cpHZ;

}

break;

//发现字母串不配,退出//

if((i==cInputStrLength)&

&

(cpt9PY_Mblen<

16)) 

//字母串全配,最多8组

cpt9PY_Mb[cpt9PY_Mblen]=cpHZ;

cpt9PY_Mblen++;

cpHZ++;

if(j!

=cInputStrLength) 

//不完全匹配输出最多匹配的1组

cpt9PY_Mb[0]=cpHZTemp;

return(cpt9PY_Mblen);

//输出完全匹配组数,0为无果而终//

char*t9PY_ime_mb(char*strInput_t9PY_str)

if(t9PY_ime(strInput_t9PY_str)>

0)

return((*(cpt9PY_Mb[0])).PY_mb);

else

return(PY_mb_space);

voidt9PY_Test(void)

bitPYEnter=0;

bitHZok=0;

unsignedchartemp;

unsignedchartemp2;

unsignedchart9PYn=0;

charidatainline[16]={0x00};

idatacharchinese_word[3]="

"

;

chartempchar,Add=0,i=0;

structt9PY_index*cpTemp;

cpTemp=t9PY_index2;

printf("

\n按键/:

上一拼音*:

下一拼音.和空格及回车键:

输入状态和选字状态切换\n"

);

请按键:

2-abc3-def4-ghi5-jkl6-mno7-pqrs8-tuv9-wxyz\n"

while(!

HZok)

tempchar=getchar();

switch(tempchar)

case'

0'

:

1'

2'

3'

4'

5'

6'

7'

8'

9'

if(~PYEnter)

inline[i]=tempchar;

i++;

Add=0;

t9PY_ime(inline);

/'

if(t9PYn>

0)t9PYn--;

*'

t9PYn++;

=cpt9PY_Mblen)t9PYn--;

-'

if(Add>

=12)Add-=12;

='

+'

if(Add<

strlen((*cpTemp).PY_mb)-12)Add+=12;

caseBACKSPACE:

if(i>

0)i--;

inline[i]=0x00;

cpTemp=cpt9PY_Mb[t9PYn];

\n'

.'

//输入状态和选字状态切换

'

PYEnter^=1;

default 

HZok=1;

\r"

if(PYEnter)

选"

if((cpTemp!

=PY_mb_space)&

(tempchar>

)&

(tempchar<

))

t9PYn=0;

%s\n"

inline);

chinese_word[0]=*((*cpTemp).PY_mb+Add+(tempchar-'

)*2);

chinese_word[1]=*((*cpTemp).PY_mb+Add+(tempchar-'

)*2+1);

printf(chinese_word);

\n"

printf((*(cpTemp)).PY);

printf((*cpTemp).PY_mb+Add);

\n拼音123456789\r"

else

拼"

for(temp=t9PYn;

temp<

cpt9PY_Mblen;

temp++)

cpTemp=cpt9PY_Mb[temp];

temp2=((strlen((*(cpTemp)).PY_mb)-Add)/2);

%2bd:

%02bd:

temp,temp2);

printf((*(cpTemp)).PY_mb+Add);

//-----以下为测试程序---------------------------------------------------------------------//

#include<

REG52.H>

#ifdefMONITOR51 

/*DebuggingwithMonitor-51needs 

charcodereserve[3]_at_0x23;

/*spaceforserialinterruptif 

#endif 

/*StopExectionwithSerialIntr. 

/*isenabled 

voidmain(void){

charinput_string[]="

98"

/*------------------------------------------------

Setuptheserialportfor1200baudat16MHz.

------------------------------------------------*/

#ifndefMONITOR51

SCON 

=0x50;

/*SCON:

mode1,8-bitUART,enablercvr 

TMOD|=0x20;

/*TMOD:

timer1,mode2,8-bitreload 

TH1 

=250;

/*TH1:

reloadvaluefor9600baud@11.0592MHz*/

TR1 

=1;

/*TR1:

timer1run 

TI 

/*TI:

setTItosendfirstcharofUART 

#endif

Notethatanembeddedprogramneverexits(because

thereisnooperatingsystemtoreturnto). 

It

mustloopandexecutef

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1