////////////////////////////////////////////////////////// // NEN5_INTE.INC // // // // M・Mインターフェース // // 01/07/06 // ////////////////////////////////////////////////////////// //*********** EEPROM設定値表示 **********************// lcd_out_bcd(int n) { do{ n--; lcd_out(bcd[n]); }while(n!=0); } //----- 燃費計数表示 ---------------------------------// void nenr_print() { stor_trans(0,0,nenr_h,nenr_l); bcd_10(0); lcd_p_l(0); lcd_out("Now Value = "); lcd_out_bcd(3); } //----- 区間距離表示 ---------------------------------// void sect_print() { stor_trans(0,0,0,section); bcd_10(0); lcd_p_l(0); lcd_out("Now Section ="); lcd_out_bcd(3); } //----- 表示内容番号表示 -----------------------------// void content_print(int hl) // H=0 L=1 { if( hl == 0 ) stor[0] = content_u; else stor[0] = content_l; stor[3] = 0; stor[2] = 0; stor[1] = 0; bcd_10(0); lcd_p_l(0); lcd_out("Now Content = "); lcd_out_bcd(2); } //----- 下段オプション番号表示 -----------------------// void option_print() { stor_trans(0,0,0,opt); bcd_10(0); lcd_p_l(0); lcd_out(" Now option = "); lcd_out_bcd(1); } //----- スピードパルス乗数表示 -----------------------// void plsk_print() { stor_trans(0,0,0,plsk); bcd_10(0); lcd_p_l(0); lcd_out(" Now Value = "); lcd_out_bcd(2); } //----- 割り込み禁止 ---------------------------------// disable_interrupts_all() { disable_interrupts(global); disable_interrupts(int_rb); //RB4-7変化割り込み停止 disable_interrupts(int_timer1); //タイマ1割り込み停止 disable_interrupts(rtcc_zero); //タイマ0割り込み停止 bit_clear(t1con,0); inj_t[0] = tmr1l; } //----- POWER Off ------------------------------------// void p_off() { output_low(den); sleep(); } //----- IG off チェック ------------------------------// int ig_off() { int i; i = 0; while(!bit_test(port_a,pin_IG)){ //ig off でwhile delay_us(100); restart_wdt(); i++; if(i>=10) //1mSec連続offならbreak return(1); } return(0); } //----- IG on チェック -------------------------------// int check_ig() { int i; i = 0; while(bit_test(port_a,pin_IG)){ //check IG delay_ms(1); restart_wdt(); i++; if(i >= 100){ enable_interrupts_all(); // 全割り込み許可 enable_rb47(); //injがHならRB4-7割り込み許可 return(2); } } return(0); } //>>>>>>>>>>> igH待ち & タイムオーバー処理 >>>>>>>>>>>>>>>>>>>>>>>>>// void h_mati(int waittime) { long loop2; int loop1; int ig_hh=0; for(loop1=0;loop1>>>>>>>>>>>> igL待ち >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>// int l_mati() { int ig_l; long ig_h; ig_l = 0; ig_h = 0; while(ig_l<10){ //IG・L待ち処理 if(inj[0]!=tmr1l || ig_h>=20000) return(1); restart_wdt(); if(!bit_test(port_a,pin_IG)){ ig_l++; ig_h=0; }else{ ig_h++; ig_l=0; } delay_us(100); restart_wdt(); } disable_interrupts_all(); return(0); } //******************************************************** lcd_out_adust() { lcd_out("Adju Completion"); } //************** 燃費補正値 +1or−1 処理 ***********************// void hosei_ee(int enzan_s,int suuti) // enzan_s:1=(+) 0=(-) { stor_trans16(nenr_h,nenr_l); syori_trans16(0,suuti); if(enzan_s == 1) add32(); else sub32(); stor[3] = 0; stor[2] = 0; nenr_l = stor[0]; nenr_h = stor[1]; s_ee(ee_hosei_l,nenr_l); s_ee(ee_hosei_h,nenr_h); lcd_p_h(0); if(enzan_s == 1) lcd_out('+'); else lcd_out('-'); lcd_out_adust(); nenr_print(); } //************** 区間距離 +1or−1 処理*************************// void sect_chan(int pm) // 0=(+1) 1=(-1) { lcd_p_h(0); if( pm == 0 ){ lcd_out('+'); section++; } else{ lcd_out('-'); section--; } if( section==0 ) section = 1; s_ee(ee_section,section); lcd_out_adust(); sect_print(); } //*********** 履歴表示 ***************************************// void r_dist_peration(int sel) { stor_trans( r_ee(ee_speed3_1+sel), r_ee(ee_speed2_1+sel), r_ee(ee_speed1_1+sel), r_ee(ee_speed0_1+sel)); m_dist_peration(); //距離 } void r_gas_peration(int sel) { stor_trans( r_ee(ee_inj4_1+sel), r_ee(ee_inj3_1+sel), r_ee(ee_inj2_1+sel), r_ee(ee_inj1_1+sel)); m_gas_peration(); //消費燃料 } void rireki() { int sel = 0; while(1){ restart_wdt(); r_gas_peration(sel<<4); //消費燃料 restart_wdt(); r_dist_peration(sel<<4); //距離 restart_wdt(); lcd_p_h(7); lcd_out('-'); lcd_out(sel+0x31); position = 0; m_nen_dis_gas(); //燃費 距離 燃料 lcd_line_out(gedan); //jyouge: 0=上段 1=下段// sel++; if(sel>2) sel = 0; h_mati(30); if(l_mati()) return; } } //*********** 機能選択 ***************************************// void select(int step) { if(l_mati()) //IG OFF 待ち return; lcd_p_l(0); lcd_out("Really? ON ->OFF"); //本当によいですか? //--------------------------------------------------------------// while(1){ h_mati(30); if(l_mati()) return; switch(step){ case 1: //データクリア if(!(tmr1l | tmr1h | inj[2] | inj[3] | inj[4] | tmr0 | speed[1] | speed[2] | speed[3])){ lcd_clr(); lcd_out("Data 0"); lcd_p_l(0); lcd_out("It wasn't Reset"); }else move_history(); //履歴移動&クリア for(step=0;step<100;step++){ // wait 2sec restart_wdt(); delay_ms(20); if(check_ig()) return; } p_off(); break; case 2: //上段表示内容 content_u++; if(content_u >= 13) content_u = 0; s_ee(ee_content_u,content_u); lcd_clr(); lcd_out("Up Item Change! "); content_print(0); // 0=上段 break; case 3: //下段表示内容 content_l++; if(content_l >= 13) content_l = 0; s_ee(ee_content_l,content_l); lcd_clr(); lcd_out("Low Item Change!"); content_print(1); // 1=下段 break; case 4: //下段オプション opt++; if(opt >= 8) opt = 0; s_ee(ee_opt,opt); lcd_clr(); lcd_out("Option Change!"); option_print(); break; case 5: //燃費計数+1補正 hosei_ee(1,1); // 足し算,1 break; case 6: //燃費計数+10補正 hosei_ee(1,10); //足し算,10 break; case 7: hosei_ee(2,1); //引き算,1 break; case 8: hosei_ee(2,10); //引き算,10 break; case 9: //区間距離+ sect_chan(0); // 0=+1 break; case 10: sect_chan(1); //区間距離− break; // 1=−1 case 11: if( plsk == 2 ) plsk = 4; else if( plsk == 4 ) plsk = 8; else if( plsk == 8 ) plsk = 16; else if( plsk == 16 ) plsk = 20; else if( plsk == 20 ) plsk = 25; else if( plsk == 25 ) plsk = 2; s_ee(ee_plsk,plsk); lcd_p_h(10); lcd_out("Change"); plsk_print(); break; case 12: rireki(); return; break; } } } //*********** 設定変更 *******************************// void settei() { int step=0; long loop=0; int loop2=0; while(1){ restart_wdt(); delay_ms(2); loop++; switch(loop){ case 1: step = 1; //記憶DATAをReset? lcd_clr(); lcd_out("Data Reset?"); lcd_p_l(0); lcd_out("Yes: IG on->off"); break; case 1500: step = 12; //履歴表示 lcd_p_h(0); lcd_out("Rireki "); break; case 3000: step = 2; //上段表示内容変更? lcd_clr(); lcd_out("Upper item?"); content_print(0); // 0=上段 break; case 4500: step = 3; //下段表示内容変更? lcd_p_h(0); lcd_out("Lower"); content_print(1); // 1=下段 break; case 6000: step = 4; //表示オプション変更? lcd_clr(); lcd_out("Option?"); option_print(); break; case 7500: step = 5; //燃費計数+1補正? lcd_clr(); lcd_out(" +1 Adjustment?"); nenr_print(); break; case 9000: step = 6; //燃費計数+10補正? lcd_p_h(1); lcd_out("+10"); break; case 10500: step = 7; //燃費計数-1補正? lcd_p_h(1); lcd_out(" -1"); break; case 12000: step = 8; //燃費計数-10補正? lcd_p_h(1); lcd_out("-10"); break; case 13500: step = 9; //区間距離プラス変更? lcd_clr(); lcd_out(" + section?"); sect_print(); break; case 15000: step = 10; //区間距離マイナス変更? lcd_p_h(3); lcd_out('-'); break; case 16500: step = 11; //スピードパルス乗数 lcd_clr(); lcd_out("Speed Pls *n?"); plsk_print(); break; case 18000: loop = 0; loop2++; if(loop2>5) p_off(); break; } if(check_ig()){ select(step); return; } } } //*********** 終了 *******************************************// void syuuryo() { disable_interrupts_all(); output_low(green); //緑ランプ output_low(red); stor_eeprom(); //データをEEPROMへ格納 lcd_clr(); lcd_out("IG on,off select"); position = 0; // m_nen_dis_gas(); //通算燃費 距離 燃料 lcd_line_out(gedan_noopt); //jyouge: 0=上段 1=下段// restart_wdt(); h_mati(6); //IG ON 待ち&タイムオーバー処理 if(!l_mati()) //IG OFF 待ち&タイムオーバー処理 settei(); }