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

📄 main.c

📁 电子词典的设计开发
💻 C
📖 第 1 页 / 共 2 页
字号:
//======================================================
//  The information contained herein is the exclusive property of
//  Sunnnorth Technology Co. And shall not be distributed, reproduced,
//  or disclosed in whole in part without prior written permission.
//          (C) COPYRIGHT 2003  SUNNORTH TECHNOLOGY CO.
//                       ALL RIGHTS RESERVED
//  The entire notice above must be reproduced on all authorized copies.
//========================================================

//============================================================
//  工程名称:LCD_DynamicGraphicMusic.spj
//  功能描述:   电子词典
//  IDE环境:   SUNPLUS u'nSPTM  IDE 1.8.0
//
//  涉及的库:
//         
//  组成文件:
//          SPLC501hardware.asm/SPLC501sys.asm/SPLC501var.asm         
//    	    splc501c.inc/splc501c_io.inc/hardware.inc/lab_parameter.h       
//          sacmv32.asm/spce.asm/sacm_user.asm/sp_lib.asm/isr.asm     
//          a2000.inc/spce.inc/sacmv32.h/sacmv32.inc
//  日期:     2006/8/17
//===============================================
//============================================================
// 文件名称:main.c
// 实现功能:电子词典
// 日期:    2006/8/17
//============================================================
#include "sacmv32.h"
#include "lab_parameter.h"
#include "SPCE061V004.H"
#define HaveKey  1
#define NoKey    0
#define high   10
#define longth   8

typedef  unsigned char uchar;    
unsigned int  KeyVal;              //键值寄存位
unsigned int  KeycodeLED[25];     //保存要查找的单词 
unsigned int  ret=0;               //数组里的字符个数  

unsigned int  telephone[50][30];   //存储电话本
unsigned int  line=0,row=0;        //电话本行不同的人,列人名 

unsigned int  tel_find[20];
unsigned int  tel_find_name=0;
            
unsigned int  flag=0;              //已经做出选择标志位
unsigned int  KeyFlag;             //按键标识                           
unsigned int  flag_you=0;          //词库里有这个单词标志位
unsigned int  temp;                //键值寄存位

unsigned int  flag_edit_tel=0; 
unsigned int  flag_dictionary=0; 
unsigned int  flag_find_tel=0; 
unsigned int  flag_change=0;       //字母与数字切换标志位
unsigned int  flag_edit_num=0;
unsigned int  line_find=0;
unsigned int  tel_num_you=0;

       
//===========================================================================
//  void Time_delay()     延时子程序
//===========================================================================  
void delay()
{
  unsigned int r1,r2;
  for(r1=0;r1<2;r1++)
      for(r2=0;r2<0xffff;r2++)
           Clear_Watch_Dog();
}

