char Reset_WiFi(char *msg)
{
//	unsigned char retval;
	
	clear_lcd();
	DrawTitle_to_row_Language2(2,"ÇëµÈ´ý...","Pls wait...");

	kmy_EnableDisableTime3(0);

	if(rak_get_net_status()==RUN_OK)
	{
		rak_disconnect();
	}
	
	Reset_Target();
	//while(!ReadINTPin());
	msleep(1000);
	rak_sys_init(&uCmdRspFrame);
	printf("%s\r\n",uCmdRspFrame.initResponse.strdata);
	if(rak_get_version()!=RUN_OK)
	{
		clear_lcd();
		DrawTitle_to_row_Language2(2,"ʧ°Ü!","failure!");
	}
	else
	{
		printf("%s\r\n",uCmdRspFrame.initResponse.strdata);
		clear_lcd();
	    DrawTitle_to_row_Language2(2,"³É¹¦!","Success!");
	}
	memset(SSID,0,sizeof(SSID));
	kmy_EnableDisableTime3(1);
	return (WaitkeyAndAutoExit(5));
}
示例#2
0
static char PhoneHandleName(char *msg)
{
	static struct MenuFuc_Language2 Menu[2]={
		{"1.修改","1.Edit",PhoneHandleNameXiuGai},		//注意:  第一个字符串的长度不能大于MaxByteOneLine-1
		{"2.删除记录","2.Delete record",PhoneHandleNameDelete},
	};
	struct MenuOperate_Language2 MenuOp={
		Menu,
		2,
		0,
		0,
		0,
		MaxRowOneScr,
		1,
		0,
		0
	};

	while(1){
		#ifdef DEBUG_PRINTF
		printf("PhoneHandleName\n");
		#endif
		MenuHandler_Language2(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(msg);
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;} 
			else{clear_lcd();MenuOp.flashflag=1;}
		}else{
			return MenuOp.RetVal;
		}
	}
}
示例#3
0
int main(int argc, char **argv) {
    if(wiringPiSetup() == -1) {
        printf("wiringPiSetup() failed\n");
        return EXIT_FAILURE;
    }

    // 540kHz speed - recomended by ST7920 spec
    //if ((lcd_fd = wiringPiSPISetupMode(0, 540000, 0x07)) < 0) {
    if ((lcd_fd = wiringPiSPISetup(0, 540000)) < 0) {
        printf("Can't open the SPI bus\n");
        return EXIT_FAILURE;
    }
    
    char mode = 0x07;
    ioctl(lcd_fd, SPI_IOC_WR_MODE, &mode);

    init_gpio();
    reset_lcd();
    init_lcd();
    
    set_extended_mode(0, 0, 0);
    set_extended_mode(0, 1, 1);

    clear_lcd();

    show_image(raspberry_pix);

    return EXIT_SUCCESS;
}
示例#4
0
static char PhoneHandleCall(char *msg)
{
	u8 phonebuff[20];
	u8 atcmd[50];
	EFILE efile;
	struct phoneleixing *ph;

	ph=(struct phoneleixing *)msg;

	clear_lcd();

	phonebuff[0]=EepromFile_Open(file_phonebook,&efile);

	memset(phonebuff,0,sizeof(phonebuff));

	if(ph->leixin==0)EepromFile_Seek(&efile,10+ph->numPhone*98+12,EepromFile_SEEK_SET);
	else EepromFile_Seek(&efile,10+ph->numPhone*98+12+18,EepromFile_SEEK_SET);
	EepromFile_read(phonebuff,18,&efile);

	DrawTitle_to_row_Language2(2,"正在拨号...","Dialing...");
	strcpy((char *)atcmd,"ATD");
	strcat((char *)atcmd,(const char *)phonebuff);
	strcat((char *)atcmd,";\r");
	send_at_cmd(atcmd);
	//text_out_to_row_x_Language2(1,25,phonebuff,phonebuff);
	phonebuff[0]=Waitkey_TillKeyPress();

	send_at_cmd("ATH\r");

	return phonebuff[0];
}
示例#5
0
/************************************光标在备注处菜单**********************************************/
static char PhoneHandleBeiZhu(char *msg)
{
	FILE *fp;
	u8 dispbuff[30];
	int numPhone;

	clear_lcd();
	fp=fopen("PhoneBook","rb");
	if(fp!=NULL){		//如果有记录,则先把记录读到phonebuff 。
		#ifdef DEBUG_PRINTF
		printf("open PhoneBook success!!\n");
		#endif
		fread(dispbuff,10,1,fp);
	}else{
		text_out_to_row_x_Language2(2,40,"没有记录","没有记录");
		goto tuichu;
	}

	numPhone=*msg;		//如果msg==NULL,则会引起segmentation  fault。
	fseek(fp,10+numPhone*98+12+18+18+20,SEEK_SET);
	fread(dispbuff,sizeof(dispbuff),1,fp);
	fclose(fp);
	
	text_out_to_row_x_Language2(0,40,"【备注】","【备注】");
	my_DisplayBuff(dispbuff,1,2);

	tuichu:
	SetBLOverTime(10);
	SetAutoExitTime(10);
	WaitkeyAndAutoExit(10);
	return 0;
}
示例#6
0
char MainMenuScreen_ToolBox_PhoneBook(char *msg)
{
	static struct MenuFuc_Language2 Menu[4]={
		{"1.浏览","1.Explorer",PhoneExplorer},
		{"2.查找","2.Search",PhoneSearch},
		{"3.增加","3.Add",PhoneAdd},
		{"4.全部删除","4.DeleteAll",PhoneDeleteAll},
	};
	struct MenuOperate_Language2 MenuOp={
		Menu,
		4,
		0,
		0,
		0,
		MaxRowOneScr,
		1,
		0,
		0
	};

	while(1){
		MenuHandler_Language2(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(msg);
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;}  
			else{clear_lcd();MenuOp.flashflag=1;}
		}else{
			CurProc=CurProc_Return;
			return MenuOp.RetVal;
		}
	}
}
示例#7
0
void main(void) {
    long op1, op2;   //32-bit operands
    char* ptr;       //pointer to keypad buffer
    char* blanks;
    char kbuf[12];   //keypad buffer
    char c, a;
    int i;
    ptr = kbuf;
    blanks = "      ";


    PLL_init();           //set system clock freq to 24MHz
    lcd_init();         //enable lcd
    keypad_enable();    //enable keypad
    set_lcd_addr(0x00); //display on 1st line
    i = 0;
    while(1) {
        c = getkey();     //read keypad
        a = hex2asc(c);   //convert to ascii
        kbuf[i] = a;      // and store in kbuf
        if(c<10) {        //if 0 - 9
            data8(a);      //   display on lcd
            wait_keyup();  //   wait to release key
            i++;           //increment index
        } else {
            switch(c) {
            case 0xE:   //if enter (*) key
                op1 = number(ptr);  //convert to binary
                set_lcd_addr(0x40); //display on 2nd line
                write_long_lcd(op1);
                set_lcd_addr(0x00); //clear 1st line
                type_lcd(blanks);
                wait_keyup();      //wait to release key
                i = 0;             //reset kbuf index
                set_lcd_addr(0x00); //display on 2nd line
                break;

            case 0xA:   //if key A
                op2 = number(ptr);  //convert to binary
                op1 = op1 + op2;    //compete sum
                set_lcd_addr(0x40); //display on 2nd line
                write_long_lcd(op1);
                set_lcd_addr(0x00);  //clear 1st line
                type_lcd(blanks);
                wait_keyup();        //wait to release key
                i = 0;               //reset kbuf index
                set_lcd_addr(0x00);  //display on 1st line
                break;
            case 0xF:   //if clear (#) key
                clear_lcd();  //clear lcd display
                wait_keyup(); //wait to release key
                i = 0;        //reset kbuf index
                break;
            default:
                break;
            }
        }
    }
}
示例#8
0
/******************************全部删除************************************/
static char PhoneDeleteAll(char *msg)
{
	char retval;

	clear_lcd();
	DrawTitle_to_row_Language2(2,"确定全部删除吗","Confirm Delete");
	retval=WaitkeyAndAutoExit(10);
	if(retval==KEY_Enter){
		//system("rm PhoneBook");
		EepromFile_Delete(file_phonebook);
		clear_lcd();
		DrawTitle_to_row_Language2(2,"删除成功","Deleted");
		retval=WaitkeyAndAutoExit(10);
	}

	return retval;
}
char WPManage(char *msg)
{
	unsigned char buff[40];
	unsigned char retval;
	abcABC123PYWuBiArgument argAa1;

	clear_lcd();
	strcpy((s8*)buff,(sc8*)WLANWP);
	DrawTitle_to_row_Language2(0,"¡¾µ±Ç°ÍøÂçÃÜÔ¿¡¿","Current Password");
	text_out_to_row_Language2(1,buff,buff);

	abcABC123PYWuBiArgDeInit(&argAa1,buff,30);
	argAa1.srfFlag=SRF_123|SRF_ABC|SRF_abc|SRF_PY|SRF_BiHua;
	argAa1.LocalTitle="¡¾ÊäÈëÍøÂçÃÜÔ¿¡¿";
	argAa1.OtherTitle="Input Password" ;
	argAa1.HaveoldFlag=1;
	retval=GetString_abcABC123PYWuBi2(&argAa1);
	if(retval!=KEY_Enter)return retval;

	
	if(strlen((sc8*)buff)>30)
	{
	    clear_lcd();
		DrawTitle_to_row_Language2(2,"´íÎó:ÃÜÔ¿³¤¶È²»¶Ô!","Password length error!");
	}
	else
	{
		memset(WLANWP,0,sizeof(WLANWP));
		strcpy((s8*)WLANWP,(sc8*)buff);
		if(!StorageVariable())
		{
		    clear_lcd();
			DrawTitle_to_row_Language2(2,"ʧ°Ü!","failure!");
			WaitkeyAndAutoExit(3);
			return KEY_ReturnPrevious;
		}
		else
	    {
			strcpy(rak_strapi.uPskFrame.psk,(char*)WLANWP);
			printf("rak_strapi.uPskFrame.psk:<%s>\r\n",rak_strapi.uPskFrame.psk);
        	if(rak_set_psk(&rak_strapi.uPskFrame)!=RUN_OK)return retval;
		}
	}
	return (WaitkeyAndAutoExit(1));
}
void write_int(int num) 
{
	idata char buf[32]; 
	char *pbuf = buf; 
	int bytes, cnt; 
	init_lcd(); 
	clear_lcd(); 
	bytes = 0;
	bytes += sprintf(buf + bytes, "U = %3.2f",5*(num/255.0));  
	for (cnt = 0; cnt < bytes; cnt++) 
	     write_char(pbuf++);
}
char DisplayVersion (char *msg)
{
	char buff[60];
	char buffother[60];
	strcpy (  buff,  VersionString);
	strcpy (  buffother,  VersionString);
	clear_lcd();
	DrawTitle_to_row_Language2 (0, "软件版本", "Software Ver");
	text_out_to_row_Language2 (1, (unsigned char*)buff, (unsigned char*)buffother);
	text_out_to_row_Language2 (2,(unsigned char*)VersionDate,(unsigned char*)VersionDate);
	text_out_to_row_Language2 (3, "硬件版本:20130809", "HardVer:20130809");
	text_out_to_row_Language2 (4, "备注:KMY801D3", "Mark:KMY801D3");
	return (WaitkeyAndAutoExit (15) );
}
void main(void) 
{ 
	idata char buf[64]; 
	char *pbuf = buf; 
	float f1 = 3.141592; 
	int bytes, cnt; 
	bytes = sprintf(buf, "%s", "PI == "); 
	bytes += sprintf(buf + bytes, "%8.6f\n", f1); 
	init_lcd(); 
	clear_lcd(); 
	for (cnt = 0; cnt < bytes; cnt++) 
	write_char(pbuf++); 
	while(1); 
} 
示例#13
0
void main(void)  
{
	idata char buf[16];
	idata char buf2[16];
	char *pbuf = buf;
	char *pbuf2 = buf2;
	float f1 = 3.141592;
	int bytes, cnt;
	int step1 = 0;
	int step2 = 0;
	while (1)
	{
		pbuf = buf;
		pbuf2 = buf2;
		bytes = sprintf(buf, "%s", "LABORATORY_WORK");
		init_lcd();
		clear_lcd();
		for (cnt = 0; cnt < step1; cnt++)
	    	write_char(' ');
		for (cnt = 0; cnt < bytes - step1; cnt++)
			write_char(pbuf++);
		step1 = step1 + 1;
		if (step1 > bytes - 1)
		{
			step1 = 0;
		}
		if (step1 > 2 * bytes - 1)
		{
			step1 = 0;
		}
		s_lcd();
		bytes = sprintf(buf2, "%s", "LSD_INFORMATION");
		for (cnt = 0; cnt < step2; cnt++)
	    	write_char(' '); 
		for (cnt = 0; cnt < bytes - step2; cnt++)
			write_char(pbuf2++);

		step2 = step2 + 1;

		if (step2 > bytes - 1)
		{
			step2 = 0;
		}

		//delay(100);
	}
	while(1);  
}
示例#14
0
 void addOper(char c, Flag *flag){
    if(flag->olock == false){ 
      flag->olock = true;
      clear_lcd(); //clear display, set cursor to 1st line
      //----------Add c to oper string-------------
      if(oidx > 0){
        strcat(oper, kbuf);
      oidx += kidx; 

      } 
      else{
       oidx = kidx;
       strcpy(oper, kbuf); 
      }
     oper[oidx++] = c;
     if(c == '-'){
       oper[oidx++] = ' ';
       flag->opback = 2;
     } 
     else
       flag->opback = 1;
     flag->nlock = false;
     flag->deci = false;
     kidx = 0; 
     //-----------------------------------------------
    } //end olock == false
    
    //----------------Replace Operator---------------
    else {
      oper[oidx-flag->opback] = c; //replace most recent operator with operator c
      if(flag->opback == 2) {  //opback = 2 means minus was last replaced   
        oper[--oidx] = '\0'; //get rid of the space added by the minus
        flag->opback = 1; //change opback back to 1
       }
      if(c == '-') { //if replacing with minus, add a space
        oper[oidx++] = ' ';
        flag->opback = 2; //opback becomes to since space added
      }  
    } //---------------------------------------------
    
    
    display(oper, oidx, 0x00);
    wait_keyup();  
  
 }
