辜渝傧

13037102709

027-87870986

教学实训

您当前的位置:首页 > 教学资源 > 实训方案 >

RFID实训|公交刷卡系统程序源码

发布者:唯众    布时间:2020-12-03 14:30:57    点击量:

2.3项目实现

#include "gongjiao.h"
#define menjin11356ADDR   1024*1014*12 //从最后10K字节开始写起
#define GONGJIAO_EX_BACKCOLOR       0X0000                       //窗体外部背景色
#define GONGJIAO_IN_BACKCOLOR       0X8C51                       //窗体内部背景色
#define GONGJIAO_NAME_COLOR                   0X001F                        //程序名颜色
#define GONGJIAO_ALPHA_VAL             18                               //APP选中透明度设置
#define GONGJIAO_ALPHA_COLOR                  WHITE                        //APP透明色
 
u8 Send[40];
u8 M1[40]={'#',0,0,0,0,0,0,0,0,0,0,13,0,'B','R',4,0XFF,0XFF,0XFF,0XFF,0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0,  0,  0,  0, 0,  0,  0,0,0,'$'};
u8 CardNum_1356[50];
//应用程序名列表
//这里列表为16个,名字长度不要超过8个字节(4个汉字)
u8* const gongjiao_appname_tbl[3][16]=
{
{
         "充值办卡","刷卡消费","发卡","充值",
         "返回","清卡","应用程序","应用程序",
         "应用程序","应用程序","应用程序","应用程序",
         "应用程序","应用程序","应用程序","应用程序",
},
{
         " "," ","應用程序","應用程序",
         "應用程序","應用程序","應用程序","應用程序",
         "應用程序","應用程序","應用程序","應用程序",
         "應用程序","應用程序","應用程序","應用程序",
},
{
         " "," ","APP","APP",
         "APP","APP","APP","APP",
         "APP","APP","APP","APP",  
         "APP","APP","APP","APP",
},
};
 
//appplay的图标路径表
u8* const gongjiao_icospath_tbl[3][16]=
{
{
"1:/SYSTEM/APP/APPS/ICOS/remote_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/3d_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/facerec_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app01_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app02_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app03_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app04_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app05_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app06_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app07_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app08_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app09_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app10_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app11_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app12_48.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app13_48.bmp",
},
 
{
"1:/SYSTEM/APP/APPS/ICOS/remote_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/3d_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/facerec_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app01_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app02_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app03_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app04_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app05_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app06_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app07_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app08_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app09_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app10_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app11_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app12_60.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app13_60.bmp",
},
{
"1:/SYSTEM/APP/APPS/ICOS/app02_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app07_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/facerec_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app01_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app02_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app03_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app04_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app05_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app06_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app07_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app08_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app09_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app10_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app11_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app12_90.bmp",
"1:/SYSTEM/APP/APPS/ICOS/app13_90.bmp",
},
};
 