//===========================================================================
// void  ciku() 单词查找子程序
//===========================================================================  
void  ciku()
{
     switch(ret) 
     {
      case 1: break;  
      case 2: break;
      case 3:
        if(KeycodeLED[0]==98&&KeycodeLED[1]==97&&KeycodeLED[2]==100)//bad
             {FG_PutStr("bu hao de",2,120,50);flag_you=1;}
        if(KeycodeLED[0]==98&&KeycodeLED[1]==97&&KeycodeLED[2]==103)//bag
             {FG_PutStr("dai zi",2,120,50);flag_you=1;}  
        if(KeycodeLED[0]==98&&KeycodeLED[1]==111&&KeycodeLED[2]==121)//boy
             {FG_PutStr("nan hai",2,120,50);flag_you=1;} 
      break;
      case 4:   
        if(KeycodeLED[0]==109&&KeycodeLED[1]==111&&KeycodeLED[2]==111&&KeycodeLED[3]==110)//moon
             {FG_PutStr("yue liang",2,120,50);flag_you=1;}
        if(KeycodeLED[0]==108&&KeycodeLED[1]==111&&KeycodeLED[2]==118&&KeycodeLED[3]==101)//love
             {FG_PutStr("xi huan,ai",2,120,50);flag_you=1;}
        if(KeycodeLED[0]==104&&KeycodeLED[1]==97&&KeycodeLED[2]==116&&KeycodeLED[3]==101)//hate
             {FG_PutStr("tao yan,hen",2,120,50);flag_you=1;}
      break;
      case 7:
        if(KeycodeLED[0]==119&&KeycodeLED[1]==101&&KeycodeLED[2]==97&&KeycodeLED[3]==116&&KeycodeLED[4]==104&&KeycodeLED[5]==101&&KeycodeLED[6]==114)//weather
             {FG_PutStr("tian qi",2,120,50);flag_you=1;}
     
      break;
      case 8:
        if(KeycodeLED[0]==116&&KeycodeLED[1]==111&&KeycodeLED[2]==109&&KeycodeLED[3]==111&&KeycodeLED[4]==114&&KeycodeLED[5]==114&&KeycodeLED[6]==111&&KeycodeLED[7]==119)//tomorrow
             {FG_PutStr("mint tian",2,120,50);flag_you=1;}
     
      break;
      case 9:
        if(KeycodeLED[0]==121&&KeycodeLED[1]==101&&KeycodeLED[2]==115&&KeycodeLED[3]==116&&KeycodeLED[4]==101&&KeycodeLED[5]==114&&KeycodeLED[6]==100&&KeycodeLED[7]==97&&KeycodeLED[8]==121)//yesterday
             {FG_PutStr("zuo tian",2,120,50);flag_you=1;}
     
      break;
      default:break;
     }   

     if(flag_you==0&&ret!=0) {FG_PutStr("SORRY!",3,100,40);}
         
    
}         
         
/////////////////////////////////////////////////////////////////////////////////////////        
//void  tel_num_find()  电话查找子程序        
/////////////////////////////////////////////////////////////////////////////////////////         
void  tel_num_find()
{
  unsigned int i,j;
  for(line_find=0;line_find<line;line_find++)
  {    
     for(j=0;j<tel_find_name;j++)
       {
          if(telephone[line_find][j]!=tel_find[j]) break;
          Clear_Watch_Dog();
       }  
     if(j>=tel_find_name) {tel_num_you=1;break;} 
  } 
  
  if(tel_num_you) {Play_Num0(line_find,j+20);}
  else {FG_PutStr("No  Number",3,120,50);FG_PutStr("of the Person",3,120,40);}
}   
     
     
       
 


       
         
         
 

