Zeyu Feng 201377605

Dependencies:   mbed

On Minerva

Revision:
22:cded0cd8e1c9
Parent:
20:a36ab1560e73
--- a/Interface/Interface.cpp	Fri May 22 04:49:26 2020 +0000
+++ b/Interface/Interface.cpp	Fri May 22 16:07:02 2020 +0000
@@ -38,6 +38,9 @@
 
 void Interface::Welcome(N5110 &lcd,Gamepad &pad)
 {
+    // initialise record
+    _record.x = 0;
+    _record.y = 0;
     // start game after pressing the start botton
     while (!pad.start_pressed()) 
     {
@@ -67,7 +70,7 @@
         lcd.printString("   Start(Hell)",0,2);
         lcd.printString("  user-defined",0,3);
         lcd.printString("   Instruction",0,4);
-        lcd.printString("         Exit",0,5);
+        lcd.printString("       Record",0,5);
         _d = pad.get_direction();
         // in order to easily control Joystick, pointer move upward in a large angle
         if(_d == N||_d ==NE||_d==NW){
@@ -186,15 +189,28 @@
     _count_down--;
 }
 
-void Interface::exit(N5110 &lcd,Gamepad &pad)
+void Interface::update_record(float increment,int max)
+{
+    if(increment > _record.x||(int(increment)==int(_record.x)&& max > _record.y)){
+        _record.x = increment;
+        _record.y = max;
+    }
+}
+
+void Interface::record(N5110 &lcd,Gamepad &pad)
 {
     lcd.clear();
     pad.init();
     pad.tone(10,0.05);
     pad.set_bpm(0);
+    sprintf(_buffer1,"  %.1f shots/s",_record.x*6);
+    sprintf(_buffer2,"  with Max.%.0f ",_record.y);
     while(!pad.B_pressed()){
-        lcd.printString(" Press B back ",0,2);
-        lcd.printString("   to menu   ",0,3);
+        lcd.printString("Record",23,0);
+        lcd.printString(_buffer1,0,1);
+        lcd.printString(_buffer2,0,2);
+        lcd.printString(" Press B back ",0,4);
+        lcd.printString("   to menu   ",0,5);
         lcd.refresh();
         wait(0.1);
     }