//加载主界面
//返回值:0,成功;其他,失败;
u8 gongjiao_load_ui(m_app_dev *appdev)
{
         u8 i;
         u8 xdis,ydis;
         u8 wxoff,wyoff;
         u8 width,height;
         u8 icowidth;
         u8 icofsize;
         u8 dis;
         u8 lcdtype=0;
        
         u8 rval=0;
        _window_obj* twin=0;   //窗体
         if(lcddev.width==240)
         {
                   wxoff=4;
                   wyoff=4;
                   xdis=4;
                   ydis=5;
                   icowidth=48;
                   icofsize=12;
                   width=48+3*2;
                   height=48+12+3*2+2;
                   lcdtype=0;
         }else if(lcddev.width==320)
         {
                   wxoff=8;
                   wyoff=8;
                   xdis=6;
                   ydis=6;
                   icowidth=60;
                   icofsize=12;
                   width=60+5*2;
                   height=60+12+5*2+2;
                   lcdtype=1;
         }else if(lcddev.width==480)
         {
                   wxoff=10;
                   wyoff=10;
                   xdis=9;
                   ydis=4;
                   icowidth=90;
                   icofsize=16;
                   width=90+8*2;
                   height=90+16+8*2+2;
                   lcdtype=2;
         }
         dis=(width-icowidth)/2;
         twin=window_creat(wxoff,gui_phy.tbheight+wyoff,lcddev.width-2*wxoff,lcddev.height-gui_phy.tbheight-2*wyoff,0,0X01,16);//创建窗口
         if(twin)
         {
                   twin->captionbkcu=GONGJIAO_IN_BACKCOLOR;            //默认caption上部分背景色
                   twin->captionbkcd=GONGJIAO_IN_BACKCOLOR;            //默认caption下部分背景色
                   twin->captioncolor=GONGJIAO_IN_BACKCOLOR;  //默认caption的颜色
                 twin->windowbkc=GONGJIAO_IN_BACKCOLOR;            //默认背景色
        
                   gui_fill_rectangle(0,0,lcddev.width,lcddev.height,GONGJIAO_EX_BACKCOLOR);//填充背景色
                app_gui_tcbar(0,0,lcddev.width,gui_phy.tbheight,0x02);//下分界线    
                 gui_show_strmid(0,0,lcddev.width,gui_phy.tbheight,WHITE,gui_phy.tbfsize
                   ,(u8*)APP_MFUNS_CAPTION_TBL[17][gui_phy.language]);//显示标题 
                   window_draw(twin);
                   for(i=0;i<2;i++)
                   {                          
                            appdev->icos[i].x=110+xdis/2+(i%4)*(width+xdis);                   
                            appdev->icos[i].y=gui_phy.tbheight+110+ydis/2+(i/4)*(height+ydis);   
                            appdev->icos[i].width=width;
                            appdev->icos[i].height=height;
                            appdev->icos[i].path=(u8*)gongjiao_icospath_tbl[lcdtype][i];
                            appdev->icos[i].name=(u8*)gongjiao_appname_tbl[gui_phy.language][i];
                            rval=minibmp_decode(appdev->icos[i].path,appdev->icos[i].x,appdev->icos[i].y+dis,appdev->icos[i].width,icowidth,0,0);
                            if(rval)break;//解码出错了
                   gui_show_strmid(appdev->icos[i].x,appdev->icos[i].y+dis+icowidth+2,appdev->icos[i].width,icofsize,GONGJIAO_NAME_COLOR,icofsize,appdev->icos[i].name);
                 }
                   appdev->selico=0XFF;//默认不选择任何一个
         }else rval=1;
         window_delete(twin);
         return rval;
}          
//设置选中哪个图标
//sel:0~15代表当前页的选中ico
void gongjiao_set_sel(m_app_dev* appdev,u8 sel)
{
         u8 icowidth;
         u8 icofsize;
         u8 dis;
         if(sel>=16)return;//非法的输入     
         if(lcddev.width==240)
         {
                   icowidth=48;
                   icofsize=12;
         }else if(lcddev.width==320)
         {
                   icowidth=60;
                   icofsize=12;
         }else if(lcddev.width==480)
         {
                   icowidth=90;
                   icofsize=16;
         }
         if(appdev->selico<16)
         {
                   dis=(appdev->icos[appdev->selico].width-icowidth)/2;
         gui_fill_rectangle(appdev->icos[appdev->selico].x,appdev->icos[appdev->selico].y,appdev->icos[appdev->selico].width,appdev->icos[appdev->selico].height,GONGJIAO_IN_BACKCOLOR);//清除之前的图片
         minibmp_decode(appdev->icos[appdev->selico].path,appdev->icos[appdev->selico].x,appdev->icos[appdev->selico].y+dis,appdev->icos[appdev->selico].width,icowidth,0,0);
        gui_show_strmid(appdev->icos[appdev->selico].x,appdev->icos[appdev->selico].y+dis+icowidth+2,appdev->icos[appdev->selico].width,icofsize,GONGJIAO_NAME_COLOR,icofsize,appdev->icos[appdev->selico].name);
         };                                     
         appdev->selico=sel;
         dis=(appdev->icos[appdev->selico].width-icowidth)/2;
gui_alphablend_area(appdev->icos[appdev->selico].x,appdev->icos[appdev->selico].y,appdev->icos[appdev->selico].width,appdev->icos[appdev->selico].height,GONGJIAO_ALPHA_COLOR,GONGJIAO_ALPHA_VAL);
minibmp_decode(appdev->icos[appdev->selico].path,appdev->icos[appdev->selico].x,appdev->icos[appdev->selico].y+dis,appdev->icos[appdev->selico].width,icowidth,0,0);
gui_show_strmid(appdev->icos[appdev->selico].x,appdev->icos[appdev->selico].y+dis+icowidth+2,appdev->icos[appdev->selico].width,icofsize,GONGJIAO_NAME_COLOR,icofsize,appdev->icos[appdev->selico].name);
}
//触摸屏扫描
//返回值:0~15,有效按键.其他,无效
u8 gongjiao_tpscan(m_app_dev *appdev)
{
         static u8 firsttpd=0; //按键处理标志,防止一次按下,多次返回
         u8 i=0XFF;
         tp_dev.scan(0);//扫描                                                                                                                                                                   
         if((tp_dev.sta&TP_PRES_DOWN))//有按键被按下
         {
                   if(firsttpd==0)//第一次处理?
                   {
                            firsttpd=1;                         //标记已经处理了此次按键
                            for(i=0;i<2;i++)
                            {
                                     if((tp_dev.x[0]>appdev->icos[i].x)&&(tp_dev.x[0]<appdev->icos[i].x+appdev->icos[i].width)
                                      &&(tp_dev.y[0]>appdev->icos[i].y)&&(tp_dev.y[0]<appdev->icos[i].y+appdev->icos[i].height))//在区域内
                                     {
                                               break;//得到选中的编号       
                                     }
                            }
                   }
         }else firsttpd=0;//松开了
         return i;
}
 
