ds

本文介绍了一个用于处理HTTP响应并返回XML消息的方法,同时提供了一种将请求参数映射到字符串的方法。通过示例代码展示了如何设置HTTP响应的内容类型、编码方式,并将Java对象转换为XML格式进行返回。

1.使用findBug

2.public static void returnHttpMsg(HttpServletResponse response, Object bean)

{

   PrintWriter out = null;

   try{

      LogManager.appendBiz_before_change("http");

String xml = XmlBeanServer.beanToXml(bean);

System.out.print(xml);

response.setCharacterEncoding("GBK");

out = response.getWriter();

out.write(xml);

out.flush();

  }catch (IOException e){

e.printStackTrace();

}

finally{

 if (null !=out){

   out.close();

}

}

 

}

public static Map<String,String> parseParameters(Map<String,String[]> paramMap){

  Map<String,String> resultMap = new HashMap<String,String>();

if (paramMap != null){

  StringBuilder buffer = new StringBuilder(32);

 String[] values;

for(Entry<String,String[]> entry :paramMap.entrySet()){

  values = entry.getValue();

 if (values != null && values.length>0){

    for (int i=0;i<values.length;i++){

      buffer.append(values[i].append(',');

    }

  }

  resultMap.put(entry.getKey(),buffer.substring(0,buffer.length()>0?buffer.length()-1:0));

buffer.delete(0,buffer.length());

}

}

return resultMap;

#include <REGX52.H> #include"LCD1602.h" #include"DS1302.h" #include"Key.h" #include"timer0.h" unsigned char KeyNumble,MOOE,TimeSetSelect,TimeSetFlashFlag; void Timeshow()//ʱ¼äÏÔʾ { DS1302_ReadTime();//¶Áȡʱ¼ä LCD_ShowNum(1,1,DS1302_Time[0],2);//ÏÔʾÄê LCD_ShowNum(1,4,DS1302_Time[1],2);//ÏÔʾÔ LCD_ShowNum(1,7,DS1302_Time[2],2);//ÏÔʾÈÕ LCD_ShowNum(2,1,DS1302_Time[3],2);//ÏÔʾʱ LCD_ShowNum(2,4,DS1302_Time[4],2);//ÏÔʾ·Ö LCD_ShowNum(2,7,DS1302_Time[5],2);//ÏÔʾÃë } void TimeSet()//ʱ¼äÉèÖù¦ÄÜ { if(KeyNumble==2)//°´¼ü2°´Ï { TimeSetSelect++;//ÉèÖÃÑ¡Ôñλ+1 TimeSetSelect%=6;//Ô½½çÇåÁ㣨0-5£© } if(KeyNumble==3)//°´¼ü3°´Ï { DS1302_Time[TimeSetSelect]++;//ʱ¼äÉèÖÃλÊýÖµ¼ÓÒ» if(DS1302_Time[0]>99){DS1302_Time[0]=0;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]>12){DS1302_Time[1]=1;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]>23){DS1302_Time[3]=0;}//ʱԽ½ç if(DS1302_Time[4]>59){DS1302_Time[4]=0;}//·ÖÔ½½ç if(DS1302_Time[5]>59){DS1302_Time[5]=0;}//ÃëÔ½½ç } if(KeyNumble==4)//°´¼ü4°´Ï { DS1302_Time[TimeSetSelect]--;//ʱ¼äÉèÖÃÊýÖµ¼õÒ» if(DS1302_Time[0]<0){DS1302_Time[0]=99;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]<1){DS1302_Time[1]=12;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]<1)DS1302_Time[2]=31; else if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]<1)DS1302_Time[2]=30; else if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]<1)DS1302_Time[2]=29; else if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]<1)DS1302_Time[2]=28; else if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]<0){DS1302_Time[3]=23;}//ʱԽ½ç if(DS1302_Time[4]<0){DS1302_Time[4]=59;}//·ÖÔ½½ç if(DS1302_Time[5]<0){DS1302_Time[5]=59;}//ÃëÔ½½ç } //¸üÐÂÏÔʾ£¬¸ù¾ÝTimeSetSelect,TimeSetFlashFlag¿ÉÍê³ÉÉÁ˸¹¦ÄÜ if(TimeSetSelect==0&&TimeSetFlashFlag==1){LCD_ShowString(1,1," ");} else{LCD_ShowNum(1,1,DS1302_Time[0],2);} if(TimeSetSelect==1&&TimeSetFlashFlag==1){LCD_ShowString(1,4," ");} else{LCD_ShowNum(1,4,DS1302_Time[1],2);} if(TimeSetSelect==2&&TimeSetFlashFlag==1){LCD_ShowString(1,7," ");} else{LCD_ShowNum(1,7,DS1302_Time[2],2);} if(TimeSetSelect==3&&TimeSetFlashFlag==1){LCD_ShowString(2,1," ");} else{LCD_ShowNum(2,1,DS1302_Time[3],2);} if(TimeSetSelect==4&&TimeSetFlashFlag==1){LCD_ShowString(2,4," ");} else{LCD_ShowNum(2,4,DS1302_Time[4],2);} if(TimeSetSelect==5&&TimeSetFlashFlag==1){LCD_ShowString(2,7," ");} else{LCD_ShowNum(2,7,DS1302_Time[5],2);} } void main() { LCD_Init();//LCD³õʼ»¯ DS1302_Init();//DS1302³õʼ»¯ Timer0Init(); LCD_ShowString(1,1," - - ");//¾²Ì¬×Ö·ûÏÔʾ LCD_ShowString(2,1," : : "); DS1302_SetTime();//ÉèÖÃʱ¼ä while(1) { KeyNumble=Key();//¶ÁÈ¡¼üÂë if(KeyNumble==1)//°´¼ü1°´Ï { if(MOOE==0){MOOE=1;TimeSetSelect=0;}//¹¦ÄÜÇл» else if(MOOE==1){MOOE=0;DS1302_SetTime();} } switch(MOOE)//¸ù¾Ý²»Í¬µÄ¹¦ÄÜÖ´Ðв»Í¬µÄº¯Êý { case 0:TimeShow();break; case 1:TimeSet();break; } } } void Timer0_Routine() interrupt 1//ÖжϺ¯Êý { static unsigned int T0Count; TL0 = 0x18; //ÉèÖö¨Ê±Æ÷³õÖµ TH0 = 0xFC; //ÉèÖö¨Ê±Æ÷³õÖµ T0Count++; if(T0Count>=500) { T0Count=0; TimeSetFlashFlag=!TimeSetFlashFlag;//ÉÁ˸λȡ·´ } }#include <REGX52.H> #include"LCD1602.h" #include"DS1302.h" #include"Key.h" #include"timer0.h" unsigned char KeyNumble,MOOE,TimeSetSelect,TimeSetFlashFlag; void Timeshow()//ʱ¼äÏÔʾ { DS1302_ReadTime();//¶Áȡʱ¼ä LCD_ShowNum(1,1,DS1302_Time[0],2);//ÏÔʾÄê LCD_ShowNum(1,4,DS1302_Time[1],2);//ÏÔʾÔ LCD_ShowNum(1,7,DS1302_Time[2],2);//ÏÔʾÈÕ LCD_ShowNum(2,1,DS1302_Time[3],2);//ÏÔʾʱ LCD_ShowNum(2,4,DS1302_Time[4],2);//ÏÔʾ·Ö LCD_ShowNum(2,7,DS1302_Time[5],2);//ÏÔʾÃë } void TimeSet()//ʱ¼äÉèÖù¦ÄÜ { if(KeyNumble==2)//°´¼ü2°´Ï { TimeSetSelect++;//ÉèÖÃÑ¡Ôñλ+1 TimeSetSelect%=6;//Ô½½çÇåÁ㣨0-5£© } if(KeyNumble==3)//°´¼ü3°´Ï { DS1302_Time[TimeSetSelect]++;//ʱ¼äÉèÖÃλÊýÖµ¼ÓÒ» if(DS1302_Time[0]>99){DS1302_Time[0]=0;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]>12){DS1302_Time[1]=1;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]>23){DS1302_Time[3]=0;}//ʱԽ½ç if(DS1302_Time[4]>59){DS1302_Time[4]=0;}//·ÖÔ½½ç if(DS1302_Time[5]>59){DS1302_Time[5]=0;}//ÃëÔ½½ç } if(KeyNumble==4)//°´¼ü4°´Ï { DS1302_Time[TimeSetSelect]--;//ʱ¼äÉèÖÃÊýÖµ¼õÒ» if(DS1302_Time[0]<0){DS1302_Time[0]=99;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]<1){DS1302_Time[1]=12;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]<1)DS1302_Time[2]=31; else if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]<1)DS1302_Time[2]=30; else if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]<1)DS1302_Time[2]=29; else if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]<1)DS1302_Time[2]=28; else if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]<0){DS1302_Time[3]=23;}//ʱԽ½ç if(DS1302_Time[4]<0){DS1302_Time[4]=59;}//·ÖÔ½½ç if(DS1302_Time[5]<0){DS1302_Time[5]=59;}//ÃëÔ½½ç } //¸üÐÂÏÔʾ£¬¸ù¾ÝTimeSetSelect,TimeSetFlashFlag¿ÉÍê³ÉÉÁ˸¹¦ÄÜ if(TimeSetSelect==0&&TimeSetFlashFlag==1){LCD_ShowString(1,1," ");} else{LCD_ShowNum(1,1,DS1302_Time[0],2);} if(TimeSetSelect==1&&TimeSetFlashFlag==1){LCD_ShowString(1,4," ");} else{LCD_ShowNum(1,4,DS1302_Time[1],2);} if(TimeSetSelect==2&&TimeSetFlashFlag==1){LCD_ShowString(1,7," ");} else{LCD_ShowNum(1,7,DS1302_Time[2],2);} if(TimeSetSelect==3&&TimeSetFlashFlag==1){LCD_ShowString(2,1," ");} else{LCD_ShowNum(2,1,DS1302_Time[3],2);} if(TimeSetSelect==4&&TimeSetFlashFlag==1){LCD_ShowString(2,4," ");} else{LCD_ShowNum(2,4,DS1302_Time[4],2);} if(TimeSetSelect==5&&TimeSetFlashFlag==1){LCD_ShowString(2,7," ");} else{LCD_ShowNum(2,7,DS1302_Time[5],2);} } void main() { LCD_Init();//LCD³õʼ»¯ DS1302_Init();//DS1302³õʼ»¯ Timer0Init(); LCD_ShowString(1,1," - - ");//¾²Ì¬×Ö·ûÏÔʾ LCD_ShowString(2,1," : : "); DS1302_SetTime();//ÉèÖÃʱ¼ä while(1) { KeyNumble=Key();//¶ÁÈ¡¼üÂë if(KeyNumble==1)//°´¼ü1°´Ï { if(MOOE==0){MOOE=1;TimeSetSelect=0;}//¹¦ÄÜÇл» else if(MOOE==1){MOOE=0;DS1302_SetTime();} } switch(MOOE)//¸ù¾Ý²»Í¬µÄ¹¦ÄÜÖ´Ðв»Í¬µÄº¯Êý { case 0:TimeShow();break; case 1:TimeSet();break; } } } void Timer0_Routine() interrupt 1//ÖжϺ¯Êý { static unsigned int T0Count; TL0 = 0x18; //ÉèÖö¨Ê±Æ÷³õÖµ TH0 = 0xFC; //ÉèÖö¨Ê±Æ÷³õÖµ T0Count++; if(T0Count>=500) { T0Count=0; TimeSetFlashFlag=!TimeSetFlashFlag;//ÉÁ˸λȡ·´ } }#include <REGX52.H> #include"LCD1602.h" #include"DS1302.h" #include"Key.h" #include"timer0.h" unsigned char KeyNumble,MOOE,TimeSetSelect,TimeSetFlashFlag; void Timeshow()//ʱ¼äÏÔʾ { DS1302_ReadTime();//¶Áȡʱ¼ä LCD_ShowNum(1,1,DS1302_Time[0],2);//ÏÔʾÄê LCD_ShowNum(1,4,DS1302_Time[1],2);//ÏÔʾÔ LCD_ShowNum(1,7,DS1302_Time[2],2);//ÏÔʾÈÕ LCD_ShowNum(2,1,DS1302_Time[3],2);//ÏÔʾʱ LCD_ShowNum(2,4,DS1302_Time[4],2);//ÏÔʾ·Ö LCD_ShowNum(2,7,DS1302_Time[5],2);//ÏÔʾÃë } void TimeSet()//ʱ¼äÉèÖù¦ÄÜ { if(KeyNumble==2)//°´¼ü2°´Ï { TimeSetSelect++;//ÉèÖÃÑ¡Ôñλ+1 TimeSetSelect%=6;//Ô½½çÇåÁ㣨0-5£© } if(KeyNumble==3)//°´¼ü3°´Ï { DS1302_Time[TimeSetSelect]++;//ʱ¼äÉèÖÃλÊýÖµ¼ÓÒ» if(DS1302_Time[0]>99){DS1302_Time[0]=0;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]>12){DS1302_Time[1]=1;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]>23){DS1302_Time[3]=0;}//ʱԽ½ç if(DS1302_Time[4]>59){DS1302_Time[4]=0;}//·ÖÔ½½ç if(DS1302_Time[5]>59){DS1302_Time[5]=0;}//ÃëÔ½½ç } if(KeyNumble==4)//°´¼ü4°´Ï { DS1302_Time[TimeSetSelect]--;//ʱ¼äÉèÖÃÊýÖµ¼õÒ» if(DS1302_Time[0]<0){DS1302_Time[0]=99;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]<1){DS1302_Time[1]=12;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]<1)DS1302_Time[2]=31; else if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]<1)DS1302_Time[2]=30; else if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]<1)DS1302_Time[2]=29; else if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]<1)DS1302_Time[2]=28; else if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]<0){DS1302_Time[3]=23;}//ʱԽ½ç if(DS1302_Time[4]<0){DS1302_Time[4]=59;}//·ÖÔ½½ç if(DS1302_Time[5]<0){DS1302_Time[5]=59;}//ÃëÔ½½ç } //¸üÐÂÏÔʾ£¬¸ù¾ÝTimeSetSelect,TimeSetFlashFlag¿ÉÍê³ÉÉÁ˸¹¦ÄÜ if(TimeSetSelect==0&&TimeSetFlashFlag==1){LCD_ShowString(1,1," ");} else{LCD_ShowNum(1,1,DS1302_Time[0],2);} if(TimeSetSelect==1&&TimeSetFlashFlag==1){LCD_ShowString(1,4," ");} else{LCD_ShowNum(1,4,DS1302_Time[1],2);} if(TimeSetSelect==2&&TimeSetFlashFlag==1){LCD_ShowString(1,7," ");} else{LCD_ShowNum(1,7,DS1302_Time[2],2);} if(TimeSetSelect==3&&TimeSetFlashFlag==1){LCD_ShowString(2,1," ");} else{LCD_ShowNum(2,1,DS1302_Time[3],2);} if(TimeSetSelect==4&&TimeSetFlashFlag==1){LCD_ShowString(2,4," ");} else{LCD_ShowNum(2,4,DS1302_Time[4],2);} if(TimeSetSelect==5&&TimeSetFlashFlag==1){LCD_ShowString(2,7," ");} else{LCD_ShowNum(2,7,DS1302_Time[5],2);} } void main() { LCD_Init();//LCD³õʼ»¯ DS1302_Init();//DS1302³õʼ»¯ Timer0Init(); LCD_ShowString(1,1," - - ");//¾²Ì¬×Ö·ûÏÔʾ LCD_ShowString(2,1," : : "); DS1302_SetTime();//ÉèÖÃʱ¼ä while(1) { KeyNumble=Key();//¶ÁÈ¡¼üÂë if(KeyNumble==1)//°´¼ü1°´Ï { if(MOOE==0){MOOE=1;TimeSetSelect=0;}//¹¦ÄÜÇл» else if(MOOE==1){MOOE=0;DS1302_SetTime();} } switch(MOOE)//¸ù¾Ý²»Í¬µÄ¹¦ÄÜÖ´Ðв»Í¬µÄº¯Êý { case 0:TimeShow();break; case 1:TimeSet();break; } } } void Timer0_Routine() interrupt 1//ÖжϺ¯Êý { static unsigned int T0Count; TL0 = 0x18; //ÉèÖö¨Ê±Æ÷³õÖµ TH0 = 0xFC; //ÉèÖö¨Ê±Æ÷³õÖµ T0Count++; if(T0Count>=500) { T0Count=0; TimeSetFlashFlag=!TimeSetFlashFlag;//ÉÁ˸λȡ·´ } }#include <REGX52.H> #include"LCD1602.h" #include"DS1302.h" #include"Key.h" #include"timer0.h" unsigned char KeyNumble,MOOE,TimeSetSelect,TimeSetFlashFlag; void Timeshow()//ʱ¼äÏÔʾ { DS1302_ReadTime();//¶Áȡʱ¼ä LCD_ShowNum(1,1,DS1302_Time[0],2);//ÏÔʾÄê LCD_ShowNum(1,4,DS1302_Time[1],2);//ÏÔʾÔ LCD_ShowNum(1,7,DS1302_Time[2],2);//ÏÔʾÈÕ LCD_ShowNum(2,1,DS1302_Time[3],2);//ÏÔʾʱ LCD_ShowNum(2,4,DS1302_Time[4],2);//ÏÔʾ·Ö LCD_ShowNum(2,7,DS1302_Time[5],2);//ÏÔʾÃë } void TimeSet()//ʱ¼äÉèÖù¦ÄÜ { if(KeyNumble==2)//°´¼ü2°´Ï { TimeSetSelect++;//ÉèÖÃÑ¡Ôñλ+1 TimeSetSelect%=6;//Ô½½çÇåÁ㣨0-5£© } if(KeyNumble==3)//°´¼ü3°´Ï { DS1302_Time[TimeSetSelect]++;//ʱ¼äÉèÖÃλÊýÖµ¼ÓÒ» if(DS1302_Time[0]>99){DS1302_Time[0]=0;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]>12){DS1302_Time[1]=1;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]>23){DS1302_Time[3]=0;}//ʱԽ½ç if(DS1302_Time[4]>59){DS1302_Time[4]=0;}//·ÖÔ½½ç if(DS1302_Time[5]>59){DS1302_Time[5]=0;}//ÃëÔ½½ç } if(KeyNumble==4)//°´¼ü4°´Ï { DS1302_Time[TimeSetSelect]--;//ʱ¼äÉèÖÃÊýÖµ¼õÒ» if(DS1302_Time[0]<0){DS1302_Time[0]=99;}//ÄêÔ½½çÅÐ¶Ï if(DS1302_Time[1]<1){DS1302_Time[1]=12;}//ÔÂÔ½½çÅÐ¶Ï if(DS1302_Time[1]==1||DS1302_Time[1]==3|| DS1302_Time[1]==5||DS1302_Time[1]==7|| DS1302_Time[1]==8||DS1302_Time[1]==10|| DS1302_Time[1]==12){if(DS1302_Time[2]<1)DS1302_Time[2]=31; else if(DS1302_Time[2]>31)DS1302_Time[2]=1;} if(DS1302_Time[1]==4||DS1302_Time[1]==6||DS1302_Time[1]==9||DS1302_Time[1]==11) {if(DS1302_Time[2]<1)DS1302_Time[2]=30; else if(DS1302_Time[2]>30)DS1302_Time[2]=1;} else if(DS1302_Time[1]==2) if(DS1302_Time[0]%4==0) {if(DS1302_Time[2]<1)DS1302_Time[2]=29; else if(DS1302_Time[2]>29)DS1302_Time[2]=1;}//ÈòÄêÔ½½ç else {if(DS1302_Time[2]<1)DS1302_Time[2]=28; else if(DS1302_Time[2]>28)DS1302_Time[2]=1;}//ƽÄêÔ½½ç if(DS1302_Time[3]<0){DS1302_Time[3]=23;}//ʱԽ½ç if(DS1302_Time[4]<0){DS1302_Time[4]=59;}//·ÖÔ½½ç if(DS1302_Time[5]<0){DS1302_Time[5]=59;}//ÃëÔ½½ç } //¸üÐÂÏÔʾ£¬¸ù¾ÝTimeSetSelect,TimeSetFlashFlag¿ÉÍê³ÉÉÁ˸¹¦ÄÜ if(TimeSetSelect==0&&TimeSetFlashFlag==1){LCD_ShowString(1,1," ");} else{LCD_ShowNum(1,1,DS1302_Time[0],2);} if(TimeSetSelect==1&&TimeSetFlashFlag==1){LCD_ShowString(1,4," ");} else{LCD_ShowNum(1,4,DS1302_Time[1],2);} if(TimeSetSelect==2&&TimeSetFlashFlag==1){LCD_ShowString(1,7," ");} else{LCD_ShowNum(1,7,DS1302_Time[2],2);} if(TimeSetSelect==3&&TimeSetFlashFlag==1){LCD_ShowString(2,1," ");} else{LCD_ShowNum(2,1,DS1302_Time[3],2);} if(TimeSetSelect==4&&TimeSetFlashFlag==1){LCD_ShowString(2,4," ");} else{LCD_ShowNum(2,4,DS1302_Time[4],2);} if(TimeSetSelect==5&&TimeSetFlashFlag==1){LCD_ShowString(2,7," ");} else{LCD_ShowNum(2,7,DS1302_Time[5],2);} } void main() { LCD_Init();//LCD³õʼ»¯ DS1302_Init();//DS1302³õʼ»¯ Timer0Init(); LCD_ShowString(1,1," - - ");//¾²Ì¬×Ö·ûÏÔʾ LCD_ShowString(2,1," : : "); DS1302_SetTime();//ÉèÖÃʱ¼ä while(1) { KeyNumble=Key();//¶ÁÈ¡¼üÂë if(KeyNumble==1)//°´¼ü1°´Ï { if(MOOE==0){MOOE=1;TimeSetSelect=0;}//¹¦ÄÜÇл» else if(MOOE==1){MOOE=0;DS1302_SetTime();} } switch(MOOE)//¸ù¾Ý²»Í¬µÄ¹¦ÄÜÖ´Ðв»Í¬µÄº¯Êý { case 0:TimeShow();break; case 1:TimeSet();break; } } } void Timer0_Routine() interrupt 1//ÖжϺ¯Êý { static unsigned int T0Count; TL0 = 0x18; //ÉèÖö¨Ê±Æ÷³õÖµ TH0 = 0xFC; //ÉèÖö¨Ê±Æ÷³õÖµ T0Count++; if(T0Count>=500) { T0Count=0; TimeSetFlashFlag=!TimeSetFlashFlag;//ÉÁ˸λȡ·´ } }检查问题
07-28
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值