//===========================================================================
//  void  play_num(int i)     在液晶屏上显示  子程序
//=========================================================================== 
void  Play_Num(unsigned int a[],unsigned int num)
{
    unsigned int i,k,j; 
    delay();
    FG_ClearScreen(0);
    
    if(num==0)
    {
         if(flag_dictionary)FG_PutStr("Input word....",3,120,40);
           else if(flag_find_tel)FG_PutStr("Input name....",3,125,40);
                else  FG_PutStr("Electronic Dictionary",3,125,40);
    }
    else
    {
     FG_ClearScreen(0); 
     if(flag_change==0)FG_PutStr("abc",3,25,20);
     else   FG_PutStr("123",3,25,20);   
     for(j=0;j<num;j++)
     {
      k=j/14;
      i=j-k*14;
      switch(a[j])
      {
        case  0:FG_PutStr("0",2,120-longth*i,60-high*k);break;
        case  1:FG_PutStr("1",2,120-longth*i,60-high*k);break;
        case  2:FG_PutStr("2",2,120-longth*i,60-high*k);break;
        case  3:FG_PutStr("3",2,120-longth*i,60-high*k);break;
        case  4:FG_PutStr("4",2,120-longth*i,60-high*k);break;
        case  5:FG_PutStr("5",2,120-longth*i,60-high*k);break;
        case  6:FG_PutStr("6",2,120-longth*i,60-high*k);break;
        case  7:FG_PutStr("7",2,120-longth*i,60-high*k);break;
        case  8:FG_PutStr("8",2,120-longth*i,60-high*k);break;
        case  9:FG_PutStr("9",2,120-longth*i,60-high*k);break;
        case 32:FG_PutStr(" ",2,120-longth*i,60-high*k);break;
        case 97:FG_PutStr("a",2,120-longth*i,60-high*k);break;        //显示a
        case 98:FG_PutStr("b",2,120-longth*i,60-high*k);break;        //显示b
        case 99:FG_PutStr("c",2,120-longth*i,60-high*k);break;        //显示c
        case 100:FG_PutStr("d",2,120-longth*i,60-high*k);break;       //显示d
        case 101:FG_PutStr("e",2,120-longth*i,60-high*k);break;       //显示e
        case 102:FG_PutStr("f",2,120-longth*i,60-high*k);break;       //显示f
        case 103:FG_PutStr("g",2,120-longth*i,60-high*k);break;       //显示g
        case 104:FG_PutStr("h",2,120-longth*i,60-high*k);break; 
        case 105:FG_PutStr("i",2,120-longth*i,60-high*k);break; 
        case 106:FG_PutStr("j",2,120-longth*i,60-high*k);break; 
        case 107:FG_PutStr("k",2,120-longth*i,60-high*k);break; 
        case 108:FG_PutStr("l",2,120-longth*i,60-high*k);break; 
        case 109:FG_PutStr("m",2,120-longth*i,60-high*k);break; 
        case 110:FG_PutStr("n",2,120-longth*i,60-high*k);break; 
        case 111:FG_PutStr("o",2,120-longth*i,60-high*k);break; 
        case 112:FG_PutStr("p",2,120-longth*i,60-high*k);break; 
        case 113:FG_PutStr("q",2,120-longth*i,60-high*k);break; 
        case 114:FG_PutStr("r",2,120-longth*i,60-high*k);break; 
        case 115:FG_PutStr("s",2,120-longth*i,60-high*k);break; 
        case 116:FG_PutStr("t",2,120-longth*i,60-high*k);break; 
        case 117:FG_PutStr("u",2,120-longth*i,60-high*k);break;
        case 118:FG_PutStr("v",2,120-longth*i,60-high*k);break;
        case 119:FG_PutStr("w",2,120-longth*i,60-high*k);break;
        case 120:FG_PutStr("x",2,120-longth*i,60-high*k);break;
        case 121:FG_PutStr("y",2,120-longth*i,60-high*k);break;
        case 122:FG_PutStr("z",2,120-longth*i,60-high*k);break;      
      }
     } 
   }
}