//app应用
u8 gongjiao(void)
{                
         u8 selx=0XFF;
         u8 rval=0;
         u8 key;
         _btn_obj* rbtn=0;            //返回按钮控件
         m_app_dev *appdev;
         appdev=(m_app_dev*)gui_memin_malloc(sizeof(m_app_dev));
         if(appdev==NULL)rval=1;
         else if(gongjiao_load_ui(appdev))rval=1;
         rbtn=btn_creat(200,lcddev.height-gui_phy.tbheight-60,2*gui_phy.tbheight+8,gui_phy.tbheight-1,0,0x03);//创建文字按钮
         if(rbtn==NULL)rval=1;      //没有足够内存够分配
         else
         {                                                                                                                                                                                         rbtn->caption=(u8*)gongjiao_appname_tbl[0][4];//重画
                   rbtn->font=gui_phy.tbfsize;//设置新的字体大小          
                   rbtn->bcfdcolor=RED;      //按下时的颜色
                   rbtn->bcfucolor=WHITE; //松开时的颜色
                   btn_draw(rbtn);//画按钮
        }
        while(rval==0)
         {
                   tp_dev.scan(0);                 
                   in_obj.get_key(&tp_dev,IN_TYPE_TOUCH);    //得到按键键值
                   key=btn_check(rbtn,&in_obj);                   //扫描返回按键
                   selx=gongjiao_tpscan(appdev);
                   if(key)
                   {
                            if(((rbtn->sta&0X80)==0))//按钮状态改变了
                            {
                                     break;
                            }
                   }
                   if(selx<16)//有有效按键
                   {
                            if(selx==appdev->selico)//第二次选择此条目
                            {
                                     //printf("selx:%d\r\n",appdev->selico);
                                     switch(selx)
                                     {
                                               case 0://充值办卡
                                                        chongzhi();
                                                        break;
                                               case 1://刷卡消费
                                                        shuaka();
                                                        break;                                
                                     }
                                     gongjiao_load_ui(appdev);//重新加载主界面
                                     btn_draw(rbtn);//画按钮
                            }
                            gongjiao_set_sel(appdev,selx);                 
                   }
                   if(system_task_return)break;//TPAD返回
                   delay_ms(1000/OS_TICKS_PER_SEC);//延时一个时钟节拍
        }
         btn_delete(rbtn);     //删除按钮
         gui_memin_free(appdev);//释放内存
         return 0;
}
 
