|
|
程序從頭到尾認(rèn)真研究與學(xué)習(xí)了一下,就程序整體邏輯而言,個人以為還是不錯的,但是其中有一處個人以為還可以進(jìn)一步優(yōu)化,其中正常顯示的邏輯中,關(guān)于里程的存儲處理函數(shù)SETS();,放在if(Mode==0&&bike_set==0)中,具體見下屬函數(shù),會導(dǎo)致里程存儲過于頻繁,對于FLASH是一種考驗(yàn),又因?yàn)楸境绦虻倪壿嬛,測速計(jì)算處于定時器中斷中,每隔500ms才計(jì)算一次速度及里程數(shù)據(jù),所以更沒有必要那么頻繁的存儲里程數(shù)據(jù)。還有其中的/40注釋沒有說明,其實(shí)我以為就是前面別人所說的磁極脈沖數(shù)。個人見解歡迎批評指正,謝謝。
if(Mode==0&&bike_set==0)//正常顯示模式
{
//讀時間
Ds1302_Read_Time();
//顯示時間
write_1602com(0x80);
write_1602dat(0x30+time_buf1[1]/10);
write_1602dat(0x30+time_buf1[1]%10);
write_1602com(0x80+3);
write_1602dat(0x30+time_buf1[2]/10);
write_1602dat(0x30+time_buf1[2]%10);
write_1602com(0x80+6);
write_1602dat(0x30+time_buf1[3]/10);
write_1602dat(0x30+time_buf1[3]%10);
write_1602com(0x80+9);
write_1602dat(0x30+time_buf1[4]/10);
write_1602dat(0x30+time_buf1[4]%10);
write_1602com(0x80+12);
write_1602dat(0x30+time_buf1[5]/10);
write_1602dat(0x30+time_buf1[5]%10);
write_1602com(0x80+15);
write_1602dat(time_buf1[7]-1);
if(before_sec!=time_buf1[6])//:顯示周期為1s,500ms顯示:500ms顯示空
{
before_sec=time_buf1[6];
write_1602com(0x80+11);
write_1602dat(':');
LED_SEC=1;
}
if(LED_SEC==0)
{
write_1602com(0x80+11);
write_1602dat(' ');
}
write_1602com(0x80+0x40);//顯示固定符號寫入位置,從2行第2個位置后開始顯示
if(Mileage/1000000==0)
write_1602dat(' ');
else
write_1602dat(0x30+Mileage/1000000);//數(shù)字+0x30得到該數(shù)字的LCD1602顯示碼
if(Mileage%1000000/100000==0)
write_1602dat(' ');
else
write_1602dat(0x30+Mileage%1000000/100000);//數(shù)字+0x30得到該數(shù)字的LCD1602顯示碼
write_1602dat(0x30+Mileage%1000000%100000/10000);//數(shù)字+0x30得到該數(shù)字的LCD1602顯示碼
write_1602com(0x80+0x40+4);
write_1602dat(0x30+Mileage%1000000%100000%10000/1000);//數(shù)字+30得到該數(shù)字的LCD1602顯示碼
write_1602dat(0x30+Mileage%1000000%100000%10000%1000/100);//數(shù)字+30得到該數(shù)字的LCD1602顯示碼
write_1602dat(0x30+Mileage%1000000%100000%10000%1000%100/10);//數(shù)字+30得到該數(shù)字的LCD1602顯示碼
SETS();
write_1602com(0x80+0x40+10);
write_1602dat(0x30+Velocity/10);
write_1602dat(0x30+Velocity%10);//數(shù)字+30得到該數(shù)字的LCD1602顯示碼
} |
|