//*************************************************************
void  Play_Num0(unsigned int num_line,unsigned int num_row)
{
    unsigned int i,k,j; 
    delay();
    FG_ClearScreen(0);
    
    if(num_row==0&&flag_find_tel)FG_PutStr("Input name And Num....",3,120,40);
    else
    {
     FG_ClearScreen(0); 
     if(flag_change==0)FG_PutStr("abc",3,25,20);
     else   FG_PutStr("123",3,25,20);   
     for(j=0;j<num_row;j++)
     {
      k=j/14;
      i=j-k*14;
      switch(telephone[num_line][j])
      {
        case  0:FG_PutStr("0",2,120-longth*i,60-high*k);break;
        case  1:FG_PutStr("1",2,120-longth*i,60-high*k);break;
        case  2:FG_PutStr("2",2,120-longth*i,60-high*k);break;
        case  3:FG_PutStr("3",2,120-longth*i,60-high*k);break;
        case  4:FG_PutStr("4",2,120-longth*i,60-high*k);break;
        case  5:FG_PutStr("5",2,120-longth*i,60-high*k);break;
        case  6:FG_PutStr("6",2,120-longth*i,60-high*k);break;
        case  7:FG_PutStr("7",2,120-longth*i,60-high*k);break;
        case  8:FG_PutStr("8",2,120-longth*i,60-high*k);break;
        case  9:FG_PutStr("9",2,120-longth*i,60-high*k);break;
        case 32:FG_PutStr(" ",2,120-longth*i,60-high*k);break;
        case 97:FG_PutStr("a",2,120-longth*i,60-high*k);break;        //显示a
        case 98:FG_PutStr("b",2,120-longth*i,60-high*k);break;        //显示b
        case 99:FG_PutStr("c",2,120-longth*i,60-high*k);break;        //显示c
        case 100:FG_PutStr("d",2,120-longth*i,60-high*k);break;       //显示d
        case 101:FG_PutStr("e",2,120-longth*i,60-high*k);break;       //显示e
        case 102:FG_PutStr("f",2,120-longth*i,60-high*k);break;       //显示f
        case 103:FG_PutStr("g",2,120-longth*i,60-high*k);break;       //显示g
        case 104:FG_PutStr("h",2,120-longth*i,60-high*k);break; 
        case 105:FG_PutStr("i",2,120-longth*i,60-high*k);break; 
        case 106:FG_PutStr("j",2,120-longth*i,60-high*k);break; 
        case 107:FG_PutStr("k",2,120-longth*i,60-high*k);break; 
        case 108:FG_PutStr("l",2,120-longth*i,60-high*k);break; 
        case 109:FG_PutStr("m",2,120-longth*i,60-high*k);break; 
        case 110:FG_PutStr("n",2,120-longth*i,60-high*k);break; 
        case 111:FG_PutStr("o",2,120-longth*i,60-high*k);break; 
        case 112:FG_PutStr("p",2,120-longth*i,60-high*k);break; 
        case 113:FG_PutStr("q",2,120-longth*i,60-high*k);break; 
        case 114:FG_PutStr("r",2,120-longth*i,60-high*k);break; 
        case 115:FG_PutStr("s",2,120-longth*i,60-high*k);break; 
        case 116:FG_PutStr("t",2,120-longth*i,60-high*k);break; 
        case 117:FG_PutStr("u",2,120-longth*i,60-high*k);break;
        case 118:FG_PutStr("v",2,120-longth*i,60-high*k);break;
        case 119:FG_PutStr("w",2,120-longth*i,60-high*k);break;
        case 120:FG_PutStr("x",2,120-longth*i,60-high*k);break;
        case 121:FG_PutStr("y",2,120-longth*i,60-high*k);break;
        case 122:FG_PutStr("z",2,120-longth*i,60-high*k);break;      
      }
     } 
   }
}


//===================================================================================================
//void choose(int value1,int value2,int value3,int value4,int value5,int value6,int value7,int value8)
//===================================================================================================  
void choose(int value1,int value2,int value3,int value4)

{
 
  temp=F_Get_Key();
  delay();
  if(flag_dictionary)
  {
   switch(temp)
    {
	  case 13 :{KeycodeLED[ret]=value1;flag=1;ret++;}break;  
	  case 14 :{KeycodeLED[ret]=value2;flag=1;ret++;}break;  
	  case 15 :{KeycodeLED[ret]=value3;flag=1;ret++;}break;  
 	  case 16 :{KeycodeLED[ret]=value4;flag=1;ret++;}break; 
    } 		
    if(ret) Play_Num(KeycodeLED,ret);
  }
  
  if(flag_edit_tel)
  {
    switch(temp)
    {
	  case 13 :{telephone[line][row]=value1;flag=1;row++;}break;  
	  case 14 :{telephone[line][row]=value2;flag=1;row++;}break;  
	  case 15 :{telephone[line][row]=value3;flag=1;row++;}break;  
 	  case 16 :{telephone[line][row]=value4;flag=1;row++;}break; 
    } 
    if(row) Play_Num0(line,row);
  } 
  if(flag_find_tel) 
  {
    switch(temp)
    {

⌨️ 快捷键说明

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