示例#15
0
static char PhoneHandleNameDelete(char *msg)
{
	char temp;

	#ifdef DEBUG_PRINTF
	printf("msg=%d\n",*msg);
	#endif

	temp=PhoneDeleteARecord(*msg);
	clear_lcd();
	if(temp==RIGHT_return){
		text_out_to_row_x_Language2(2,46,"已删除","Deleted");
	}else{
		text_out_to_row_x_Language2(2,40,"删除失败","Delete failure");
	}

	return (WaitkeyAndAutoExit(10));
}
示例#16
0
/************************************光标在手机处菜单**********************************************/
static char PhoneHandleCall(char *msg)
{
	u8 phonebuff[20];
	u8 atcmd[50];
	EFILE efile;
	struct phoneleixing *ph;

	ph=(struct phoneleixing *)msg;

	clear_lcd();
	/*fp=fopen("PhoneBook","rb");
	if(fp!=NULL){		//如果有记录,则先把记录读到phonebuff 。
	#ifdef DEBUG_PRINTF
	printf("open PhoneBook success!!\n");
	#endif
	}else{
	#ifdef DEBUG_PRINTF
	printf("open PhoneBook failure!!\n");
	#endif
	return KEY_ReturnPrevious;
	}*/
	phonebuff[0]=EepromFile_Open(file_phonebook,&efile);

	memset(phonebuff,0,sizeof(phonebuff));
	/*if(ph->leixin==0)fseek(fp,10+ph->numPhone*98+12,SEEK_SET);
	else fseek(fp,10+ph->numPhone*98+12+18,SEEK_SET);
	fread(phonebuff,18,1,fp);*/
	if(ph->leixin==0)EepromFile_Seek(&efile,10+ph->numPhone*98+12,EepromFile_SEEK_SET);
	else EepromFile_Seek(&efile,10+ph->numPhone*98+12+18,EepromFile_SEEK_SET);
	EepromFile_read(phonebuff,18,&efile);

	DrawTitle_to_row_Language2(2,"正在拨号...","Dialing...");
	strcpy((char *)atcmd,"ATD");
	strcat((char *)atcmd,(const char *)phonebuff);
	strcat((char *)atcmd,";\r");
	send_at_cmd(atcmd);
	//text_out_to_row_x_Language2(1,25,phonebuff,phonebuff);
	phonebuff[0]=Waitkey_TillKeyPress();

	send_at_cmd("ATH\r");

	return phonebuff[0];
}
示例#17
0
static char PhoneHandleSendmassage(char *msg)
{
	#if 1
	return(abeyant(NULL));
	#else
	char receive[60];

	GetString_abcABC123PYWuBi_Language2("短信输入","Msg input",SRF_123|SRF_BiHua|SRF_ABC|SRF_abc|SRF_PY,SRF_BiHua,receive,sizeof(receive),0);

	clear_lcd();
	DrawTitle_to_row_Language2(2,"正在发送短信","Sending message");
	if(SendMessage(receive,"15112475662")==Sim900B_ProccessOK){
		DrawTitle_to_row_Language2(3,"短信已成功发送","Sended");
	}else{
		DrawTitle_to_row_Language2(3,"短信发送失败","Send failure");
	}

	return WaitkeyAndAutoExit(10);
	#endif
}
示例#18
0
 void clrLine(int ln){
    char *blank = "                ";
    
    switch(ln) {
      
      case 1: //clear 1st line
        set_lcd_addr(0x00); //set cursor to 1st line 
        type_lcd(blank);
        break;
      case 2: //clear 2nd line
        set_lcd_addr(0x40); 
        type_lcd(blank); //set cursor to 2nd line
        break;
      default: //clear entire display
         clear_lcd(); 
         break;
    }
    
    //set_lcd_addr(curs); //set cursor to location curs
  
 }
