• メインページ
  • データ構造
  • ファイル
  • ファイル一覧
  • グローバル

OpenSSM/screen.c

説明を見る。
00001 /**************************************************************************************************
00002     Title           : Screen Task
00003     Programmer      : Yosuke FURUSAWA.
00004     Copyright       : Copyright (C) 2008-2010 Yosuke FURUSAWA.
00005     Since           : 2008/12/15
00006 
00007     Filename        : screen.c
00008     Last up date    : 2010/08/13
00009     Kanji-Code      : Shift-JIS
00010     TAB Space       : 4
00011 **************************************************************************************************/
00012 
00013 
00014 /* Note:
00015 F1 〜 F12, PageUp, PageDownは、画面切り替えキーとしてシステムの予約とする
00016 DELは、キーリピートの変更キーとして予約
00017 
00018 キー入力処理については、再設計の余地あり...
00019 作りこむ時間がありませんでした...
00020 */
00021 
00022 
00023 /*================================================================================================
00024 ヘッダファイルをインクルード
00025 =================================================================================================*/
00026 #include <p24FJ64GA002.h>
00027 
00028 #include "types.h"
00029 
00030 #include "libvideo.h"
00031 #include "libuart.h"
00032 #include "librtc.h"
00033 #include "libadc.h"
00034 #include "libdac.h"
00035 #include "libeeprom.h"
00036 #include "libps2.h"
00037 
00038 #include "table.h"
00039 #include "ssm.h"
00040 #include "main.h"
00041 #include "extmeter.h"
00042 
00043 #include "screen.h"
00044 #include "config.h"
00045 
00046 
00047 /*================================================================================================
00048 マクロ定義
00049 =================================================================================================*/
00050 #define abs(a)                      (((a)>0) ? (a) : -(a))
00051 
00052 
00053 /*================================================================================================
00054 グローバル変数
00055 =================================================================================================*/
00056 /* 起動時の表示画面を保存するための変数. cf SCREEN_main(), SCREEN_setup_config() */
00057 static unsigned int backup;
00058 
00059 SCREEN_T screen;
00060 
00061 
00062 static METER_T meter[6];
00063 static GRAPH_T graph;
00064 static TRACK_T track;
00065 
00066 
00067 /*================================================================================================
00068 プロトタイプ宣言
00069 =================================================================================================*/
00070 static  void SCREEN_meter1(void);
00071 static  void SCREEN_meter2(void);
00072 static  void SCREEN_meter3(void);
00073 static  void SCREEN_meter4(void);
00074 static  void SCREEN_meter5(void);
00075 static  void SCREEN_meter6(void);
00076 static  void SCREEN_setup_ssm(void);
00077 static  void SCREEN_setup_video(void);
00078 static  void SCREEN_setup_extmeter(void);
00079 static  void SCREEN_setup_config(void);
00080 static  void SCREEN_debug(void);
00081 static  void SCREEN_version(void);
00082 static  void SCREEN_lifegame(void);
00083 
00084 static  void SCREEN_keybuf_clear(void);
00085 static  unsigned char SCREEN_key_get(void);
00086 
00087 
00088 /**************************************************************************************************
00089 画面描画タスクの初期化
00090 **************************************************************************************************/
00091 void SCREEN_init(void)
00092 {
00093     screen.screen = 0x01;
00094     screen.screen_flag = SCREEN_INIT;
00095     screen.fps = 7;
00096 
00097     screen.track[0] = 2;
00098     screen.track[1] = 1;
00099 
00100     return;
00101 }
00102 
00103 
00104 /**************************************************************************************************
00105 画面描画タスクの初期化
00106 
00107 関数ポインタを使うと、ちょっと速くなる.
00108 **************************************************************************************************/
00109 BOOL SCREEN_main(void)
00110 {
00111     unsigned char key;
00112     static unsigned char watch = 0;
00113     static unsigned int tick = 0;
00114 
00115     if(RTC_get_ticks(tick, rtc.tick) < (10000 / screen.fps)) return(FALSE);
00116     tick = rtc.tick;
00117 
00118     /* 画面セレクト. F1 〜 F12の 12画面. うぉ、DOSっぽい */
00119     key = PS2_key_check();
00120     if(key >= KEY_F1 && key <= KEY_F12){
00121         screen.screen_flag = SCREEN_INIT;
00122         switch(PS2_key_get()){
00123         case KEY_F1:    screen.screen = 0x01;   break;      /* 3min NG */
00124         case KEY_F2:    screen.screen = 0x02;   break;      /* 9min OK */
00125         case KEY_F3:    screen.screen = 0x03;   break;      /* 21sec NG */
00126         case KEY_F4:    screen.screen = 0x04;   break;      /* 10min OK */
00127         case KEY_F5:    screen.screen = 0x05;   break;      /* 11min OK */
00128         case KEY_F6:    screen.screen = 0x06;   break;      /* 10min OK */
00129         case KEY_F7:    screen.screen = 0x07;   break;      /* 7sec NG */
00130         case KEY_F8:    screen.screen = 0x08;   break;
00131         case KEY_F9:    screen.screen = 0x09;   break;
00132         case KEY_F10:   screen.screen = 0x0a;   break;
00133         case KEY_F11:   screen.screen = 0x0b;   break;
00134         case KEY_F12:   screen.screen = 0x0c;   break;
00135         }
00136 
00137     /* テンキー・キーボード用 */
00138     } else if(key == KEY_PAGEDOWN){
00139         PS2_key_get();
00140         screen.screen_flag = SCREEN_INIT;
00141         screen.screen--;
00142         if(screen.screen < 0x00) screen.screen = 0x00;
00143 
00144     } else if(key == KEY_PAGEUP){
00145         PS2_key_get();
00146         screen.screen_flag = SCREEN_INIT;
00147         screen.screen++;
00148         if(screen.screen > 0x0c) screen.screen = 0x0c;
00149 
00150     /* おまけ : キーリピートを切り替える */
00151     } else if(key == KEY_DEL){
00152         if(ps2.wait != 2000){
00153             ps2.wait = 2000;
00154             VIDEO_locate(0,1);
00155             VIDEO_putstr("Slow");
00156         } else {
00157             ps2.wait =  500;
00158             VIDEO_locate(0,1);
00159             VIDEO_putstr("Fast");
00160         }
00161         PS2_key_buf_clear();
00162 
00163     /* おまけ : クイックセーブ */
00164     } else if(key == KEY_HOME){
00165         PS2_key_get();
00166         VIDEO_locate(0,1);
00167         VIDEO_putstr("Saving...");
00168         VIDEO_locate(0,1);
00169         screen.screen_flag = SCREEN_INIT;
00170         if(CONFIG_save()){
00171             VIDEO_putstr("         ");
00172         } else {
00173             VIDEO_putstr("Error... ");
00174         }
00175         screen.screen_flag = SCREEN_VIEW;
00176 
00177     /* おまけ : 内部時計 */
00178     } else if(key == KEY_END){
00179         PS2_key_get();
00180         watch++;
00181     }
00182 
00183     /* 時計表示 */
00184     if(watch % 2){
00185         VIDEO_locate( 14,0);
00186         VIDEO_putuint(rtc.day, 5);
00187         VIDEO_putch(' ');
00188         VIDEO_putuint(rtc.hour, 2);
00189         VIDEO_putch(':');
00190         VIDEO_putuint(rtc.min, 2);
00191         VIDEO_putch(':');
00192         VIDEO_putuint(rtc.sec, 2);
00193         VIDEO_putch('.');
00194         VIDEO_putuint(rtc.msec, 3);
00195     }
00196 
00197     /* 画面を表示する */
00198     switch(screen.screen){
00199     case 0x01:  SCREEN_meter1();                break;
00200     case 0x02:  SCREEN_meter2();                break;
00201     case 0x03:  SCREEN_meter3();                break;
00202     case 0x04:  SCREEN_meter4();                break;
00203     case 0x05:  SCREEN_meter5();                break;
00204     case 0x06:  SCREEN_meter6();                break;
00205     case 0x07:  SCREEN_setup_ssm();             break;
00206     case 0x08:  SCREEN_setup_video();           break;
00207     case 0x09:  SCREEN_setup_extmeter();        break;
00208     case 0x0a:  SCREEN_setup_config();          break;
00209     case 0x0b:  SCREEN_debug();                 break;
00210     case 0x0c:  SCREEN_version();               break;
00211     default:    screen.screen = 0x01;           break;          /* ここにきたらバグ */
00212     }
00213 
00214     /* 起動時の表示画面保存用 */
00215     if(screen.screen < 0x07) backup = screen.screen;
00216 
00217     return(TRUE);
00218 }
00219 
00220 
00221 /*-------------------------------------------------------------------------------------------------
00222 メータ表示1
00223 -------------------------------------------------------------------------------------------------*/
00224 static  void SCREEN_meter1(void)
00225 {
00226     unsigned int tmp;
00227     int x, y;
00228 
00229     /* 画面初期化 */
00230     if(screen.screen_flag == SCREEN_INIT){
00231         screen.screen_flag = SCREEN_VIEW;
00232         screen.fps = 10;
00233         VIDEO_vram_clear(0x00);
00234 
00235         VIDEO_locate( 0, 0);    VIDEO_putstr("SSM Multi Monitor");
00236 
00237         VIDEO_locate( 7, 2);    VIDEO_putstr("rpm");
00238         VIDEO_locate( 7, 3);    VIDEO_putstr("km/h");
00239         VIDEO_locate( 7, 4);    VIDEO_putch ('%');
00240         VIDEO_locate( 7, 5);    VIDEO_putch ('s');
00241 
00242         VIDEO_locate(17, 2);    VIDEO_putstr("WAT");
00243         VIDEO_locate(17, 3);    VIDEO_putstr("AIR");
00244         VIDEO_locate(17, 4);    VIDEO_putch ('V');
00245         VIDEO_locate(17, 5);    VIDEO_putstr("km/L");
00246 
00247         VIDEO_locate(29, 2);    VIDEO_putstr("MAF");
00248         VIDEO_locate(29, 3);    VIDEO_putstr("AFR");
00249         VIDEO_locate(29, 4);    VIDEO_putstr("KNO");
00250         VIDEO_locate(29, 5);    VIDEO_putstr("IGN");
00251 
00252         VIDEO_locate( 6, 9);    VIDEO_putstr("kg/cm2");
00253 
00254         METER_init(&meter[0],  50, 50, 50);
00255         TRACK_init(&track,    105,  0, NTSC_WIDTH - 105, 90);
00256     }
00257 
00258     /* キーボード入力処理 */
00259     switch(SCREEN_key_get()){
00260     case KEY_UP:
00261     case KEY_DOWN:  screen.track[0] = (screen.track[0] + 1) % 3;    break;
00262     case KEY_LEFT:
00263     case KEY_RIGHT: screen.track[1] = (screen.track[1] + 1) % 3;    break;
00264     default:                                                        break;
00265     }
00266 
00267     /* ±2G -> ±1Gへ変換. あんまり賢くないコード... */
00268     x = (adc.adc[ screen.track[0] ] << 1) - 1024;
00269     y = (adc.adc[ screen.track[1] ] << 1) - 1024;
00270     x = -1 * x;
00271     if(x >  512) x =  512;
00272     if(x < -512) x = -512;
00273     if(y >  512) y =  512;
00274     if(y < -512) y = -512;
00275     x = (x + 512) / 10;
00276     y = (y + 512) / 10;
00277 
00278     /* 表示 */
00279     TRACK_putdata(&track, x, y);
00280     TRACK_draw_point(&track);
00281 /*
00282     VIDEO_locate(31,10);    VIDEO_putuint(screen.track[0], 1);
00283     VIDEO_locate(31,11);    VIDEO_putuint(screen.track[1], 1);
00284 */
00285     VIDEO_locate( 2, 2);    VIDEO_putuint(ssm_data.engine, 4);
00286     VIDEO_locate( 3, 3);    VIDEO_putuint(ssm_data.speed, 3);
00287     VIDEO_locate( 0, 4);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00288     VIDEO_locate( 5, 5);    VIDEO_putuint(ssm_data.shift, 1);
00289 
00290     VIDEO_locate(12, 2);    VIDEO_putint(ssm_data.coolant, 3);
00291     VIDEO_locate(12, 3);    VIDEO_putint(ssm_data.intakeair, 3);
00292     VIDEO_locate(11, 4);    VIDEO_putdouble(ssm_data.battery, 2, 1);
00293     VIDEO_locate(10, 5);    VIDEO_putdouble(ssm_data.fuel, 3, 1);
00294 
00295     VIDEO_locate(21, 2);    VIDEO_putdouble(ssm_data.maf, 4, 1);
00296     VIDEO_locate(21, 3);    VIDEO_putdouble(ssm_data.afr, 4, 1);
00297     VIDEO_locate(23, 4);    VIDEO_putdouble(ssm_data.knock, 2, 1);
00298     VIDEO_locate(23, 5);    VIDEO_putdouble(ssm_data.ignition, 2, 1);
00299 
00300     VIDEO_locate( 4, 8);    VIDEO_putdouble(ssm_data.boost, 1, 2);
00301 
00302     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00303     else                    tmp = 33.0 + ssm_data.boost  * 44.666;
00304     METER_draw(&meter[0], tmp);
00305 
00306     return;
00307 }
00308 
00309 
00310 /*-------------------------------------------------------------------------------------------------
00311 メータ表示2
00312 -------------------------------------------------------------------------------------------------*/
00313 static  void SCREEN_meter2(void)
00314 {
00315     unsigned int tmp;
00316 
00317     /* 画面初期化 */
00318     if(screen.screen_flag == SCREEN_INIT){
00319         screen.screen_flag = SCREEN_VIEW;
00320         screen.fps = 10;
00321         VIDEO_vram_clear(0x00);
00322 
00323         VIDEO_locate( 0,  0);   VIDEO_putstr("Multi Meter");
00324         VIDEO_locate( 6,  4);   VIDEO_putstr("rpm");
00325         VIDEO_locate(18,  4);   VIDEO_putch ('%');
00326         VIDEO_locate(25,  4);   VIDEO_putstr("kg/cm2");
00327         VIDEO_locate( 4, 10);   VIDEO_putstr("km/h");
00328         VIDEO_locate(15, 10);   VIDEO_putstr("Water");
00329         VIDEO_locate(28, 10);   VIDEO_putstr("Air");
00330 
00331         METER_init(&meter[0],  40, 128, 40);
00332         METER_init(&meter[1], 128, 128, 40);
00333         METER_init(&meter[2], 215, 128, 40);
00334         METER_init(&meter[3],  40,  40, 40);
00335         METER_init(&meter[4], 128,  40, 40);
00336         METER_init(&meter[5], 215,  40, 40);
00337     }
00338 
00339 
00340     /* キーボード入力処理 */
00341     SCREEN_keybuf_clear();
00342 
00343     VIDEO_locate( 4, 3);    VIDEO_putuint(ssm_data.engine, 4);
00344     tmp = ((unsigned long)ssm_data.engine * 100) / 9999;
00345     METER_draw(&meter[0],    tmp);
00346 
00347     VIDEO_locate(16, 3);    VIDEO_putuint(ssm_data.throttle, 3);
00348     METER_draw(&meter[1],    ssm_data.throttle);
00349 
00350     VIDEO_locate(25, 3);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00351     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00352     else                    tmp = 33.0 + ssm_data.boost  * 44.666;
00353     METER_draw(&meter[2],    tmp);
00354 
00355     VIDEO_locate( 5, 9);    VIDEO_putuint(ssm_data.speed, 3);
00356     tmp = ((unsigned int)ssm_data.speed * 100) / 255;
00357     METER_draw(&meter[3],    tmp);
00358 
00359 
00360     VIDEO_locate(15, 9);    VIDEO_putint(ssm_data.coolant, 3);
00361     tmp = (((unsigned int)ssm_data.coolant + 40) * 100) / 255;
00362     METER_draw(&meter[4],    tmp);
00363 
00364     VIDEO_locate(26, 9);    VIDEO_putint(ssm_data.intakeair, 3);
00365     tmp = (((unsigned int)ssm_data.intakeair + 40) * 100) / 255;
00366     METER_draw(&meter[5],    tmp);
00367 
00368     return;
00369 }
00370 
00371 
00372 /*-------------------------------------------------------------------------------------------------
00373 メータ表示3
00374 -------------------------------------------------------------------------------------------------*/
00375 static  void SCREEN_meter3(void)
00376 {
00377     unsigned int tmp;
00378 
00379     /* 画面初期化 */
00380     if(screen.screen_flag == SCREEN_INIT){
00381         screen.screen_flag = SCREEN_VIEW;
00382         screen.fps = 10;
00383         VIDEO_vram_clear(0x00);
00384 
00385         VIDEO_locate( 0, 0);    VIDEO_putstr("Fuel Consumption Monitor");
00386 
00387         VIDEO_locate( 5, 4);    VIDEO_putstr("rpm");
00388         VIDEO_locate(13, 4);    VIDEO_putstr("km/h");
00389         VIDEO_locate( 2, 9);    VIDEO_putstr("kg/cm2");
00390         VIDEO_locate(15, 9);    VIDEO_putstr("%");
00391         VIDEO_locate( 5,11);    VIDEO_putstr("WAT");
00392         VIDEO_locate(14,11);    VIDEO_putstr("AIR");
00393 
00394         METER_init(&meter[0],  36, 132, 36);
00395         METER_init(&meter[1], 112, 132, 36);
00396         METER_init(&meter[2],  36,  57, 36);
00397         METER_init(&meter[3], 112,  57, 36);
00398 
00399         VIDEO_locate(28, 2);    VIDEO_putstr("Fe/h");
00400         VIDEO_locate(28, 3);    VIDEO_putstr("ml/s");
00401         VIDEO_locate(28, 4);    VIDEO_putstr("km/L");
00402         GRAPH_init(&graph, 152,   0, GRAPH_SIZE, 100);
00403     }
00404 
00405     /* キーボード入力処理 */
00406     SCREEN_keybuf_clear();
00407 
00408     VIDEO_locate( 3, 3);    VIDEO_putuint(ssm_data.engine, 4);
00409     tmp = ((unsigned long)ssm_data.engine * 100) / 9999;
00410     METER_draw(&meter[0],    tmp);
00411 
00412     VIDEO_locate(13, 3);    VIDEO_putuint(ssm_data.speed, 3);
00413     tmp = ((unsigned int)ssm_data.speed * 100) / 255;
00414     METER_draw(&meter[1],    tmp);
00415 
00416     VIDEO_locate( 2, 8);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00417     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00418     else                    tmp = 33.0 + ssm_data.boost  * 44.666;
00419     METER_draw(&meter[2],    tmp);
00420     
00421     VIDEO_locate(13, 8);    VIDEO_putuint(ssm_data.throttle, 3);
00422     METER_draw(&meter[3],    ssm_data.throttle);
00423 
00424     VIDEO_locate( 0,11);    VIDEO_putint(ssm_data.coolant, 3);
00425     VIDEO_locate( 9,11);    VIDEO_putint(ssm_data.intakeair, 3);
00426 
00427     VIDEO_locate(18, 2);    VIDEO_putdouble((ssm_data.fuel_rate * (double)ssm.price * 3.6), 4, 3);
00428     VIDEO_locate(19, 3);    VIDEO_putdouble( ssm_data.fuel_rate, 3, 3);
00429     VIDEO_locate(19, 4);    VIDEO_putdouble( ssm_data.fuel, 3, 3);
00430     GRAPH_putdata(&graph, (unsigned int)(ssm_data.fuel * 3.0));
00431     GRAPH_draw_line(&graph);
00432 
00433     return;
00434 }
00435 
00436 
00437 /*-------------------------------------------------------------------------------------------------
00438 メータ表示4
00439 -------------------------------------------------------------------------------------------------*/
00440 static  void SCREEN_meter4(void)
00441 {
00442     unsigned int tmp;
00443 
00444     /* 画面初期化 */
00445     if(screen.screen_flag == SCREEN_INIT){
00446         screen.screen_flag = SCREEN_VIEW;
00447         screen.fps = 10;
00448         VIDEO_vram_clear(0x00);
00449 
00450         VIDEO_locate(20, 9);    VIDEO_putstr("rpm");
00451         VIDEO_locate(20,10);    VIDEO_putstr("km/h");
00452         VIDEO_locate(20,11);    VIDEO_putstr("km/L");
00453 
00454         VIDEO_locate(31, 9);    VIDEO_putch('%');
00455         VIDEO_locate(31,10);    VIDEO_putch('C');
00456         VIDEO_locate(31,11);    VIDEO_putch('s');
00457 
00458         METER_init(&meter[0], 50, 50, 50);
00459         VIDEO_locate( 5,10);    VIDEO_putstr("kg/cm2");
00460     }
00461 
00462     /* キーボード入力処理 */
00463     SCREEN_keybuf_clear();
00464 
00465     /* 表示 */
00466     if(ssm_data.boost <= 0) tmp = (ssm_data.boost + 1.0) * 33.333;
00467     else                    tmp = 33.0 + ssm_data.boost  * 44.666;
00468     METER_draw(&meter[0], tmp);
00469 
00470     VIDEO_locate( 4, 9);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00471 
00472 
00473     VIDEO_locate(15, 9);    VIDEO_putuint(ssm_data.engine, 4);
00474     VIDEO_locate(16,10);    VIDEO_putuint(ssm_data.speed, 3);
00475     VIDEO_locate(13,11);    VIDEO_putdouble(ssm_data.fuel, 3, 1);
00476 
00477 
00478     VIDEO_locate(24, 9);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00479     VIDEO_locate(27,10);    VIDEO_putuint(ssm_data.coolant, 3);
00480     VIDEO_locate(29,11);    VIDEO_putuint(ssm_data.shift, 1);
00481 
00482     return;
00483 }
00484 
00485 
00486 /*-------------------------------------------------------------------------------------------------
00487 メータ表示5
00488 -------------------------------------------------------------------------------------------------*/
00489 static  void SCREEN_meter5(void)
00490 {
00491     int x, y;
00492 
00493     /* 画面初期化 */
00494     if(screen.screen_flag == SCREEN_INIT){
00495         screen.screen_flag = SCREEN_VIEW;
00496         screen.fps = 10;
00497         VIDEO_vram_clear(0x00);
00498 
00499         VIDEO_locate(20, 9);    VIDEO_putstr("rpm");
00500         VIDEO_locate(20,10);    VIDEO_putstr("km/h");
00501         VIDEO_locate(20,11);    VIDEO_putstr("kg/cm2");
00502 
00503         VIDEO_locate(31, 9);    VIDEO_putch('%');
00504         VIDEO_locate(31,10);    VIDEO_putch('C');
00505         VIDEO_locate(31,11);    VIDEO_putch('s');
00506 
00507         TRACK_init(&track, 0, 0, 100, 50);
00508     }
00509 
00510     /* キーボード入力処理 */
00511     switch(SCREEN_key_get()){
00512     case KEY_UP:
00513     case KEY_DOWN:  screen.track[0] = (screen.track[0] + 1) % 3;    break;
00514     case KEY_LEFT:
00515     case KEY_RIGHT: screen.track[1] = (screen.track[1] + 1) % 3;    break;
00516     default:                                            break;
00517     }
00518 
00519     /* ±2G -> ±1Gへ変換. あんまり賢くないコード... */
00520     x = (adc.adc[ screen.track[0] ] << 1) - 1024;
00521     y = (adc.adc[ screen.track[1] ] << 1) - 1024;
00522     x = -1 * x;
00523     if(x >  512) x =  512;
00524     if(x < -512) x = -512;
00525     if(y >  512) y =  512;
00526     if(y < -512) y = -512;
00527     x = (x + 512) / 10;
00528     y = (y + 512) / 10;
00529 
00530     /* 表示 */
00531     TRACK_putdata(&track, (1024 - adc.adc[ screen.track[0] ]) / 10, adc.adc[ screen.track[1] ] / 10);
00532     TRACK_draw_point(&track);
00533 
00534     VIDEO_locate(13, 9);    VIDEO_putuint(screen.track[0], 1);
00535     VIDEO_locate(13,10);    VIDEO_putuint(screen.track[1], 1);
00536 
00537     VIDEO_locate(15, 9);    VIDEO_putuint(ssm_data.engine, 4);
00538     VIDEO_locate(16,10);    VIDEO_putuint(ssm_data.speed, 3);
00539     VIDEO_locate(14,11);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00540 
00541     VIDEO_locate(24, 9);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00542     VIDEO_locate(27,10);    VIDEO_putuint(ssm_data.coolant, 3);
00543     VIDEO_locate(29,11);    VIDEO_putuint(ssm_data.shift, 1);
00544 
00545 
00546     return;
00547 }
00548 
00549 
00550 /*-------------------------------------------------------------------------------------------------
00551 メータ表示6
00552 -------------------------------------------------------------------------------------------------*/
00553 static  void SCREEN_meter6(void)
00554 {
00555     /* 画面初期化 */
00556     if(screen.screen_flag == SCREEN_INIT){
00557         screen.screen_flag = SCREEN_VIEW;
00558         screen.fps = 10;
00559         VIDEO_vram_clear(0x00);
00560 
00561         VIDEO_locate( 9,11);    VIDEO_putstr("km/L");
00562 
00563         VIDEO_locate(20, 9);    VIDEO_putstr("rpm");
00564         VIDEO_locate(20,10);    VIDEO_putstr("km/h");
00565         VIDEO_locate(20,11);    VIDEO_putstr("kg/cm2");
00566 
00567         VIDEO_locate(31, 9);    VIDEO_putch('%');
00568         VIDEO_locate(31,10);    VIDEO_putch('C');
00569         VIDEO_locate(31,11);    VIDEO_putch('s');
00570 
00571         GRAPH_init(&graph, 0, 16, GRAPH_SIZE, 32);
00572     }
00573 
00574     /* キーボード入力処理 */
00575     SCREEN_keybuf_clear();
00576 
00577     /* 表示 */
00578     GRAPH_putdata(&graph, (unsigned int)ssm_data.fuel * 3);
00579     GRAPH_draw_line(&graph);
00580     VIDEO_locate(2,11);     VIDEO_putdouble(ssm_data.fuel, 3, 1);
00581 
00582     VIDEO_locate(15, 9);    VIDEO_putuint(ssm_data.engine, 4);
00583     VIDEO_locate(16,10);    VIDEO_putuint(ssm_data.speed, 3);
00584     VIDEO_locate(14,11);    VIDEO_putdouble(ssm_data.boost, 0, 2);
00585 
00586     VIDEO_locate(24, 9);    VIDEO_putdouble(ssm_data.throttle, 3, 1);
00587     VIDEO_locate(27,10);    VIDEO_putuint(ssm_data.coolant, 3);
00588     VIDEO_locate(29,11);    VIDEO_putuint(ssm_data.shift, 1);
00589 
00590     return;
00591 }
00592 
00593 
00594 /*-------------------------------------------------------------------------------------------------
00595 SSMの設定
00596 -------------------------------------------------------------------------------------------------*/
00597 static  void SCREEN_setup_ssm(void)
00598 {
00599     static char cursol;
00600     char run = 0;
00601     char i;
00602 
00603     /* 画面初期化 */
00604     if(screen.screen_flag == SCREEN_INIT){
00605         screen.screen_flag = SCREEN_VIEW;
00606         screen.fps = 20;
00607         VIDEO_vram_clear(0x00);
00608         cursol = 0;
00609 
00610         VIDEO_locate( 0, 0);    VIDEO_putstr("SSM Setup");
00611         VIDEO_locate(16, 0);    VIDEO_putstr("UART1");
00612         VIDEO_locate(24, 0);    VIDEO_putstr("UART2");
00613 
00614         VIDEO_locate( 1, 2);    VIDEO_putstr("MODE");
00615 
00616         VIDEO_locate( 1, 4);    VIDEO_putstr("TIRE Width");
00617         VIDEO_locate( 1, 5);    VIDEO_putstr("TIRE Flat");
00618         VIDEO_locate( 1, 6);    VIDEO_putstr("TIRE Inch");
00619         VIDEO_locate( 1, 7);    VIDEO_putstr("TIRE Circle");
00620         VIDEO_locate( 1, 8);    VIDEO_putstr("Fuel Price");
00621         VIDEO_locate( 1, 9);    VIDEO_putstr("SSM Wait");
00622         VIDEO_locate( 1,10);    VIDEO_putstr("SSM Cycle");
00623         VIDEO_locate( 1,11);    VIDEO_putstr("SSM Error");
00624 
00625         VIDEO_locate(20, 4);    VIDEO_putstr("Final");
00626         VIDEO_locate(20, 5);    VIDEO_putstr("1st");
00627         VIDEO_locate(20, 6);    VIDEO_putstr("2nd");
00628         VIDEO_locate(20, 7);    VIDEO_putstr("3rd");
00629         VIDEO_locate(20, 8);    VIDEO_putstr("4th");
00630         VIDEO_locate(20, 9);    VIDEO_putstr("5th");
00631         VIDEO_locate(20,10);    VIDEO_putstr("6th");
00632         VIDEO_locate(20,11);    VIDEO_putstr("7th");
00633     }
00634 
00635     /* キーボード入力処理 */
00636     switch(SCREEN_key_get()){
00637     case KEY_UP:        cursol--;       break;
00638     case KEY_DOWN:      cursol++;       break;
00639     case KEY_LEFT:      run = -1;       break;
00640     case KEY_RIGHT:     run =  1;       break;
00641     default:                            break;
00642     }
00643 
00644     /* カーソル確認/表示 */
00645     if(cursol <  0) cursol =  0;
00646     if(cursol > 16) cursol = 16;
00647 
00648     VIDEO_locate(0, 2);
00649     if(cursol == 0)     VIDEO_putch('>');
00650     else                VIDEO_putch(' ');
00651 
00652     for(i = 1; i < 9; i++){
00653         VIDEO_locate(0, 3 + i);
00654         if(cursol == i) VIDEO_putch('>');
00655         else            VIDEO_putch(' ');
00656     }
00657     for(; i < 17; i++){
00658         VIDEO_locate(19, i - 5);
00659         if(cursol == i) VIDEO_putch('>');
00660         else            VIDEO_putch(' ');
00661     }
00662 
00663     /* 実行 */
00664     if(run == -1 || run == 1){
00665         switch(cursol){
00666         case  0:
00667             if(run == -1)   ssm.mode = SSM_MODE_OPENSSM;
00668             else            ssm.mode = SSM_MODE_OPENPORT;
00669             break;
00670 
00671         case  1:    ssm.tire_width += run;                      break;
00672         case  2:    ssm.tire_flat += run;                       break;
00673         case  3:    ssm.tire_inch += run;                       break;
00674 
00675         case  5:    ssm.price += run;                           break;
00676         case  6:    ssm.wait += run;                            break;
00677 
00678         case  9:    ssm.gear_ratio[0] += (double)run * 0.001;   break;
00679         case 10:    ssm.gear_ratio[1] += (double)run * 0.001;   break;
00680         case 11:    ssm.gear_ratio[2] += (double)run * 0.001;   break;
00681         case 12:    ssm.gear_ratio[3] += (double)run * 0.001;   break;
00682         case 13:    ssm.gear_ratio[4] += (double)run * 0.001;   break;
00683         case 14:    ssm.gear_ratio[5] += (double)run * 0.001;   break;
00684         case 15:    ssm.gear_ratio[6] += (double)run * 0.001;   break;
00685         case 16:    ssm.gear_ratio[7] += (double)run * 0.001;   break;
00686         default:                                                break;
00687         }
00688 
00689         ssm.tire_circle = SSM_TIRE_R(ssm.tire_width, ssm.tire_flat, ssm.tire_inch);
00690     }
00691 
00692 
00693     /* 表示 */
00694     VIDEO_locate( 6, 2);
00695     switch(ssm.mode){
00696     case SSM_MODE_OPENSSM:  VIDEO_putstr("OpenSSM ");   break;
00697     case SSM_MODE_OPENPORT:
00698     default:
00699                             VIDEO_putstr("OpenPort");   break;
00700     }
00701 
00702     VIDEO_locate(16, 1);    VIDEO_putdouble(UART1_get_baud() / 1000.0, 3, 1);   VIDEO_putch('k');
00703     VIDEO_locate(25, 1);    VIDEO_putdouble(UART2_get_baud() / 1000.0, 3, 1);   VIDEO_putch('k');
00704 
00705     VIDEO_locate(16, 2);    VIDEO_putuint(UART1_get_sendbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART1_TX_BUFFER_SIZE, 3);
00706     VIDEO_locate(16, 3);    VIDEO_putuint(UART1_get_recvbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART1_RX_BUFFER_SIZE, 3);
00707 
00708     VIDEO_locate(25, 2);    VIDEO_putuint(UART2_get_sendbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART2_TX_BUFFER_SIZE, 3);
00709     VIDEO_locate(25, 3);    VIDEO_putuint(UART2_get_recvbuf(), 3);  VIDEO_putch('/');   VIDEO_putuint(UART2_RX_BUFFER_SIZE, 3);
00710 
00711     VIDEO_locate(14, 4);    VIDEO_putuint(ssm.tire_width, 4);
00712     VIDEO_locate(15, 5);    VIDEO_putuint(ssm.tire_flat, 3);
00713     VIDEO_locate(15, 6);    VIDEO_putuint(ssm.tire_inch, 3);
00714     VIDEO_locate(13, 7);    VIDEO_putuint(ssm.tire_circle, 5);
00715     VIDEO_locate(13, 8);    VIDEO_putuint(ssm.price, 5);
00716     VIDEO_locate(13, 9);    VIDEO_putuint(ssm.wait, 5);
00717     VIDEO_locate(13,10);    VIDEO_putuint(ssm.cycle, 5);
00718     VIDEO_locate(13,11);    VIDEO_putuint(ssm.error, 5);
00719 
00720     VIDEO_locate(26, 4);    VIDEO_putdouble(ssm.gear_ratio[0], 1, 3);
00721     VIDEO_locate(26, 5);    VIDEO_putdouble(ssm.gear_ratio[1], 1, 3);
00722     VIDEO_locate(26, 6);    VIDEO_putdouble(ssm.gear_ratio[2], 1, 3);
00723     VIDEO_locate(26, 7);    VIDEO_putdouble(ssm.gear_ratio[3], 1, 3);
00724     VIDEO_locate(26, 8);    VIDEO_putdouble(ssm.gear_ratio[4], 1, 3);
00725     VIDEO_locate(26, 9);    VIDEO_putdouble(ssm.gear_ratio[5], 1, 3);
00726     VIDEO_locate(26,10);    VIDEO_putdouble(ssm.gear_ratio[6], 1, 3);
00727     VIDEO_locate(26,11);    VIDEO_putdouble(ssm.gear_ratio[7], 1, 3);
00728 
00729     return;
00730 }
00731 
00732 
00733 /*-------------------------------------------------------------------------------------------------
00734 ビデオの設定
00735 -------------------------------------------------------------------------------------------------*/
00736 static  void SCREEN_setup_video(void)
00737 {
00738     static char cursol;
00739     char run = 0;
00740     unsigned int i;
00741 
00742     /* 画面初期化 */
00743     if(screen.screen_flag == SCREEN_INIT){
00744         screen.screen_flag = SCREEN_VIEW;
00745         screen.fps = 5;
00746         VIDEO_vram_clear(0x00);
00747         cursol = 0;
00748 
00749         VIDEO_locate( 1, 1);    VIDEO_putstr("NTSC Setup");
00750 
00751         VIDEO_locate( 1, 2);    VIDEO_putstr("line");
00752         VIDEO_locate( 1, 3);    VIDEO_putstr("line_sync");
00753         VIDEO_locate( 1, 4);    VIDEO_putstr("line_space");
00754         VIDEO_locate( 1, 5);    VIDEO_putstr("line_video");
00755         VIDEO_locate( 1, 6);    VIDEO_putstr("horizon");
00756         VIDEO_locate( 1, 7);    VIDEO_putstr("serration");
00757         VIDEO_locate( 1, 8);    VIDEO_putstr("equalizing");
00758         VIDEO_locate( 1, 9);    VIDEO_putstr("left_space");
00759         VIDEO_locate( 1,10);    VIDEO_putstr("width");
00760 
00761         VIDEO_locate(12, 1);    VIDEO_putstr("Monitor");
00762         VIDEO_locate(20, 1);    VIDEO_putstr("Superimpose");
00763 
00764         /* 白枠 */
00765         VIDEO_line(             1,               1, NTSC_WIDTH - 2,               1);
00766         VIDEO_line(             1,               1,              1, NTSC_HEIGHT - 1);
00767         VIDEO_line(NTSC_WIDTH - 2,               1, NTSC_WIDTH - 2, NTSC_HEIGHT - 1);
00768         VIDEO_line(             1, NTSC_HEIGHT - 1, NTSC_WIDTH - 2, NTSC_HEIGHT - 1);
00769 
00770         VIDEO_line(             2,               2, NTSC_WIDTH - 3,               2);
00771         VIDEO_line(             2,               2,              2, NTSC_HEIGHT - 2);
00772         VIDEO_line(NTSC_WIDTH - 3,               2, NTSC_WIDTH - 3, NTSC_HEIGHT - 2);
00773         VIDEO_line(             2, NTSC_HEIGHT - 2, NTSC_WIDTH - 3, NTSC_HEIGHT - 2);
00774 
00775         VIDEO_line(             3,               3, NTSC_WIDTH - 4,               3);
00776         VIDEO_line(             3,               3,              3, NTSC_HEIGHT - 3);
00777         VIDEO_line(NTSC_WIDTH - 4,               3, NTSC_WIDTH - 4, NTSC_HEIGHT - 3);
00778         VIDEO_line(             3, NTSC_HEIGHT - 3, NTSC_WIDTH - 4, NTSC_HEIGHT - 3);
00779 
00780         VIDEO_line(             4,               4, NTSC_WIDTH - 5,               4);
00781         VIDEO_line(             4,               4,              4, NTSC_HEIGHT - 4);
00782         VIDEO_line(NTSC_WIDTH - 5,               4, NTSC_WIDTH - 5, NTSC_HEIGHT - 4);
00783         VIDEO_line(             4, NTSC_HEIGHT - 4, NTSC_WIDTH - 5, NTSC_HEIGHT - 4);
00784     }
00785 
00786 
00787     /* キーボード入力処理 */
00788     switch(SCREEN_key_get()){
00789     case KEY_UP:        cursol--;       break;
00790     case KEY_DOWN:      cursol++;       break;
00791     case KEY_LEFT:      run = -1;       break;
00792     case KEY_RIGHT:     run =  1;       break;
00793     default:                            break;
00794     }
00795 
00796     /* カーソル確認/表示 */
00797     if(cursol <  0) cursol =  0;
00798     if(cursol > 17) cursol = 17;
00799     for(i = 0; i < 9; i++){
00800         VIDEO_locate(13, 2 + i);
00801         if(cursol == i) VIDEO_putch('>');
00802         else            VIDEO_putch(' ');
00803     }
00804     for(; i < 18; i++){
00805         VIDEO_locate(25, i - 7);
00806         if(cursol == i) VIDEO_putch('>');
00807         else            VIDEO_putch(' ');
00808     }
00809 
00810     /* 実行 */
00811     if(run == -1 || run == 1){
00812         switch(cursol){
00813         case  0:    ntsc.monitor.line += run;                   break;
00814         case  1:    ntsc.monitor.line_sync += run;              break;
00815         case  2:    ntsc.monitor.line_space_top += run;         break;
00816         case  3:    ntsc.monitor.line_video += run;             break;
00817         case  4:    ntsc.monitor.horizon_pulse += run;          break;
00818         case  5:    ntsc.monitor.serration_pulse += run;        break;
00819         case  6:    ntsc.monitor.equalizing_pulse += run;       break;
00820         case  7:    ntsc.monitor.left_space += run;             break;
00821         case  8:    ntsc.monitor.video_width += run;            break;
00822         case  9:    ntsc.superimpose.line += run;               break;
00823         case 10:    ntsc.superimpose.line_sync += run;          break;
00824         case 11:    ntsc.superimpose.line_space_top += run;     break;
00825         case 12:    ntsc.superimpose.line_video += run;         break;
00826         case 13:    ntsc.superimpose.horizon_pulse += run;      break;
00827         case 14:    ntsc.superimpose.serration_pulse += run;    break;
00828         case 15:    ntsc.superimpose.equalizing_pulse += run;   break;
00829         case 16:    ntsc.superimpose.left_space += run;         break;
00830         case 17:    ntsc.superimpose.video_width += run;        break;
00831         default:                                                break;
00832         }
00833     }
00834 
00835     /* 表示 */
00836     VIDEO_locate(14, 2);    VIDEO_putuint(ntsc.monitor.line, 5);
00837     VIDEO_locate(14, 3);    VIDEO_putuint(ntsc.monitor.line_sync, 5);
00838     VIDEO_locate(14, 4);    VIDEO_putuint(ntsc.monitor.line_space_top, 5);
00839     VIDEO_locate(14, 5);    VIDEO_putuint(ntsc.monitor.line_video, 5);
00840     VIDEO_locate(14, 6);    VIDEO_putuint(ntsc.monitor.horizon_pulse, 5);
00841     VIDEO_locate(14, 7);    VIDEO_putuint(ntsc.monitor.serration_pulse, 5);
00842     VIDEO_locate(14, 8);    VIDEO_putuint(ntsc.monitor.equalizing_pulse, 5);
00843     VIDEO_locate(14, 9);    VIDEO_putuint(ntsc.monitor.left_space, 5);
00844     VIDEO_locate(14,10);    VIDEO_putuint(ntsc.monitor.video_width, 5);
00845 
00846     VIDEO_locate(26, 2);    VIDEO_putuint(ntsc.superimpose.line, 5);
00847     VIDEO_locate(26, 3);    VIDEO_putuint(ntsc.superimpose.line_sync, 5);
00848     VIDEO_locate(26, 4);    VIDEO_putuint(ntsc.superimpose.line_space_top, 5);
00849     VIDEO_locate(26, 5);    VIDEO_putuint(ntsc.superimpose.line_video, 5);
00850     VIDEO_locate(26, 6);    VIDEO_putuint(ntsc.superimpose.horizon_pulse, 5);
00851     VIDEO_locate(26, 7);    VIDEO_putuint(ntsc.superimpose.serration_pulse, 5);
00852     VIDEO_locate(26, 8);    VIDEO_putuint(ntsc.superimpose.equalizing_pulse, 5);
00853     VIDEO_locate(26, 9);    VIDEO_putuint(ntsc.superimpose.left_space, 5);
00854     VIDEO_locate(26,10);    VIDEO_putuint(ntsc.superimpose.video_width, 5);
00855 
00856     return;
00857 }
00858 
00859 
00860 /*-------------------------------------------------------------------------------------------------
00861 外付けメータの設定
00862 -------------------------------------------------------------------------------------------------*/
00863 static  void SCREEN_setup_extmeter(void)
00864 {
00865     static unsigned char target = 0;
00866     static char cursol;
00867     char run = 0;
00868     unsigned int i;
00869 
00870     /* 画面初期化 */
00871     if(screen.screen_flag == SCREEN_INIT){
00872         screen.screen_flag = SCREEN_VIEW;
00873         screen.fps = 10;
00874         VIDEO_vram_clear(0x00);
00875         cursol = 0;
00876 
00877         target = extmeter.target;
00878 
00879         VIDEO_locate( 0, 0);    VIDEO_putstr("External Meter Setup");
00880 
00881         VIDEO_locate( 1, 2);    VIDEO_putstr("TARGET");
00882         VIDEO_locate( 1, 4);    VIDEO_putstr("0x0f");
00883         VIDEO_locate( 1, 5);    VIDEO_putstr("0x1f");
00884         VIDEO_locate( 1, 6);    VIDEO_putstr("0x2f");
00885         VIDEO_locate( 1, 7);    VIDEO_putstr("0x3f");
00886         VIDEO_locate( 1, 8);    VIDEO_putstr("0x4f");
00887         VIDEO_locate( 1, 9);    VIDEO_putstr("0x5f");
00888         VIDEO_locate( 1,10);    VIDEO_putstr("0x6f");
00889         VIDEO_locate( 1,11);    VIDEO_putstr("0x7f");
00890         VIDEO_locate(16, 4);    VIDEO_putstr("0x8f");
00891         VIDEO_locate(16, 5);    VIDEO_putstr("0x9f");
00892         VIDEO_locate(16, 6);    VIDEO_putstr("0xaf");
00893         VIDEO_locate(16, 7);    VIDEO_putstr("0xbf");
00894         VIDEO_locate(16, 8);    VIDEO_putstr("0xcf");
00895         VIDEO_locate(16, 9);    VIDEO_putstr("0xdf");
00896         VIDEO_locate(16,10);    VIDEO_putstr("0xef");
00897         VIDEO_locate(16,11);    VIDEO_putstr("0xff");
00898     }
00899 
00900     /* キーボード入力処理 */
00901     switch(SCREEN_key_get()){
00902     case KEY_UP:        cursol--;       break;
00903     case KEY_DOWN:      cursol++;       break;
00904     case KEY_LEFT:      run = -1;       break;
00905     case KEY_RIGHT:     run =  1;       break;
00906     default:                            break;
00907     }
00908 
00909     /* カーソル確認/表示 */
00910     if(cursol <  0) cursol =  0;
00911     if(cursol > 17) cursol = 17;
00912     for(i = 0; i < 10; i++){
00913         VIDEO_locate( 0, 2 + i);
00914         if(cursol == i) VIDEO_putch('>');
00915         else            VIDEO_putch(' ');
00916     }
00917     for(; i < 18; i++){
00918         VIDEO_locate(15, 4 + i - 10);
00919         if(cursol == i) VIDEO_putch('>');
00920         else            VIDEO_putch(' ');
00921     }
00922 
00923     /* 実行 */
00924     switch(cursol){
00925     case  0:
00926         extmeter.target = target;
00927         if(run == -1 || run == 1){
00928             target += run;
00929             if(target < 1) target = 1;
00930             if(target > 6) target = 6;
00931             EXTMETER_init(target);
00932         }
00933         break;
00934 
00935     case  1:
00936         extmeter.target = target;
00937         break;
00938 
00939     default:
00940         extmeter.target  = EXTMETER_SETTING;
00941         extmeter.setting = ((cursol - 2) << 4) + 0x0f;
00942         if(run == -1 || run == 1){
00943             switch(target){
00944             case EXTMETER_ENGINE:       extmeter.map[ cursol - 2 ] += 100 * run;        break;
00945             case EXTMETER_BOOST:        extmeter.map[ cursol - 2 ] += 0.01 * run;       break;
00946             case EXTMETER_THROTTLE:     extmeter.map[ cursol - 2 ] += 0.1 * run;        break;
00947             case EXTMETER_SPEED:
00948             case EXTMETER_COOLANT:
00949             case EXTMETER_INTAKEAIR:
00950                                         extmeter.map[ cursol - 2 ] += 1 * run;          break;
00951             default:                                                                    break;
00952             }
00953         }
00954 
00955         break;
00956     }
00957 
00958     /* 表示 */
00959     VIDEO_locate( 8, 2);
00960     switch(extmeter.target){
00961     case EXTMETER_SETTING:      VIDEO_putstr("-SETTING MODE-");     break;
00962     case EXTMETER_SPEED:        VIDEO_putstr("Vechile Speed ");     break;
00963     case EXTMETER_ENGINE:       VIDEO_putstr("Engine Speed  ");     break;
00964     case EXTMETER_BOOST:        VIDEO_putstr("Boost Meter   ");     break;
00965     case EXTMETER_THROTTLE:     VIDEO_putstr("Throttle      ");     break;
00966     case EXTMETER_COOLANT:      VIDEO_putstr("Coolant Temp  ");     break;
00967     case EXTMETER_INTAKEAIR:    VIDEO_putstr("IntakeAir Temp");     break;
00968     default:                                                        break;
00969     }
00970     for(i = 0; i < 8; i++){
00971         VIDEO_locate( 6, 4 + i);
00972         VIDEO_putdouble(extmeter.map[i], 4, 2);
00973     }
00974     for(; i < 16; i++){
00975         VIDEO_locate(21, 4 + i - 8);
00976         VIDEO_putdouble(extmeter.map[i], 4, 2);
00977     }
00978 
00979     return;
00980 }
00981 
00982 
00983 /*-------------------------------------------------------------------------------------------------
00984 環境設定の保存と読み出し
00985 -------------------------------------------------------------------------------------------------*/
00986 static  void SCREEN_setup_config(void)
00987 {
00988     static char cursol;
00989     char run = 0;
00990     unsigned int i;
00991 
00992     /* 画面初期化 */
00993     if(screen.screen_flag == SCREEN_INIT){
00994         screen.screen_flag = SCREEN_VIEW;
00995         screen.fps = 5;
00996         VIDEO_vram_clear(0x00);
00997 
00998         cursol = 0;
00999 
01000         VIDEO_locate( 0, 0);    VIDEO_putstr("Configuration Setup");
01001 
01002         VIDEO_locate( 1, 2);    VIDEO_putstr("Load");
01003         VIDEO_locate( 1, 3);    VIDEO_putstr("Save");
01004         VIDEO_locate( 1, 4);    VIDEO_putstr("Initialize");
01005     }
01006 
01007     /* キーボード入力処理 */
01008     switch(SCREEN_key_get()){
01009     case KEY_UP:        cursol--;       break;
01010     case KEY_DOWN:      cursol++;       break;
01011     case KEY_ENTER:     run = 1;        break;
01012     default:                            break;
01013     }
01014 
01015     /* カーソル確認/表示 */
01016     if(cursol < 0) cursol = 0;
01017     if(cursol > 2) cursol = 2;
01018     for(i = 0; i < 3; i++){
01019         VIDEO_locate( 0, 2 + i);
01020         if(cursol == i) VIDEO_putch('>');
01021         else            VIDEO_putch(' ');
01022     }
01023 
01024     /* 実行 */
01025     if(run == 1){
01026         switch(cursol){
01027         case 0:
01028             VIDEO_locate( 5, 6);        VIDEO_putstr("Now Loading...");
01029             if(CONFIG_load()){
01030                 VIDEO_locate( 5, 6);    VIDEO_putstr("Load Success  ");
01031             } else {
01032                 VIDEO_locate( 5, 6);    VIDEO_putstr("Load Failed   ");
01033             }
01034             screen.screen = 0x0a;
01035             screen.screen_flag = SCREEN_VIEW;
01036             break;
01037 
01038         case 1:
01039             screen.screen = backup;
01040             screen.screen_flag = SCREEN_INIT;
01041             VIDEO_locate( 5, 6);        VIDEO_putstr("Now Saving... ");
01042             if(CONFIG_save()){
01043                 VIDEO_locate( 5, 6);    VIDEO_putstr("Save Success  ");
01044             } else {
01045                 VIDEO_locate( 5, 6);    VIDEO_putstr("Save Failed   ");
01046             }
01047             screen.screen = 0x0a;
01048             screen.screen_flag = SCREEN_VIEW;
01049             break;
01050 
01051         case 2:
01052             SSM_init();
01053             SCREEN_init();
01054             VIDEO_init();
01055             screen.screen = 0x0a;
01056             screen.screen_flag = SCREEN_INIT;
01057             EXTMETER_init(EXTMETER_BOOST);
01058             VIDEO_locate( 5, 6);        VIDEO_putstr("Init Success  ");
01059             break;
01060 
01061         default:
01062             break;
01063         }
01064     }
01065 
01066 
01067     return;
01068 }
01069 
01070 
01071 /*-------------------------------------------------------------------------------------------------
01072 デバック用情報表示画面
01073 -------------------------------------------------------------------------------------------------*/
01074 static  void SCREEN_debug(void)
01075 {
01076     /* 画面初期化 */
01077     if(screen.screen_flag == SCREEN_INIT){
01078         screen.screen_flag = SCREEN_VIEW;
01079         screen.fps = 10;
01080         VIDEO_vram_clear(0x00);
01081 
01082         VIDEO_locate( 0, 0);    VIDEO_putstr("DEBUG Monitor");
01083 
01084         VIDEO_locate( 0, 2);    VIDEO_putstr("PortA");
01085         VIDEO_locate( 0, 3);    VIDEO_putstr("PortB");
01086         VIDEO_locate( 0, 4);    VIDEO_putstr("DAC");
01087         VIDEO_locate( 0, 5);    VIDEO_putstr("ADC-0");
01088         VIDEO_locate( 0, 6);    VIDEO_putstr("ADC-1");
01089         VIDEO_locate( 0, 7);    VIDEO_putstr("ADC-2");
01090         VIDEO_locate( 0, 9);    VIDEO_putstr("Last");
01091         VIDEO_locate( 0,10);    VIDEO_putstr("Cycle");
01092         VIDEO_locate( 0,11);    VIDEO_putstr("Error");
01093 
01094         VIDEO_locate(11, 2);    VIDEO_putstr("Speed");
01095         VIDEO_locate(11, 3);    VIDEO_putstr("Engine");
01096         VIDEO_locate(11, 4);    VIDEO_putstr("Throttle");
01097         VIDEO_locate(11, 5);    VIDEO_putstr("Boost");
01098         VIDEO_locate(11, 6);    VIDEO_putstr("Gear");
01099         VIDEO_locate(11, 7);    VIDEO_putstr("Temp");
01100         VIDEO_locate(11, 8);    VIDEO_putstr("Battery");
01101         VIDEO_locate(11, 9);    VIDEO_putstr("MAF");
01102         VIDEO_locate(11,10);    VIDEO_putstr("AF Rate");
01103         VIDEO_locate(11,11);    VIDEO_putstr("IG/Knock");
01104 
01105         VIDEO_locate(26, 2);    VIDEO_putstr("km/h");
01106         VIDEO_locate(26, 3);    VIDEO_putstr("rpm");
01107         VIDEO_locate(26, 4);    VIDEO_putch('%');
01108         VIDEO_locate(26, 5);    VIDEO_putstr("kg/cm2");
01109         VIDEO_locate(26, 6);    VIDEO_putstr("Shift");
01110         VIDEO_locate(26, 7);    VIDEO_putstr("C");
01111         VIDEO_locate(26, 8);    VIDEO_putstr("V");
01112         VIDEO_locate(26, 9);    VIDEO_putstr("g/s");
01113         VIDEO_locate(26,10);    VIDEO_putstr("A/F");
01114         VIDEO_locate(26,11);    VIDEO_putstr("deg");
01115     }
01116 
01117     SCREEN_keybuf_clear();
01118 
01119     /* 描画 */
01120     VIDEO_locate( 6, 2);
01121     VIDEO_puthex(PORTA >> 8);   VIDEO_puthex(PORTA);
01122 
01123     VIDEO_locate( 6, 3);
01124     VIDEO_puthex(PORTB >> 8);   VIDEO_puthex(PORTB);
01125 
01126     VIDEO_locate( 6, 4);
01127     VIDEO_putch('0');   VIDEO_putch('0');   VIDEO_puthex(dac);
01128 
01129     VIDEO_locate( 6, 5);
01130     VIDEO_puthex(adc.adc[0] >> 8);  VIDEO_puthex(adc.adc[0]);
01131 
01132     VIDEO_locate( 6, 6);
01133     VIDEO_puthex(adc.adc[1] >> 8);  VIDEO_puthex(adc.adc[1]);
01134 
01135     VIDEO_locate( 6, 7);
01136     VIDEO_puthex(adc.adc[2] >> 8);  VIDEO_puthex(adc.adc[2]);
01137 
01138     VIDEO_locate( 6, 9);
01139     VIDEO_puthex(ssm.last >> 8);    VIDEO_puthex(ssm.last);
01140 
01141     VIDEO_locate( 6,10);
01142     VIDEO_puthex(ssm.cycle >> 8);   VIDEO_puthex(ssm.cycle);
01143 
01144     VIDEO_locate( 6,11);
01145     VIDEO_puthex(ssm.error >> 8);   VIDEO_puthex(ssm.error);
01146 
01147     VIDEO_locate(22, 2);
01148     VIDEO_putuint(ssm_data.speed, 3);
01149 
01150     VIDEO_locate(21, 3);
01151     VIDEO_putuint(ssm_data.engine, 4);
01152 
01153     VIDEO_locate(19, 4);
01154     VIDEO_putdouble(ssm_data.throttle, 3,1);
01155 
01156     VIDEO_locate(20, 5);
01157     VIDEO_putdouble(ssm_data.boost, 0, 2);
01158 
01159     VIDEO_locate(24, 6);
01160     VIDEO_putuint(ssm_data.shift, 1);
01161 
01162     VIDEO_locate(20, 7);
01163     VIDEO_putuint(ssm_data.coolant, 2);
01164     VIDEO_putch('/');
01165     VIDEO_putuint(ssm_data.intakeair, 2);
01166 
01167     VIDEO_locate(20, 8);
01168     VIDEO_putdouble(ssm_data.battery, 2, 1);
01169 
01170     VIDEO_locate(20, 9);
01171     VIDEO_putuint(ssm_data.maf, 5);
01172 
01173     VIDEO_locate(20,10);
01174     VIDEO_putdouble(ssm_data.afr, 2, 1);
01175 
01176     VIDEO_locate(20,11);
01177     VIDEO_putuint(ssm_data.ignition, 2);
01178     VIDEO_putch('/');
01179     VIDEO_putuint(ssm_data.knock, 2);
01180 
01181     return;
01182 }
01183 
01184 
01185 /*-------------------------------------------------------------------------------------------------
01186 基板情報表示画面
01187 -------------------------------------------------------------------------------------------------*/
01188 static  void SCREEN_version(void)
01189 {
01190     /* 画面初期化 */
01191     if(screen.screen_flag == SCREEN_INIT){
01192         screen.screen_flag = SCREEN_VIEW;
01193         screen.fps = 5;
01194         VIDEO_vram_clear(0x00);
01195 
01196         VIDEO_locate(0, 0);
01197         VIDEO_putstr("Product Infomation");
01198 
01199         VIDEO_locate(0, 2);
01200         VIDEO_putstr("Board name    : ");
01201         VIDEO_putstr(info.board_name);
01202 
01203         VIDEO_locate(0, 3);
01204         VIDEO_putstr("Board build   : Koki ");
01205         VIDEO_putuint(info.board_year, 4);  VIDEO_putch('/');   VIDEO_putuint(info.board_month, 2); VIDEO_putch('/');   VIDEO_putuint(info.board_day, 2);
01206 
01207         VIDEO_locate(0, 4);
01208         VIDEO_putstr("Firmware Ver. : ");
01209         VIDEO_putuint(info.firmware_major, 2);  VIDEO_putch('.');   VIDEO_putuint(info.firmware_minor, 2);  VIDEO_putch('.');   VIDEO_putuint(info.firmware_revision, 3);
01210 
01211         VIDEO_locate(0, 5);
01212         VIDEO_putstr("Firmware build: Koki ");
01213         VIDEO_putuint(info.firmware_year, 4);   VIDEO_putch('/');   VIDEO_putuint(info.firmware_month, 2);  VIDEO_putch('/');   VIDEO_putuint(info.firmware_day, 2);
01214 
01215         VIDEO_locate(0, 6);
01216         VIDEO_putstr("Board S/N     : ");
01217         VIDEO_putstr(info.serial);
01218 
01219         VIDEO_locate(0, 8); VIDEO_putstr(info.project);
01220         VIDEO_locate(0, 9); VIDEO_putstr(info.web);
01221         VIDEO_locate(0,10); VIDEO_putstr(info.mail);
01222         VIDEO_locate(0,11); VIDEO_putstr(info.copyright);
01223 
01224     }
01225 
01226     SCREEN_keybuf_clear();
01227     return;
01228 }
01229 
01230 
01231 /*-------------------------------------------------------------------------------------------------
01232 おまけ、23/3 ライフゲームもどき 兼 スクリーンセーバー
01233 -------------------------------------------------------------------------------------------------*/
01234 static  void SCREEN_lifegame(void)
01235 {
01236     static unsigned int y, stage;
01237     unsigned int x, check;
01238 
01239     /* 画面初期化 */
01240     if(screen.screen_flag == SCREEN_INIT){
01241         screen.screen_flag = SCREEN_VIEW;
01242         screen.fps = 60;
01243         y = 1;
01244         stage = 0;
01245     }
01246 
01247     SCREEN_keybuf_clear();
01248 
01249     if(y >= NTSC_HEIGHT - 1){
01250         y = 1;
01251         stage++;
01252     }
01253     if(y < (unsigned int)FONTX2_get_ascii_height()){
01254         VIDEO_locate(27, 0);
01255         VIDEO_putuint(stage, 5);
01256     }
01257 
01258     /* 探索 */
01259     for(x = 1; x < NTSC_WIDTH - 1; x++){
01260         /* メモリに余裕がないので、ラインを捨てながら描く */
01261         check = VIDEO_get_point(x - 1, y - 1)
01262               + VIDEO_get_point(x - 1, y    )
01263               + VIDEO_get_point(x - 1, y + 1)
01264               + VIDEO_get_point(x    , y - 1)
01265               + VIDEO_get_point(x    , y + 1)
01266               + VIDEO_get_point(x + 1, y - 1)
01267               + VIDEO_get_point(x + 1, y    )
01268               + VIDEO_get_point(x + 1, y + 1);
01269 
01270         if(check == 3){
01271             VIDEO_point(x,y);
01272         } else {
01273             if(check != 2) VIDEO_point_(x,y);
01274         }
01275     }
01276 
01277     y++;
01278 
01279     return;
01280 }
01281 
01282 
01283 /*-------------------------------------------------------------------------------------------------
01284 使わないキーを読み込み、バッファを捨てる.
01285 -------------------------------------------------------------------------------------------------*/
01286 static  void SCREEN_keybuf_clear(void)
01287 {
01288     switch(PS2_key_check()){
01289     case KEY_F1:
01290     case KEY_F2:
01291     case KEY_F3:
01292     case KEY_F4:
01293     case KEY_F5:
01294     case KEY_F6:
01295     case KEY_F7:
01296     case KEY_F8:
01297     case KEY_F9:
01298     case KEY_F10:
01299     case KEY_F11:
01300     case KEY_F12:
01301     case KEY_PAGEUP:
01302     case KEY_PAGEDOWN:
01303     case KEY_DEL:
01304     case KEY_HOME:
01305         break;
01306 
01307     default:
01308         PS2_key_get();
01309         break;
01310     }
01311 
01312     return;
01313 }
01314 
01315 
01316 /*-------------------------------------------------------------------------------------------------
01317 各スクリーンでキー入力が必要なときに使う
01318 -------------------------------------------------------------------------------------------------*/
01319 static  unsigned char SCREEN_key_get(void)
01320 {
01321     switch(PS2_key_check()){
01322     case KEY_F1:
01323     case KEY_F2:
01324     case KEY_F3:
01325     case KEY_F4:
01326     case KEY_F5:
01327     case KEY_F6:
01328     case KEY_F7:
01329     case KEY_F8:
01330     case KEY_F9:
01331     case KEY_F10:
01332     case KEY_F11:
01333     case KEY_F12:
01334     case KEY_PAGEUP:
01335     case KEY_PAGEDOWN:
01336     case KEY_DEL:
01337     case KEY_HOME:
01338         return(KEY_NOP);
01339         break;
01340 
01341     default:
01342         return(PS2_key_get());
01343         break;
01344     }
01345 
01346     /* ここにきたらバグ */
01347     return(KEY_NOP);
01348 }

OpenSSMに対してThu Sep 9 2010 00:03:05に生成されました。  doxygen 1.7.1