unsigned char Fetch_15minSpeed(unsigned char Num15) { unsigned char rec_num=0; unsigned char i=0,j=0,k=0; unsigned char Read_15minData[75]; unsigned int kk=0; u8 temp_data=0,temp_time=0; //数据格式:15 1 xx xx xx xx xx sp 2 xx xx xx xx xx sp ... ...15 xx xx xx xx xx sp if(avgspd_Mint_Wr>=15) { avgspd_Mint_Wr--; for(i=0;i<15;i++) { memcpy(&Speed_15min[2+i*7],Avrgspd_Mint.datetime,3);//BCD Speed_15min[2+i*7+3]=Temp_Gps_Gprs.Time[0]; Speed_15min[2+i*7+4]=avgspd_Mint_Wr-14+i;//不是BCD码 Speed_15min[2+i*7+5]=Avrgspd_Mint.avgrspd[avgspd_Mint_Wr-14+i]; } #if 0 //================================================== //rt_kprintf("\r\n******当前分钟数>15********",rec_num); rec_num=Api_DFdirectory_Query(spdpermin,0); //rt_kprintf("\r\n已有整小时记录条数(%d 条)",rec_num); if(rec_num) { Api_DFdirectory_Read(spdpermin,Read_15minData,70,0,0); // 从new-->old 读取 /*rt_kprintf("\r\n(读取到)存储的最近一条整小时记录:"); rt_kprintf("\r\n %2x/%2x/%2x %2x:%2x\r\n",Read_15minData[0],Read_15minData[1],Read_15minData[2],Read_15minData[3],Read_15minData[4]); for(i=0;i<65;i++) { if(i%20==0) rt_kprintf("\r\n"); rt_kprintf(" %2d",Read_15minData[i+5]); } rt_kprintf("\r\n存储的前一条数据读出完成\r\n");*/ //判断读出的前一条记录是不是当前小时的前一个小时 //if((Read_15minData[2]==Avrgspd_Mint.datetime[2])&&(Avrgspd_Mint.datetime[3]==(Read_15minData[3]+1))) temp_data=(Read_15minData[2]>>4)*10+(Read_15minData[2]&0x0f); temp_time=(Read_15minData[3]>>4)*10+(Read_15minData[3]&0x0f); //rt_kprintf("\r\n(读出)%d日,%d点\r\n",temp_data,temp_time); //rt_kprintf("\r\n(当前)%d日,%d点\r\n",Temp_Gps_Gprs.Date[2],Temp_Gps_Gprs.Time[0]); } #endif //================================================== }
static void keypress(unsigned int key) { unsigned char temp=0; unsigned char exspeed_num=0; switch(KeyValue) { case KeyValueMenu: pMenuItem=&Menu_4_InforTirExspd; pMenuItem->show(); CounterBack=0; ErrorRecord=0;//疲劳超速记录错误清0 StartDisTiredExpspeed=0; expsp_Flag=0;//查看疲劳报警记录过程标志清0; ChaoScreen=1; break; case KeyValueOk: if(ChaoScreen==1) { ChaoScreen=2; exspeed_num=Api_DFdirectory_Query(spd_warn,0); //查询当前疲劳驾驶记录数目 if(exspeed_num>0) { expsp_Flag=1; //rt_kprintf("\r\n 已有 疲劳驾驶 的记录 %d 条\r\n",TiredDrv_write); if(exspeed_num>=3) ReadEXspeed(3); else ReadEXspeed(exspeed_num); Dis_chaosu(data_tirexps); } else { expsp_Flag=2; //rt_kprintf("\r\n无超速驾驶记录 read\r\n"); } } else if(ChaoScreen==2) { ChaoScreen=3; if(expsp_Flag==3) { expsp_Flag=4; ChaoSuNumScreen=0; StartDisTiredExpspeed=1; lcd_fill(0); lcd_text12(18,10,"按下翻逐条查看",14,LCD_MODE_SET); lcd_update_all(); } } break; case KeyValueUP: if(expsp_Flag==4) { if(ChaoSuNumScreen>0) ChaoSuNumScreen--; if(ChaoSuNumScreen<1) ChaoSuNumScreen=1; if(ChaoSuNumScreen%2==1) drawChaoSu_1(); else { if(ErrorRecord==0) { StartDisTiredExpspeed=0; drawChaoSu_2();//开始时间 结束时间 } } } break; case KeyValueDown: if(expsp_Flag==4) { ChaoSuNumScreen++; /*if(ExpSpdRec_write>=3) temp=6; else temp=ExpSpdRec_write*2;*/ if(ChaoSuNumScreen>=temp) ChaoSuNumScreen=temp; if(ChaoSuNumScreen%2==1) drawChaoSu_1(); else { if(ErrorRecord==0) { StartDisTiredExpspeed=0; drawChaoSu_2();//开始时间 结束时间 } } } break; } KeyValue=0; }
unsigned char Fetch_15minSpeed(unsigned char Num15) { unsigned char rec_num=0; unsigned char i=0,j=0,k=0; unsigned char Read_15minData[75]; unsigned int kk=0; //数据格式:15 1 xx xx xx xx xx sp 2 xx xx xx xx xx sp ... ...15 xx xx xx xx xx sp if(Temp_Gps_Gprs.Time[1]>=1) avgspd_Mint_Wr=Temp_Gps_Gprs.Time[1]-1; if(avgspd_Mint_Wr>=14) { //for(i=0;i<Num15;i++) //Speed_15min[1+j*7]=i+1; //avgspd_Mint_Wr=Temp_Gps_Gprs.Time[0]; //if(Temp_Gps_Gprs.Time[1]>=1) //avgspd_Mint_Wr=Temp_Gps_Gprs.Time[1]-1; //rt_kprintf("\r\n当前时间>=14min"); for(i=0;i<15;i++) { memcpy(&Speed_15min[2+i*7],Avrgspd_Mint.datetime,3);//BCD Speed_15min[2+i*7+3]=Temp_Gps_Gprs.Time[0]; Speed_15min[2+i*7+4]=avgspd_Mint_Wr-14+i;//不是BCD码 Speed_15min[2+i*7+5]=Avrgspd_Mint.avgrspd[avgspd_Mint_Wr-14+i]; } } else { rec_num=Api_DFdirectory_Query(spdpermin,0); //rt_kprintf("\r\n已有整小时记录条数",rec_num); //rt_kprintf("\r\n当前分钟数<15,已有 %d 条,需要从前一小时内读取 %d 条",avgspd_Mint_Wr,(15-avgspd_Mint_Wr)); if(rec_num) { Api_DFdirectory_Read(spdpermin,Read_15minData,70,0,0); // 从new-->old 读取 //rt_kprintf("\r\n存储最近一条整小时记录:"); //for(i=0;i<70;i++) //rt_kprintf(" %d",Read_15minData[i]); //rt_kprintf("\r\n"); //判断读出的前一条记录是不是当前小时的前一个小时 if((Read_15minData[2]==Avrgspd_Mint.datetime[2])&&(Avrgspd_Mint.datetime[3]==(Read_15minData[3]+1))) { for(i=0;i<(14-avgspd_Mint_Wr);i++)//avgspd_Mint_Wr { //rt_kprintf(" %d",Read_15minData[64-(14-avgspd_Mint_Wr-1)+i]);//不需要读取存储的数据 memcpy(&Speed_15min[2+i*7],Read_15minData,4);//yymmddhh Speed_15min[2+i*7+4]=60-(14-avgspd_Mint_Wr)+i;//mm Speed_15min[2+i*7+5]=Read_15minData[64-(13-avgspd_Mint_Wr)+i];//speed } k=i; } else//读出的前一条记录不是当前小时的前一个小时的数据 { for(i=0;i<(14-avgspd_Mint_Wr);i++)//avgspd_Mint_Wr { //rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据 memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,3); kk=(Avrgspd_Mint.datetime[3]>>4)*10+(Avrgspd_Mint.datetime[3]&0x0f)-1; Speed_15min[2+i*7+k*7+3]=((kk/10)<<4)+(kk%10);// Speed_15min[2+i*7+k*7+4]=60-(14-avgspd_Mint_Wr)+i;; Speed_15min[2+i*7+k*7+5]=0; } k=i; } for(i=0;i<=avgspd_Mint_Wr;i++) { rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据 memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,4); Speed_15min[2+i*7+k*7+4]=i; Speed_15min[2+i*7+k*7+5]=Avrgspd_Mint.avgrspd[i]; } } else //没有存过整小时的速度 { //rt_kprintf("\r\n 没有整小时的数据存入 "); for(i=0;i<(14-avgspd_Mint_Wr);i++)//avgspd_Mint_Wr { //rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据 memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,3); kk=(Avrgspd_Mint.datetime[3]>>4)*10+(Avrgspd_Mint.datetime[3]&0x0f)-1; Speed_15min[2+i*7+k*7+3]=((kk/10)<<4)+(kk%10);// Speed_15min[2+i*7+k*7+4]=60-(14-avgspd_Mint_Wr)+i;; Speed_15min[2+i*7+k*7+5]=0; } k=i; //rt_kprintf("\r\n %d 条人为补充数据, 分钟数下标=%d",k,avgspd_Mint_Wr); for(i=0;i<=avgspd_Mint_Wr;i++) { //rt_kprintf(" %d",Avrgspd_Mint.avgrspd[i]);//不需要读取存储的数据 memcpy(&Speed_15min[2+i*7+k*7],Avrgspd_Mint.datetime,4); Speed_15min[2+i*7+k*7+4]=i; Speed_15min[2+i*7+k*7+5]=Avrgspd_Mint.avgrspd[i]; } } //rt_kprintf("\r\n 停车前15分钟车速读完"); }