void on_clear_button_clicked(GtkObject *object, gpointer user_data)
{
	int32_t error_code = ERR_NONE;

	if (0 > comm_init(com_port_name))
		error_code = ERR_PORT_INIT;

	if (ERR_NONE == error_code)
		error_code = send_password("WIFIBOT123");

	if (ERR_NONE == error_code)
		error_code = clear_lcd();

	if (ERR_NONE == error_code)
	{
		draw_lcd(wm->lcd_text, "");
	}

	comm_close();

	error_handler(wm->window, error_code);
}
示例#20
0
char set_apn (void)
{
	char Regist[200];
	char retval;
	char cnt = 0;

	clear_lcd();
	DrawTitle_to_row_Language2 (2, "正在设置APN", "Setting APN");
again:
	memset ( (char*) Regist, 0, sizeof (Regist) );
	strcat ( (char*) Regist, "AT+QICSGP=1,\"");
	strcat ( (char*) Regist, (char*) ApnApn);
	strcat ( (char*) Regist, "\",\"");
	strcat ( (char*) Regist, (char*) ApnUsername);
	strcat ( (char*) Regist, "\",\"");
	strcat ( (char*) Regist, (char*) ApnPassword);
	strcat ( (char*) Regist, "\"\r");
	retval = send_at_cmd_and_return ( (const unsigned char*) Regist, 3000, "OK", "ERROR");

	if (retval == TCP_OK)return retval;

	retval = GetKeyValue();

	if (retval == KEY_ReturnInitInterface || retval == KEY_ReturnPrevious) return TCP_ERROR;

	if (cnt++ > 7) return retval;

	retval = send_at_cmd_and_return ("AT+QIDEACT\r", 2000, "OK", "ERROR");

	if (retval == TCP_OK || retval == TCP_ERROR)
	{
		retval = WaitkeyAndAutoExit (3);

		if (retval == KEY_ReturnInitInterface || retval == KEY_ReturnPrevious) return TCP_ERROR;
	}

	goto again;
}
示例#21
0
static char PhoneHandleNumber(char *msg)
{
	static struct MenuFuc_Language2 Menu[5]={
		{"1.拨号","1.Dial number",PhoneHandleCall},		//注意:  第一个字符串的长度不能大于MaxByteOneLine-1
		{"2.发送短信","2.Send message",PhoneHandleSendmassage},
		{"3.发送彩信","3.Send color msg",PhoneHandleSendcolormassage},
		{"4.IP拨号","4.Ip Dial",PhoneHandleIPCall},
		{"5.设为拒接电话","5.Set refuse num",PhoneHandleSetRefuseNumber}
	};
	struct MenuOperate_Language2 MenuOp={
		Menu,
		5,
		0,
		0,
		0,
		MaxRowOneScr,
		1,
		0,
		0
	};


	//struct phoneleixing ph;
	//ph.leixin=0;
	//ph.numPhone=*msg;

	while(1){
		MenuHandler_Language2(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(msg);
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;}  
			else{clear_lcd();MenuOp.flashflag=1;}
		}else{
			return MenuOp.RetVal;
		}
	}
}
示例#22
0
/*********************************增加*************************************/
static char PhoneAdd(char *msg)
{
	static u8 PhoneNumber[18],PhoneName[12],PhoneZuoJi[18],PhoneEmail[20],PhoneBeiZhu[30],PhoneSave[5];

static struct FunctionMenuAddIco Menu[6]={
		{PhoneNameIco,	PhoneName,	PhoneNameSize,	PhoneAddName},
		{PhoneNumberIco,PhoneNumber,PhoneNumberSize,PhoneAddNumber},
		{PhoneZuoJiIco,	PhoneZuoJi,	PhoneZuoJiSize,	PhoneAddZuoJi},
		{PhoneEmailIco,	PhoneEmail,	PhoneEmailSize,	PhoneAddEmail},
		{PhoneBeiZhuIco,PhoneBeiZhu,PhoneBeiZhuSize,PhoneAddBeiZhu},
		{PhoneSaveIco,	PhoneSave,	PhoneSaveSize,	PhoneAddSave}
	}; 
	
	struct OperateAddIco MenuOp={Menu,6,0, 0,0,MaxRowOneScr, 1,0,0};

	char temp[25];
	
	if(Language[0]==LOCAL_LANGUAGE){
		strcpy((char *)PhoneNumber,(const char *)con_Chinese_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_Chinese_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_Chinese_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_Chinese_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_Chinese_PhoneBeiZhu);
		strcpy((char *)PhoneSave,(const char *)con_Chinese_PhoneSave);
	}
	else{
		strcpy((char *)PhoneNumber,(const char *)con_English_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_English_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_English_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_English_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_English_PhoneBeiZhu);
		strcpy((char *)PhoneSave,(const char *)con_English_PhoneSave);
	}

	while(1){
		MenuHandler_AddIco(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			if(MenuOp.Menucnt==MenuOp.MenuTotal-1){
				MenuOp.FucRetVal=MenuOp.Menu->MenuFuc((u8 *)Menu,0);
				return MenuOp.FucRetVal;
			}else{
				strcpy(temp,(sc8*)(MenuOp.Menu->MenuStr));
				memset(MenuOp.Menu->MenuStr,0,10);

				MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(MenuOp.Menu->MenuStr,MenuOp.Menu->size);

				if(strlen((sc8*)(MenuOp.Menu->MenuStr))==0){
					strcpy((s8*)(MenuOp.Menu->MenuStr),temp);
				}
			}
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;} 
			else{clear_lcd();MenuOp.flashflag=1;}
		}else{
			return MenuOp.RetVal;
		}
	}

	#undef PhoneNumber
	#undef PhoneName
	#undef PhoneZuoJi
	#undef PhoneEmail
	#undef PhoneBeiZhu
	#undef PhoneSave
}
示例#23
0
//static char PhoneSearch(char *msg)
char PhoneSearch(char *msg)
{
	EFILE efile;
	u8 receive[12];
	u8 tempbuff[50];
	u8 dispbuff[50];
	int i;
	struct OperateDisplay disp={0,0, 0,0,MaxRowOneScr ,1};
	unsigned char retval;
	unsigned char keyval;

	retval=GetString_abcABC123PYWuBi_Language2("【输入姓名】","Input name",SRF_PY|SRF_BiHua|SRF_abc|SRF_ABC|SRF_123,SRF_abc,receive,sizeof(receive),0);
	if(retval!=KEY_Enter)return retval;
	if(strlen((sc8*)receive)==0)goto tuichu;

	loop:
	clear_lcd();
	//fp=fopen("PhoneBook","rb");
	retval=EepromFile_Open(file_phonebook,&efile);
	retval=EepromFile_ReadData(tempbuff,10,file_phonebook);
	if(retval==EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		disp.MenuTotal=atoi((sc8*)tempbuff);
	}else{
		DrawTitle_to_row_Language2(2,"没有记录","No record");
		goto tuichu;
	}

	retval=EepromFile_Open(file_phonebook,&efile);
	for(i=0;i<disp.MenuTotal;i++){
		EepromFile_Seek(&efile,10+i*98,EepromFile_SEEK_SET);
		EepromFile_read(dispbuff,12,&efile);
		if(my_FFstrstr((sc8*)dispbuff,(sc8*)receive)==1){
			disp.Menucnt=i;
			if(disp.Menucnt<disp.EndLine-disp.StartLine){
				disp.curFlashRow+=disp.Menucnt;
			}else{
				disp.curFlashRow=disp.EndLine-1;
			}
			break;
		}
	}

	if(i>=disp.MenuTotal){DrawTitle_to_row_Language2(2,"找不到此记录","Can't find record");goto tuichu;}

	while(1){
		if(disp.flashflag){
			disp.flashflag=0;

			for(i=disp.StartLine;i<disp.EndLine&&i<disp.MenuTotal+disp.StartLine;i++){
				//fseek(fp,10+(disp.Menucnt-disp.curFlashRow+i)*98,SEEK_SET);
				//fread(dispbuff,12,1,fp);
				EepromFile_Seek(&efile,10+(disp.Menucnt-disp.curFlashRow+i)*98,EepromFile_SEEK_SET);
				EepromFile_read(dispbuff,12,&efile);
				steaddraw_pic_to_row_x(PhoneNameIco,0,i,12,12);
				text_out_to_row_x_fillSpace(i,16,dispbuff);
			}

			DispHighLightRow_to_x(16,disp.curFlashRow);			//高亮
		}

		keyval=GetKeyValue();
		if(keyval == KEY_NONE) continue;
		KeyEventPost();

		switch(keyval){ 
			case KEY_UP:
			my_OperateDisplay_KEY_UP(&disp);
			break;

			case KEY_DOWN:
			my_OperateDisplay_KEY_DOWN(&disp);
			break;

			case KEY_Enter:
			case KEY_RIGHT:
			if(HandlePhoneSelection(disp.Menucnt)==KEY_ReturnInitInterface){
				//fclose(fp);
				return KEY_ReturnInitInterface;
			}
			disp.flashflag=1;
			disp.curFlashRow=0;
			//fclose(fp);
			goto loop;

			case KEY_ReturnPrevious:
			case KEY_ReturnInitInterface:
			case KEY_WaitTimeout:
			//fclose(fp);
			return keyval;
		}

	}

	tuichu:
	WaitkeyAndAutoExit(10);
	return 0;
}
示例#24
0
static char PhoneExplorer(char *msg)
{
	EFILE efile;
	u8 dispbuff[50];
	int i;
	struct OperateDisplay disp={0,0, 0,0,MaxRowOneScr ,1};
	unsigned char keyval;

	loop:
	clear_lcd();
	keyval=EepromFile_ReadData(dispbuff,10,file_phonebook);
	if(keyval==EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		disp.MenuTotal=atoi((sc8*)dispbuff);
		if(disp.MenuTotal==0){
			text_out_to_row_x_Language2(40,2,"没有记录","No record");
			goto tuichu;
		}
	}else{
		text_out_to_row_x_Language2(2,40,"没有记录","No record");
		goto tuichu;
	}

	keyval=EepromFile_Open(file_phonebook,&efile);

	while(1){
		if(disp.flashflag){
			disp.flashflag=0;
			
			for(i=disp.StartLine;i<disp.EndLine&&i<disp.MenuTotal+disp.StartLine;i++){
				EepromFile_Seek(&efile,10+(disp.Menucnt-disp.curFlashRow+i)*98,EepromFile_SEEK_SET);
				EepromFile_read(dispbuff,12,&efile);
				steaddraw_pic_to_row_x(PhoneNameIco,0,i,12,12);
				text_out_to_row_x_fillSpace(i,16,dispbuff);
			}

			DispHighLightRow_to_x(16,disp.curFlashRow);			//高亮
		}

		keyval=GetKeyValue();
		if(keyval == KEY_NONE) continue;

		KeyEventPost();
		switch(keyval){ 
			case KEY_UP:
			my_OperateDisplay_KEY_UP(&disp);
			break;

			case KEY_DOWN:
			my_OperateDisplay_KEY_DOWN(&disp);
			break;

			case KEY_Enter:
			case KEY_RIGHT:
			if(HandlePhoneSelection(disp.Menucnt)==KEY_ReturnInitInterface){return KEY_ReturnInitInterface;}
			disp.flashflag=1;
			//fclose(fp);
			goto loop;

			case KEY_ReturnPrevious:
			case KEY_ReturnInitInterface:
			case KEY_WaitTimeout:
			//fclose(fp);
			return keyval;
		}

	}

	tuichu:
	return (WaitkeyAndAutoExit(10));
}
示例#25
0
/************************************记录详情**********************************************/
static char HandlePhoneSelection(char numPhone)
{
	static u8 PhoneNumber[18],PhoneName[12],PhoneZuoJi[18],PhoneEmail[20],PhoneBeiZhu[30];

	EFILE efile;
	char dispbuff[11];
	u8 retval;
	static struct FunctionMenuAddIco2 Menu[5]={
		{PhoneNameIco,	PhoneName,	PhoneHandleName},
		{PhoneNumberIco,PhoneNumber,PhoneHandleNumber},
		{PhoneZuoJiIco,	PhoneZuoJi,	PhoneHandleZuoJi},
		{PhoneEmailIco,	PhoneEmail,	PhoneHandleEmail},
		{PhoneBeiZhuIco,PhoneBeiZhu,PhoneHandleBeiZhu},
	};
	struct OperateAddIco2 MenuOp={Menu,5,0 ,0,0,MaxRowOneScr, 1,0,0};

	if(Language[0]==LOCAL_LANGUAGE){
		strcpy((char *)PhoneNumber,(const char *)con_Chinese_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_Chinese_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_Chinese_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_Chinese_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_Chinese_PhoneBeiZhu);
		//strcpy((char *)PhoneSave,(const char *)con_Chinese_PhoneSave);
	}
	else{
		strcpy((char *)PhoneNumber,(const char *)con_English_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_English_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_English_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_English_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_English_PhoneBeiZhu);
		//strcpy((char *)PhoneSave,(const char *)con_English_PhoneSave);
	}

	loop:
	retval=EepromFile_ReadData((unsigned char *)dispbuff,10,file_phonebook);
	if(retval!=EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		clear_lcd();
		text_out_to_row_x_Language2(2,40,"没有记录","No record");
		return WaitkeyAndAutoExit(10);
	}

	retval=EepromFile_Open(file_phonebook,&efile);

	EepromFile_Seek(&efile,10+numPhone*98,EepromFile_SEEK_SET);
	EepromFile_read(PhoneName,PhoneNameSize,&efile);
	EepromFile_read(PhoneNumber,PhoneNumberSize,&efile);
	EepromFile_read(PhoneZuoJi,PhoneZuoJiSize,&efile);
	EepromFile_read(PhoneEmail,PhoneEmailSize,&efile);
	EepromFile_read(PhoneBeiZhu,PhoneBeiZhuSize,&efile);

	while(1){
		MenuHandler_AddIco2(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(&numPhone);
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;}  
			else{
				clear_lcd();
				MenuOp.flashflag=1;
				goto loop;
			}
		}else{
			return MenuOp.RetVal;
		}
	}

	#undef PhoneNumber
	#undef PhoneName
	#undef PhoneZuoJi
	#undef PhoneEmail
	#undef PhoneBeiZhu
	//#undef PhoneSave
}
示例#26
0
void main(){
long int n;
int i; 
float ix = 0.0,duty, period;
char j, scale = 0x06;
char *msg1 = "Period(us):";
char *msg2 = "Duty(%):";
char *msg3 = "Not valid";
char *msg4 = "Displaying...";
char *msg5 = "Go again?";

lcd_init();

type_lcd(msg1);

              
  
n = 0;  
  
getperiod:
    i= getkey1();               		//get key from keypad
    delayms(10);
    
    if(i == 0x0A){              		//if i=A (enter key)
      clear_lcd();                  //clear lcd
      type_lcd(msg2);               //diplay duty message
      delayms(1000);                //diplay message for 1s
      period = n;                   //save period value
      n= 0;                         //reset n to be used for duty
      goto getduty;             		//get duty cycle
    }
    else if (i > 0x0A) {        		//if i not a valid input
      clear_lcd();                  //clear lcd
      type_lcd(msg3);            		//display error message
      delayms(1000);                //display for 1s
      n = 0;                        //reset n
      clear_lcd();
      type_lcd(msg1);
      goto getperiod;               //get period again
    } 
    
    if((n*10+i) > 1360){        		//if n exceeds limit
      clear_lcd();                  //clear lcd
      type_lcd(msg3);            		//display error message
      delayms(1000);                //display for 1s
      n = 0;                        //reset n
      clear_lcd();
      type_lcd(msg1);
      goto getperiod;               //get period again
     }     
    
          
    j= (char)i;                			//turn i into char
    j=j+0x30;                 			//convert hex to ASCII
    data8(j);               			  //display ASCII to LCD

    n = n*10 +i;               			//keep track of decimal value
    goto getperiod;              		//get another key



getduty:
    i= getkey1();               		//get key from keypad
    delayms(10);
    
    if(i == 0x0A){              		//if i=A (enter key)
      clear_lcd();                  //clear lcd
      duty = n;                     //save duty value
      n = 0;                        //reset n
      goto signal;             		  //output signal
    }
    else if (i > 0x0A) {        		//if i not a valid input
      clear_lcd();                  //clear lcd
      type_lcd(msg3);            		//display error message
      delayms(1000);                //display for 1s
      n = 0;                        //reset n
      clear_lcd();
      type_lcd(msg2);
      goto getduty;                 //get duty cycle again
    } 
    
    
    if((n*10+i) > 100){        		  //if n exceeds limit
      clear_lcd();                  //clear lcd
      type_lcd(msg3);            		//display error message
      delayms(1000);                //display for 1s
      n = 0;                        //reset n
      clear_lcd();
      type_lcd(msg2);
      goto getduty;                 //get duty again
     }       
    
    
          
    j= (char)i;                			//turn i into char
    j=j+0x30;                 			//convert hex to ASCII
    data8(j);               			  //display ASCII to LCD

    n = n*10 +i;               			//keep track of decimal value
    goto getduty;              			//get another key

signal:
     
                                    
     
    if(period < 10){
      period= period*24;		          //calculate count
      duty = duty/100;               //calculate duty
      duty = duty*period;
      scale = 0x00;
    }else if(period >680){
      period= period*24;		          //calculate count
     period = period/128;            //calculate count
     duty = duty/100;               //calculate duty
     duty = duty*period;
     scale = 0x07;  
    }else{
     period= period*24;		          //calculate count
     period = period/64;            //calculate count
     duty = duty/100;               //calculate duty
     duty = duty*period;            //calculate duty
     scale = 0x06;
    }
    
    PWMCLK = 0;                     //select clock A as source
    PWMPRCLK = scale;                //set clock A prescaler to 64
    PWMPOL = 1;                     //channel 9 output high at start
    PWMCAE = 0;                     //left-aligned mode
    PWMCTL = 0x0C;                  //8-bit mode, stop in wait and freeze mode
    PWMPER0 = period;               //set period value
    PWMDTY0 = duty;                 //set duty value
    PWME = 0x01;                    //enalbe PWM0 to output signal
  


  while (1){
    type_lcd(msg4);                 //displaying signal
    set_lcd_addr(0x40);
    type_lcd(msg5);                 //ask if want to create new waveform
    
    i= getkey1();               		//get key from keypad
    delayms(10);
    
    if(i == 0x0A){                  //if i=A (enter key)
      clear_lcd();                  //clear lcd
      type_lcd(msg1);               //diplay period message
      delayms(1000);                //diplay message for 1s
      n= 0;                         //reset n 
      goto getperiod;             	//get new period
    
    }else{
      clear_lcd();
    }
    
  
  }                      
}
示例#27
0
/************************************光标在姓名处菜单**********************************************/
static s8 PhoneHandleNameXiuGai(s8 *msg)
{
	static u8 PhoneNumber[18],PhoneName[12],PhoneZuoJi[18],PhoneEmail[20],PhoneBeiZhu[30],PhoneSave[5];
	char temp[50];
	int numPhone;
	EFILE efile;

	static struct FunctionMenuAddIco Menu[6]={
		{PhoneNameIco,	PhoneName,	PhoneNameSize,	PhoneAddName},
		{PhoneNumberIco,PhoneNumber,PhoneNumberSize,PhoneAddNumber},
		{PhoneZuoJiIco,	PhoneZuoJi,	PhoneZuoJiSize,	PhoneAddZuoJi},
		{PhoneEmailIco,	PhoneEmail,	PhoneEmailSize,	PhoneAddEmail},
		{PhoneBeiZhuIco,PhoneBeiZhu,PhoneBeiZhuSize,PhoneAddBeiZhu},
		{PhoneSaveIco,	PhoneSave,	PhoneSaveSize,	PhoneAddSave}
	};
	
	struct OperateAddIco MenuOp={Menu,6,0,0,0,MaxRowOneScr,1,0};

	if(Language[0]==LOCAL_LANGUAGE){
		strcpy((char *)PhoneNumber,(const char *)con_Chinese_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_Chinese_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_Chinese_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_Chinese_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_Chinese_PhoneBeiZhu);
		strcpy((char *)PhoneSave,(const char *)con_Chinese_PhoneSave);
	}
	else{
		strcpy((char *)PhoneNumber,(const char *)con_English_PhoneNumber);
		strcpy((char *)PhoneName,(const char *)con_English_PhoneName);
		strcpy((char *)PhoneZuoJi,(const char *)con_English_PhoneZuoJi);
		strcpy((char *)PhoneEmail,(const char *)con_English_PhoneEmail);
		strcpy((char *)PhoneBeiZhu,(const char *)con_English_PhoneBeiZhu);
		strcpy((char *)PhoneSave,(const char *)con_English_PhoneSave);
	}

	clear_lcd();
	temp[0]=EepromFile_ReadData((unsigned char *)temp,10,file_phonebook);
	if(temp[0]!=EepromFile_ReadOk){		//如果有记录,则先把记录读到phonebuff 。
		clear_lcd();
		text_out_to_row_x_Language2(2,40,"没有记录","No record");
		return KEY_ReturnPrevious;
	}

	EepromFile_Open(file_phonebook,&efile);
	numPhone=*msg;		//如果msg==NULL,则会引起segmentation  fault。
	EepromFile_Seek(&efile,10+numPhone*98,EepromFile_SEEK_SET);
	EepromFile_read(PhoneName,PhoneNameSize,&efile);
	EepromFile_read(PhoneNumber,PhoneNumberSize,&efile);
	EepromFile_read(PhoneZuoJi,PhoneZuoJiSize,&efile);
	EepromFile_read(PhoneEmail,PhoneEmailSize,&efile);
	EepromFile_read(PhoneBeiZhu,PhoneBeiZhuSize,&efile);

	while(1){
		MenuHandler_AddIco(&MenuOp);
		if(MenuOp.RetVal==KEY_Enter){
			if(MenuOp.Menucnt==MenuOp.MenuTotal-1){
				if(PhoneDeleteARecord(numPhone)==RIGHT_return){
					MenuOp.FucRetVal=MenuOp.Menu->MenuFuc((u8 *)Menu,0);
				}
				
				return MenuOp.FucRetVal;
			}else{
				strcpy(temp,(sc8*)(MenuOp.Menu->MenuStr));

				MenuOp.FucRetVal=MenuOp.Menu->MenuFuc(MenuOp.Menu->MenuStr,MenuOp.Menu->size);

				if(strlen((sc8*)(MenuOp.Menu->MenuStr))==0){
					strcpy((s8*)(MenuOp.Menu->MenuStr),temp);
				}
			}
			if(MenuOp.FucRetVal==KEY_WaitTimeout||MenuOp.FucRetVal==KEY_ReturnInitInterface){CurProc=CurProc_Return;return MenuOp.FucRetVal;} 
			else{clear_lcd();MenuOp.flashflag=1;}
		}else{
			return MenuOp.RetVal;
		}
	}

	#undef PhoneNumber
	#undef PhoneName
	#undef PhoneZuoJi
	#undef PhoneEmail
	#undef PhoneBeiZhu
	#undef PhoneSave
}
示例#28
0
void shiftMode(char key, Flag *flag){ 
   switch(key){
          case 0xA:  //if memory set (A) key - save number
            midx = kidx;
            strcpy(mem, kbuf); //copy data from kbuf to mem
            flag->save = true;
            led_on(1); //turn on 2nd led to indicate saved number
            wait_keyup(); 
            break;
            
          case 0xB: //if memory recall (B) key - get saved number
            if(flag->save == true){
              flag->olock = false;
              flag->nlock = true;
              strcpy(kbuf, mem);
              kidx = midx;
              //kbuf[kidx] = '\0';                     
              clrLine(2); //clear line 2
              display(kbuf, kidx,  0x40); 
              wait_keyup();    
            }
            break;
            
             
    
          case 0x1: //if plus '+' (1) key
            addOper('+', flag);
            break;
            
          case 0x2: //if minus '-' (2) key
            addOper('-', flag);
            break;
            
          case 0x3: //if mod '%' (3) key
            addOper('%', flag);
            break;
            
          case 0x4: //if multiply '*' (4) key
            addOper('*', flag);
            break;
          
          case 0x5: //if divide key '/' (5) key
            addOper('/', flag);
            break;
            
          case 0x6: //if power '^' (6) key
            addOper('^', flag);
            break;
          
          case 0x7: //if left parenthesis '('  (7) key
            if(flag->olock == true){         
              flag->leftpar += 1;
              kbuf[kidx++] = '(';
              display(kbuf,kidx, 0x40);
              wait_keyup();
            }

            break;
            
          case 0x8: //if right parenthesis ')' (8) key
            if(flag->leftpar>0 && flag->olock==false){ //if '(' present
              flag->leftpar -= 1;
              kbuf[kidx++] = ')';
              display(kbuf,kidx, 0x40);
              flag->nlock = true; //nlock = true to stop taking number inputs
              wait_keyup();
              
             } 
             break;
            
          case 0x9: //if factorial '!' (9) key
            addOper('!', flag);            
            break;
                  
          case 0xC:   //if clear (C) key
            flag->nlock = false;
            flag->olock = true;
            flag->deci = false;
            flag = createFlag();
            clear_lcd();

            kidx = 0;        //reset kbuf index
            kbuf[kidx] = '\0'; //clear kbuf
            oidx = 0;          //reset oper index
            oper[oidx] = '\0';  //clear oper
            substart = 0;
            set_lcd_addr(0x40);
            wait_keyup(); //wait to release key
            
            break;  
          
          
          case 0xD:  // if shift (D) key
            flag->shift = false;
            wait_keyup();  //wait to release key
            break;
          
          case 0xF:   //if equal (#) key
            clrLine(1);
            //--------------------
            if(oidx > 0){
              strcat(oper, kbuf);
              oidx += kidx; 

            } 
            else{
              oidx = kidx;
              strcpy(oper, kbuf); 
            }
            oper[oidx++] = ' ';
            flag->nlock = false;
            flag->deci = false;
            kidx = 0; 
            //-------------------

            --oidx; //remove space
            
            display(oper, oidx, 0x40);
            wait_keyup();
            break;
            
          case 0x0:
            break;
          default: break; 
        }  //end switch
 
 }
