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

📄 t9_v1.lst

📁 拼音输入法,通过单片机实现
💻 LST
📖 第 1 页 / 共 3 页
字号:
 540   3                              write_cmd(PAGE+page+j);write_cmd(COL+col);
 541   3                              for(i=0;i<num;i++)
 542   3                                        write_data(str[n*12+6*j+i]);
 543   3                    }
 544   2                        CS2=0;CS1=1;
 545   2                        col=0;
 546   2                        for(j=0;j<2;j++)
 547   2                        {
 548   3                                write_cmd(PAGE+page+j);write_cmd(COL+col);
 549   3                                for(i=num;i<6;i++)
 550   3                                      write_data(str[n*12+6*j+i]);  
 551   3                        }
C51 COMPILER V7.50   T9_V1                                                                 01/22/2006 18:12:40 PAGE 10  

 552   2              }
 553   1      
 554   1              
 555   1      
 556   1      }
 557          
 558          
 559          
 560          /**************************************************************************************************
 561          *显示小数字函数
 562          *函数声明:void display_num(uchar page,uchar col,uchar code *str,uchar n);
 563          *函数参数:page为页地址(0-7),col为列地址(0-127),str为数组名
 564          *函数作用:显示数字0-9
 565          *
 566          *
 567          **************************************************************************************************/
 568          void display_num(uchar page,uchar col,uchar code *str,uchar n)
 569          {
 570   1          uchar i;
 571   1              if(col<64)
 572   1              {
 573   2                        CS2=1;CS1=0;
 574   2              }
 575   1              else
 576   1              {
 577   2                        CS2=0;CS1=1;
 578   2                        col=col-64;
 579   2              }
 580   1              write_cmd(PAGE+page);write_cmd(COL+col);
 581   1              for(i=0;i<5;i++)
 582   1                      write_data(str[5*n+i]);
 583   1              
 584   1      
 585   1      }
 586          
 587          
 588          
 589          
 590          /**************************************************************************************************
 591          *
 592          *界面1函数
 593          *函数声明:void screen_1();
 594          *函数参数:无
 595          *函数作用:显示欢迎界面
 596          *
 597          **************************************************************************************************/
 598          void screen_1()
 599          {
 600   1            uchar i;
 601   1                uchar ii,iii;
 602   1      
 603   1                init();
 604   1                cls();
 605   1      
 606   1                for(i=0;i<7;i++)display_h(2,20+12*i,str_2,i);
 607   1                for(i=0;i<3;i++)display_h(4,44+12*i,str_2,i+7);
 608   1                for(i=0;i<10;i++)display_h(6,4+12*i,str_2,10+i);
 609   1                while(1)
 610   1                {
 611   2                       ii=key_ii();
 612   2                               iii=key();
 613   2                               if(ii!=0xff||iii!=0)
C51 COMPILER V7.50   T9_V1                                                                 01/22/2006 18:12:40 PAGE 11  

 614   2                               {
 615   3                                     state=1;
 616   3                                         break;
 617   3                               }
 618   2                     
 619   2                }
 620   1      
 621   1      }
 622          
 623          
 624          /**************************************************************************************************
 625          *
 626          *界面2函数
 627          *函数声明:void screen_2();
 628          *函数参数:无
 629          *函数作用:
 630          *
 631          *                1:[读短信]
 632          *                2:[写短信]
 633          *        确定              取消
 634          **************************************************************************************************/
 635          void screen_2()
 636          {
 637   1            uchar i;
 638   1                uchar ii,iii;
 639   1                uchar cnt=0;
 640   1      
 641   1                init();
 642   1                cls();
 643   1                display_h(2,40-12,symbol,0);
 644   1                display_h(2,40+36,symbol,1);
 645   1      
 646   1                display_h(2,40,symbol,2);
 647   1                display_h(2,40+12,symbol,4);
 648   1                display_h(2,40+24,symbol,5);
 649   1      
 650   1            display_e(2,5,b_num,1);
 651   1                display_e(2,5+6,b_num,10);
 652   1      
 653   1                display_e(4,5,b_num,2);
 654   1                display_e(4,5+6,b_num,10);
 655   1                for(i=0;i<3;i++)display_h(4,40+12*i,symbol,3+i);
 656   1                for(i=0;i<2;i++)display_h(6,12*i,str_1,i);         //显示“确定”
 657   1                for(i=0;i<2;i++)display_h(6,100+12*i,symbol,6+i);  //显示“取消”
 658   1              
 659   1                while(1)
 660   1                {
 661   2                      iii=key();
 662   2                              ii=key_ii();
 663   2                              if(ii==8)
 664   2                              {
 665   3                                    
 666   3                                   display_h(2,40-12,symbol,0);   //“〔”
 667   3                           display_h(2,40+36,symbol,1);       // “〕”
 668   3                                       display_h(4,28,str_1,4);
 669   3                                       display_h(4,76,str_1,4);
 670   3                                       cnt=0; 
 671   3                              }
 672   2                              else if(ii==9)
 673   2                              {
 674   3                                   display_h(4,40-12,symbol,0);   //“〔”
 675   3                           display_h(4,40+36,symbol,1);       // “〕”
C51 COMPILER V7.50   T9_V1                                                                 01/22/2006 18:12:40 PAGE 12  

 676   3                                       display_h(2,28,str_1,4);
 677   3                                       display_h(2,76,str_1,4);
 678   3                                       cnt=1; 
 679   3                              }
 680   2                              if (iii==6)
 681   2                              {
 682   3                                   if(cnt==1)
 683   3                                       {
 684   4                                             state=2;
 685   4                                             break; 
 686   4                                       }
 687   3                                       else if(cnt==0)
 688   3                                       {
 689   4                                             state=3;
 690   4                                             break;
 691   4                                       }
 692   3                                   
 693   3                              }
 694   2                              if(iii==7)
 695   2                              {
 696   3                                    state=0;
 697   3                                        break;
 698   3                              }
 699   2                }
 700   1      
 701   1      
 702   1      }
 703          
 704          
 705          /**************************************************************************************************
 706          *
 707          *界面3函数
 708          *函数声明:void screen_3();
 709          *函数参数:无
 710          *函数作用:用于写短信
 711          *
 712          **************************************************************************************************/
 713          void screen_3()
 714          {
 715   1            unsigned char *p,input_string[5];
 716   1                unsigned char *temp;//用于保存上一次查找的汉字 
 717   1                uchar page=0;
 718   1                uchar i,ii,iii;
 719   1                uchar cnt=0;
 720   1                uchar keycode,length=0;
 721   1                //uchar iic;
 722   1            //unsigned char *p_mem;
 723   1                unsigned int mem,cmp;
 724   1                
 725   1                length_h=0;     
 726   1                init();
 727   1                cls();
 728   1                line_v(63,16,15);
 729   1                line_v(64,16,15);
 730   1                line_h(0,30,128);
 731   1      
 732   1                //========================================================
 733   1                //中间为测试代码
 734   1                //IICWrite(0x100,84);
 735   1                //IICWrite(0x150,88);
 736   1                //iic=IICRead(0x100);
 737   1                //iic=IICRead(0x150);
C51 COMPILER V7.50   T9_V1                                                                 01/22/2006 18:12:40 PAGE 13  

 738   1                //p=T9PY("334",3);
 739   1                //mem=(unsigned int)p;
 740   1                //IICWrite(0x150,mem&0xff);
 741   1                //IICWrite(0x151,mem>>8);
 742   1                //mem=IICRead(0x150)+(IICRead(0x151)<<8);
 743   1                //p=(uchar code *)mem;
 744   1                //for(i=0;i<8;i++)display_h(0,12*i,p,i);
 745   1                //========================================================
 746   1      
 747   1      
 748   1                for(i=0;i<2;i++)
 749   1                {
 750   2                      display_h(6,i*12,str_1,i);                //显示“确定”
 751   2                              display_h(6,104+i*12,str_1,i+2);  //显示“拼音”
 752   2                }
 753   1                line_v(0,0,16);                                                 //显示光标
 754   1      
 755   1                
 756   1            while(1)
 757   1                {
 758   2                      iii=key();//判断“确定”键是否被按下
 759   2                              if(iii==6)
 760   2                              {
 761   3                                    state=1;
 762   3                                        break;
 763   3                              }
 764   2                              if(cnt==0)                            //CNT=0时为拼音输入状态
 765   2                              {                                                                 //扫描键盘,并且判断是否是在“1”-“9”之间
 766   3                                    ii=key_ii();
 767   3                                    if(ii!=0xff)
 768   3                                    {
 769   4                                              if(ii==0)keycode='7';
 770   4                                                      if(ii==1)keycode='8';
 771   4                                                      if(ii==2)keycode='9';
 772   4                                                      if(ii==4)keycode='4';
 773   4                                                      if(ii==5)keycode='5';
 774   4                                                      if(ii==6)keycode='6';
 775   4                                                      if(ii==9)keycode='2';
 776   4                                                      if(ii==10)keycode='3';
 777   4                                                      
 778   4                                                      if(ii>=0&&ii<=10&&ii!=3&&ii!=8)                            //当按键为字母键时
 779   4                                              {               
 780   5                                        for(i=0;i<8;i++) display_h(4,i*16+5,str_1,4);//清屏
 781   5                                                                for(i=0;i<8;i++)display_num(4,i*16,str_num,10);
 782   5                                                                input_string[length]=keycode;                //将键值赋给input_string数组
 783   5                                                    p=T9PY(input_string,length+1);               //查表,并且取得点阵表的地址
 784   5                                                                if(PY_num>0)                                  //find为1表示找到了与输入拼音匹配的汉字
 785   5                                                            {                                                                                 //保存下此次的汉字点阵地址,一旦下次没找到相匹配的汉字
 786   6                                                                      temp=p;                                                         //则调用显示最后匹配的汉字,否则将显示乱码
 787   6                                                                              for(i=0;i<8;i++)display_h(4,i*16+5,T9PY_mb[0]->PY_mb,i);     //显示汉字           
 788   6                                          length++;                                                                  //length用于记录输入字母的长度,每按一次键leng
             -th的值加一
 789   6                                                                      for(i=0;i<length;i++)
 790   6                                                                        display_e(2,66+6*i,asc,*(p_py+i)-'a'); //显示输入的拼音,字母的点阵放在asc数组中
 791   6                                          line_h(0,30,128);
 792   6                                                                              page=0;    //重新输入拼音,page置为0,否则会出错
 793   6                                                                }
 794   5                                                                else
 795   5                                                                {
 796   6                                                                      for(i=0;i<8;i++)display_h(4,i*16+5,temp,i);     //显示汉字
 797   6      
 798   6                                                                }
C51 COMPILER V7.50   T9_V1                                                                 01/22/2006 18:12:40 PAGE 14  

 799   5                              }
 800   4                                                      if (ii==15&&(PY_num>0))
 801   4                                                      {
 802   5                                                            for(i=0;i<8;i++) display_h(4,i*16+5,str_1,4);//清屏
 803   5                                                                for(i=0;i<8;i++)display_num(4,i*16,str_num,10);
 804   5                                                                page++;
 805   5                                                                if(page==PY_num)page=0;
 806   5                                                                for(i=0;i<8;i++)display_h(4,i*16+5,T9PY_mb[page]->PY_mb,i);     //显示汉字              
 807   5                                                                                                           
 808   5                                                                for(i=0;i<length;i++)
 809   5                                                                  display_e(2,66+6*i,asc,*(T9PY_mb[page]->PY+i)-'a'); //显示输入的拼音,字母的点阵放在asc

⌨️ 快捷键说明

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