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