示例#29
0
int main(void){
    //SYSTEMConfigPerformance(10000000);
    int i;
    state = forward;    
    float Volts = 0.0;
    float VoltNew = 0.0;
    init_timer_1();
    enableInterrupts();
    init_lcd();
    clear_lcd();
    initPWM();
    char voltage[8];

    initADC();
    initMotor();
    
    

    
    while(1){
        while(IFS0bits.AD1IF == 0) {
        }
        val = ADC1BUF0;
        IFS0bits.AD1IF = 0;

        VoltNew = (float)val*5.0/(1023.0);
            Volts = VoltNew;
            sprintf(voltage, "%.2f",Volts);
            move_cursor_lcd(0,1);
        print_string_lcd(voltage);
        switch(state) {
            case forward:
                idle1 = 0;
                OC1RS = 0;
                OC2RS = 0;
                
                if (Volts > 2.5) {;
                    OC3RS = 1023;
                    OC4RS = (1- (Volts - 2.5)/2.5)*1023;   
                }    
                else if (Volts < 2.5) {
                    OC3RS = (1- (2.5 - Volts)/2.5)*1023;
                    OC4RS = 1023;   
                }    
                else {
                    OC3RS = 1023;
                    OC4RS = 1023;
                }
                stateNext = back;
            break;
            case back:
                idle1 = 0;
                OC3RS = 0;
                OC4RS = 0;
                
                if (Volts > 2.5) {;
                    OC1RS = 1023;
                    OC2RS = (1- (Volts - 2.5)/2.5)*1023;   
                }    
                else if (Volts < 2.5) {
                    OC1RS = (1- (2.5 - Volts)/2.5)*1023;
                    OC2RS = 1023;   
                }    
                else {
                    OC1RS = 1023;
                    OC2RS = 1023;
                }
                stateNext = forward;
                
            break;
            case idle:
                OC1RS = 0;
                OC2RS = 0;
                OC3RS = 0;
                OC4RS = 0;
                idle1 = 1;
                break;
            case debounce1:
                delay_ms(40);
                break;
            case debounce2:
                delay_ms(40);
                if(idle1 == 1)
                state = stateNext;
                else if (idle1 == 0)
                    state = idle;
                break;
        }

    }
    
    return 0;
}
示例#30
0
//按拼音排序保存一个记录
static u8 PhoneAddSave(u8 *receive,u16 size)
{
	char phonebuff[4096],*pphonebuff,*endphonebuff;
	char bufftemp[100];
	struct FunctionMenuAddIco *MenuPhoneAdd;
	int num;
	int i;

	clear_lcd();
	DrawTitle_to_row_Language2(2,"正在保存...","saving...");
	MenuPhoneAdd=(struct FunctionMenuAddIco *)receive;

	EepromFile_ReadData((unsigned char *)phonebuff,sizeof(phonebuff)-1,file_phonebook);

	pphonebuff=phonebuff;
	memset(bufftemp,0,sizeof(bufftemp));
	memcpy(bufftemp,pphonebuff,10);
	pphonebuff+=10;
	num=atoi((sc8*)bufftemp);
	endphonebuff=pphonebuff+num*98;	//endphonebuff  指向最后一条记录后面的空白处
	if(endphonebuff>&phonebuff[sizeof(phonebuff)-200]){
		text_out_to_row_x_Language2(3,40,"电话本已满","Phone book full");
		goto tuichu;
	}

	memset(bufftemp,0,50);	//按拼音次序找到要写入记录的位置
	for(i=0;i<num;i++){
		memcpy(bufftemp,pphonebuff,12);
		if(strcmp(bufftemp,(sc8*)MenuPhoneAdd->MenuStr)>0)break;
		pphonebuff+=98;
	}

	while(endphonebuff>pphonebuff){		//把要写入记录位置处的所有记录向后移一个记录的位置
		memcpy(bufftemp,endphonebuff-98,98);
		memcpy(endphonebuff,bufftemp,98);
		endphonebuff-=98;
	}

	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,12);	//读入要写入记录的信息
	MenuPhoneAdd++;pphonebuff+=12;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,18);
	MenuPhoneAdd++;pphonebuff+=18;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,18);
	MenuPhoneAdd++;pphonebuff+=18;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,20);
	MenuPhoneAdd++;pphonebuff+=20;
	memcpy(pphonebuff,MenuPhoneAdd->MenuStr,30);

	num++;
	memset(bufftemp,0,10);
	sprintf(bufftemp,"%d",num);
	memcpy(phonebuff,bufftemp,10);

	i=EepromFile_WriteData((unsigned char*)phonebuff,num*99+100,file_phonebook);
	if(i==EepromFile_WriteOk){
		DrawTitle_to_row_Language2(3,"电话记录保存成功","save success");
	}else{
		DrawTitle_to_row_Language2(3,"电话记录保存失败","save failure");
	}

	tuichu:
	return (WaitkeyAndAutoExit(10));
}