void chongzhi(void)
{
         u8 key1,key2,key3,key4;          
         u8 *caption;                       //标题
         u8 res,i,flag1,flag2;
         u8 Str[20];
         _btn_obj* bbtn=0;            //办卡按钮控件
         _btn_obj* cbtn=0;            //充值按钮控件
         _btn_obj* rbtn=0;            //返回按钮控件
         _btn_obj* qbtn=0;
         usart3_init(9600);
         caption=(u8*)gongjiao_appname_tbl[0][0];//无线传输         
         gui_fill_rectangle(0,gui_phy.tbheight,lcddev.width,lcddev.height-gui_phy.tbheight,LGRAY);         //填充背景色
        app_filebrower(caption,0X07);                                                              //显示标题
         bbtn=btn_creat(5,600-gui_phy.tbheight,2*gui_phy.tbheight+8,gui_phy.tbheight-1,0,0x03);//创建文字按钮
         if(bbtn==NULL)res=1;       //没有足够内存够分配
         else
         {                                                                                                                                                                                         bbtn->caption=(u8*)gongjiao_appname_tbl[0][2];//重画
                   bbtn->font=gui_phy.tbfsize;//设置新的字体大小          
                   bbtn->bcfdcolor=BLACK; //按下时的颜色
                   bbtn->bcfucolor=RED;     //松开时的颜色
                   btn_draw(bbtn);//画按钮
        }
         cbtn=btn_creat(400,600-gui_phy.tbheight,2*gui_phy.tbheight+8,gui_phy.tbheight-1,0,0x03);//创建文字按钮
         if(cbtn==NULL)res=1;       //没有足够内存够分配
         else
         {                                                                                                                                                                                         cbtn->caption=(u8*)gongjiao_appname_tbl[0][3];//重画
                   cbtn->font=gui_phy.tbfsize;//设置新的字体大小          
                   cbtn->bcfdcolor=BLACK;  //按下时的颜色
                   cbtn->bcfucolor=RED;      //松开时的颜色
                   btn_draw(cbtn);//画按钮
        }
         qbtn=btn_creat(0,800-gui_phy.tbheight,2*gui_phy.tbheight+8,gui_phy.tbheight-1,0,0x03);//创建文字按钮
         if(qbtn==NULL)res=1;       //没有足够内存够分配
         else
         {                                                                                                                                                                                         qbtn->caption=(u8*)gongjiao_appname_tbl[0][5];//重画
                   qbtn->font=gui_phy.tbfsize;//设置新的字体大小          
                   qbtn->bcfdcolor=BLACK; //按下时的颜色
                   qbtn->bcfucolor=RED;     //松开时的颜色
                   btn_draw(qbtn);//画按钮
        }
         rbtn=btn_creat(400,lcddev.height-gui_phy.tbheight,2*gui_phy.tbheight+8,gui_phy.tbheight-1,0,0x03);//创建文字按钮
         if(rbtn==NULL)res=1;       //没有足够内存够分配
         else
         {                                                                                                                                                                                         rbtn->caption=(u8*)gongjiao_appname_tbl[0][4];//重画
                   rbtn->font=gui_phy.tbfsize;//设置新的字体大小          
                   rbtn->bcfdcolor=RED;      //按下时的颜色
                   rbtn->bcfucolor=WHITE; //松开时的颜色
                   btn_draw(rbtn);//画按钮
        }
         gui_show_string("卡号:",10,138,107,170,24,BLACK);
         gui_show_string("余额:",250,138,347,170,24,BLACK);
         while(1)
         {
                   tp_dev.scan(0);                 
                   in_obj.get_key(&tp_dev,IN_TYPE_TOUCH);    //得到按键键值
                   key1=btn_check(bbtn,&in_obj);                //扫描办卡按键
                  key2=btn_check(cbtn,&in_obj);                //扫描充值按键
                   key3=btn_check(rbtn,&in_obj);                 //扫描返回按键
                   key4=btn_check(qbtn,&in_obj);
                 if(key3)
                   {
                            if(((rbtn->sta&0X80)==0))//按钮状态改变了
                            {
                                     break;
                            }
                   }
                   if(key1&&flag2) //发卡
                   {
                            if(((bbtn->sta&0X80)==0))//按钮状态改变了
                            {                
                                     W25QXX_Read(CardNum_1356,menjin11356ADDR,50);
                                     CardNum_1356[0]=CardNum_1356[0]+1;
                                     M1[25]=CardNum_1356[0];                                                  
                                     uart3_send_bytes(40,M1);
                                     W25QXX_Write(CardNum_1356,menjin11356ADDR,50);
                                     window_msg_box((lcddev.width-200)/2,(lcddev.height-70)/2-15,300,100,"发卡成功!",(u8*)APP_REMIND_CAPTION_TBL[gui_phy.language],24,0,0,0);
                                     delay_ms(500);
                                     gui_fill_rectangle(140,350,300,100,LGRAY);
                                     flag2=0;
                            }
                   }
                   if(key2&&flag1)//充值
                   {
                            if(((cbtn->sta&0X80)==0))//按钮状态改变了
                            {
                                     for(i=0;i<24;i++)
                                     {
                                               Send[i]=USART3_RX_BUF[i];
                                     }
                                     Send[24]=USART3_RX_BUF[24];
                                     Send[25]=USART3_RX_BUF[25];                                 
                                     Send[29]=USART3_RX_BUF[29]+10;
                                     Send[39]=USART3_RX_BUF[39];
                                     uart3_send_bytes(40,Send);   
                                     window_msg_box((lcddev.width-200)/2,(lcddev.height-70)/2-15,300,100,"充值成功!",(u8*)APP_REMIND_CAPTION_TBL[gui_phy.language],24,0,0,0);
                                     delay_ms(500);
                                     gui_fill_rectangle(140,350,300,100,LGRAY);
                                     flag1=0;
                            }
                   }
                   if(key4&&flag1)//清卡
                   {
                            if(((qbtn->sta&0X80)==0))//按钮状态改变了
                            {
                                               for(i=0;i<16;i++)
                                               {
                                                                 Send[i]=USART3_RX_BUF[i];
                                               }
                                               for(i=16;i<39;i++)
                                               {
                                                                 Send[i]=0x00;
                                               }
                                               Send[39]='$';
                                               uart3_send_bytes(40,Send);   
                                               window_msg_box((lcddev.width-200)/2,(lcddev.height-70)/2-15,300,100,"清卡成功!",(u8*)APP_REMIND_CAPTION_TBL[gui_phy.language],24,0,0,0);
                                               delay_ms(500);
                                               gui_fill_rectangle(140,350,300,100,LGRAY);
                                               flag1=0;
                            }
                   }       
                   if(USART3_RX_STA&(1<<15))
                   {
                            if(USART3_RX_BUF[0]=='#'&&USART3_RX_BUF[39]=='$')
                            {
                                     if(USART3_RX_BUF[11]==13)
                                     {
if((USART3_RX_BUF[16]==0xff)&&(USART3_RX_BUF[17]==0xff)&&(USART3_RX_BUF[18]==0xff)&&(USART3_RX_BUF[19]==0xff))
                                               {
                                                        sprintf((char*)Str,"%2d %2d",USART3_RX_BUF[24],USART3_RX_BUF[25]);
                                                        gui_show_ptstr(140,138,250,170,0,RED,24,Str,0);
                                                        sprintf((char*)Str,"%2d ",USART3_RX_BUF[29]);
                                                        gui_show_ptstr(350,138,450,170,0,RED,24,Str,0);
                                                        flag1=1;  
                                               }
                                               else
                                               {
                                                        flag2=1;
                                                        window_msg_box((lcddev.width-200)/2,(lcddev.height-70)/2-15,300,100,"此卡是新卡!",(u8*)APP_REMIND_CAPTION_TBL[gui_phy.language],24,0,0,0);
                                                        delay_ms(500);
                                                        gui_fill_rectangle(140,350,300,100,LGRAY);
                                               }
                                     }
                                     else
                                     {
                                               gui_fill_rectangle(140,138,100,32,LGRAY);
                                               gui_fill_rectangle(350,138,100,32,LGRAY);
                                               flag1=0;
                                               flag2=0;
                                     }                
                            }
                            USART3_RX_STA=0;
                   }
         }
         btn_delete(rbtn);     //删除按钮
         btn_delete(bbtn);    //删除按钮
         btn_delete(cbtn);    //删除按钮
         btn_delete(qbtn);    //删除按钮
}
 
