To Record the time of the car

Dependencies:   mbed TextLCD

Revision:
4:1300ca51fc75
Parent:
3:70ce5fd299bb
Child:
5:a897228b7306
--- a/main.cpp	Tue Aug 11 17:59:44 2020 +0000
+++ b/main.cpp	Tue Aug 11 23:15:01 2020 +0000
@@ -8,7 +8,7 @@
     #define BUTTON_DEBOUNCE       0.3f
     #define LCD_SHOW_PERIOD       3.0f           //show last cycle for 2 sec
     #define SENSOR_IN_DEBOUNCE    0.2f
-    #define NVIC_RESET_PROTECT    4.0f           //all sys reset by pull blue button(button 2) for more than 4 seconds
+    #define NVIC_RESET_PROTECT    3.0f           //all sys reset by pull blue button(button 2) for more than 4 seconds
 //Define-Don't Change
     #if(DEBUG == 2 && NO_DELAY == 1)
     #define NO_DELAY 0
@@ -21,7 +21,7 @@
 #else 
     #define CYCLE_TIME_PROTECT    1.0f
 #endif
-    #define ENDURANCE_CYCLE         20
+    #define ENDURANCE_CYCLE         11
     #define SKIDPAD_CYCLE            4 
 
 //RF CMD
@@ -51,13 +51,13 @@
     I2C i2c_lcd(PB_9,PB_8);                     // SDA,SCL 
     TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD16x2);     //0x40 for all short(blue lcd) , 0x4E for A1 to A3 open(green lcd) - I2C Address
 //Sensor
-//#if(DEBUG)
+#if(DEBUG == 1)
     DigitalOut  sensor_com(PA_8,1);             // D7
     InterruptIn SENSOR_IT(PB_4,PullDown);      //  D5
-//#else
-//    DigitalOut  sensor_com(PB_2,1);
-//    InterruptIn SENSOR_IT(PB_1,PullDown);
-//#endif
+#else
+    DigitalOut  sensor_com(PB_2,1);
+    InterruptIn SENSOR_IT(PB_1,PullDown);
+#endif
 //BT
     Serial bt (PA_0,PA_1,115200);              // Serial_4 tx,rx
     DigitalOut key(PC_1,0);                    // not AT Mode
@@ -205,10 +205,18 @@
         lcd.locate(0,0);
         lcd.printf("Set up ok!"); 
         if(bt_state.read()){
+              bt.printf("Mode 0 -> Single Cycle\r\n");
+              bt.printf("Mode 1 -> Accleration \r\n");
+              bt.printf("Mode 2 -> Skidpad     \r\n");
+              bt.printf("Mode 3 -> Endurance:%d\r\n\r\n",ENDURANCE_CYCLE);
               bt.printf("NTHU RACING TIME RECORDER SET UP DONE\r\n");
               bt.printf("#####################################\r\n");
         }
         else{
+              pc.printf("Mode 0 -> Single Cycle\r\n");
+              pc.printf("Mode 1 -> Accleration \r\n");
+              pc.printf("Mode 2 -> Skidpad     \r\n");
+              pc.printf("Mode 3 -> Endurance:%d\r\n",ENDURANCE_CYCLE);
               pc.printf("NTHU RACING TIME RECORDER SET UP DONE\r\n");
               pc.printf("#####################################\r\n");
         }
@@ -373,7 +381,8 @@
                 if(cycle == SKIDPAD_CYCLE && mode == 2 ||  cycle == ENDURANCE_CYCLE && mode == 3){
                     pc.printf("Mode %d End & Reset\r\n",mode);
                     bt_end_flag = 1;
-                }   
+                } 
+                else if(mode == 1) bt_end_flag = 1;
             }
         }
         if(last_rf_state != rf_state){