void shuaka(void)
{
         u8 key1,key2,key3,key4;
         u8 *caption;                       //标题
         u8 res,i;
         u8 Str[20];
         _btn_obj* rbtn=0;            //返回按钮控件
         usart3_init(9600);
         caption=(u8*)gongjiao_appname_tbl[0][1];//无线传输         
         gui_fill_rectangle(0,gui_phy.tbheight,lcddev.width,lcddev.height-gui_phy.tbheight,LGRAY);         //填充背景色
        app_filebrower(caption,0X07);                                                              //显示标题
         rbtn=btn_creat(400,lcddev.height-gui_phy.tbheight,2*gui_phy.tbheight+8,gui_phy.tbheight-1,0,0x03);//创建文字按钮
         if(rbtn==NULL)res=1;       //没有足够内存够分配
         else
         {                                                                                                                                                                                         rbtn->caption=(u8*)gongjiao_appname_tbl[0][4];//重画
                   rbtn->font=gui_phy.tbfsize;//设置新的字体大小          
                   rbtn->bcfdcolor=RED;      //按下时的颜色
                   rbtn->bcfucolor=WHITE; //松开时的颜色
                   btn_draw(rbtn);//画按钮
        }
         gui_show_string("卡号:",10,138,107,170,24,BLACK);
         gui_show_string("余额:",250,138,347,470,24,BLACK);
         while(1)
         {
                   tp_dev.scan(0);                 
                   in_obj.get_key(&tp_dev,IN_TYPE_TOUCH);    //得到按键键值
                   key3=btn_check(rbtn,&in_obj);                 //扫描返回按键
                   if(key3)
                   {
                            if(((rbtn->sta&0X80)==0))//按钮状态改变了
                            {
                                     break;
                            }
                   }
                   if(USART3_RX_STA&(1<<15))
                   {
                            if(USART3_RX_BUF[0]=='#'&&USART3_RX_BUF[39]=='$')
                            {
                                     if(USART3_RX_BUF[11]==13)
                                     {
                                     if((USART3_RX_BUF[16]==0xff)&&(USART3_RX_BUF[17]==0xff)&&(USART3_RX_BUF[18]==0xff)&&(USART3_RX_BUF[19]==0xff))
                                               {
                                                        sprintf((char*)Str,"%2d %2d",USART3_RX_BUF[24],USART3_RX_BUF[25]);
                                                        gui_show_ptstr(140,138,250,170,0,RED,24,Str,0);
                                                        sprintf((char*)Str,"%2d ",USART3_RX_BUF[29]);
                                                        gui_show_ptstr(350,138,450,170,0,RED,24,Str,0);
                                               }
                                               else
                                               {
                                                        window_msg_box((lcddev.width-200)/2,(lcddev.height-70)/2-15,300,100,"此卡非本站卡!",(u8*)APP_REMIND_CAPTION_TBL[gui_phy.language],24,0,0,0);
                                                        delay_ms(500);
                                                        gui_fill_rectangle(140,350,300,100,LGRAY);
                                               }
                                     }
                                     else
                                     {
                                               gui_fill_rectangle(140,138,100,32,LGRAY);
                                               gui_fill_rectangle(350,138,100,32,LGRAY);
                                     }
                                     USART3_RX_STA=0;
                            }
                   }
         }
         btn_delete(rbtn);     //删除按钮
}


上一篇:RFID实训|公交刷卡系统

下一篇:RFID实训|环境检测系统