From a019d644dbd22d5c4bf69036f3168f5dd2770855 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Mon, 6 Jun 2022 19:52:51 +0800 Subject: [PATCH] =?UTF-8?q?perf(MCU=E8=AF=BE=E8=AE=BE):=20=E6=98=BE?= =?UTF-8?q?=E8=91=97=E6=94=B9=E5=96=84=E6=93=8D=E4=BD=9C=E9=A1=BA=E7=95=85?= =?UTF-8?q?=E5=BA=A6=E4=BB=A5=E5=8F=8A=E5=B1=8F=E5=B9=95=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MCU/MCU_5 _Wave_Generate/delay.h | 1 + MCU/MCU_REAL _FINAL/MCU_1.uvopt | 16 ++++++++++++++-- MCU/MCU_REAL _FINAL/MCU_1.uvproj | 5 +++++ MCU/MCU_REAL _FINAL/delay.c | 27 +++++++++++++++++++++++---- MCU/MCU_REAL _FINAL/delay.h | 2 +- MCU/MCU_REAL _FINAL/main.c | 2 +- MCU/MCU_REAL _FINAL/menu.c | 14 ++++++-------- 7 files changed, 51 insertions(+), 16 deletions(-) diff --git a/MCU/MCU_5 _Wave_Generate/delay.h b/MCU/MCU_5 _Wave_Generate/delay.h index ae46cf9..7d8d1d9 100644 --- a/MCU/MCU_5 _Wave_Generate/delay.h +++ b/MCU/MCU_5 _Wave_Generate/delay.h @@ -3,5 +3,6 @@ void delay(int i); +void delayms(int n); //@11.0592MHz #endif \ No newline at end of file diff --git a/MCU/MCU_REAL _FINAL/MCU_1.uvopt b/MCU/MCU_REAL _FINAL/MCU_1.uvopt index ca2ce1a..19e6e61 100644 --- a/MCU/MCU_REAL _FINAL/MCU_1.uvopt +++ b/MCU/MCU_REAL _FINAL/MCU_1.uvopt @@ -213,7 +213,7 @@ 1 1 1 - 0 + 1 0 0 .\main.c @@ -273,7 +273,7 @@ 1 6 1 - 0 + 1 0 0 .\block.c @@ -373,6 +373,18 @@ 0 0 + + 2 + 14 + 5 + 0 + 0 + 0 + ..\MCU_5 _Wave_Generate\delay.h + delay.h + 0 + 0 + diff --git a/MCU/MCU_REAL _FINAL/MCU_1.uvproj b/MCU/MCU_REAL _FINAL/MCU_1.uvproj index 0feb962..9cd484a 100644 --- a/MCU/MCU_REAL _FINAL/MCU_1.uvproj +++ b/MCU/MCU_REAL _FINAL/MCU_1.uvproj @@ -446,6 +446,11 @@ 5 .\block.h + + delay.h + 5 + ..\MCU_5 _Wave_Generate\delay.h + diff --git a/MCU/MCU_REAL _FINAL/delay.c b/MCU/MCU_REAL _FINAL/delay.c index 983d71c..35f77ee 100644 --- a/MCU/MCU_REAL _FINAL/delay.c +++ b/MCU/MCU_REAL _FINAL/delay.c @@ -3,7 +3,26 @@ void delay(int n) -{int i, j; - for(i=n;i>0;i--) - for(j = 7; j > 0; j--); -} \ No newline at end of file +{ + int i, j; + for(i = n; i > 0; i--) + for(j = 7; j > 0; j--); +} + +void delayms(int n) //@11.0592MHz +{ + unsigned char i, j, k; + for(k = n; k > 0; k--) + { + _nop_(); + _nop_(); + _nop_(); + i = 11; + j = 190; + do + { + while (--j); + } + while (--i); + } +} diff --git a/MCU/MCU_REAL _FINAL/delay.h b/MCU/MCU_REAL _FINAL/delay.h index da40b5c..cb9e279 100644 --- a/MCU/MCU_REAL _FINAL/delay.h +++ b/MCU/MCU_REAL _FINAL/delay.h @@ -3,5 +3,5 @@ void delay(int i); -void delay100us(); +void delayms(int k); #endif \ No newline at end of file diff --git a/MCU/MCU_REAL _FINAL/main.c b/MCU/MCU_REAL _FINAL/main.c index 9195ad8..376947a 100644 --- a/MCU/MCU_REAL _FINAL/main.c +++ b/MCU/MCU_REAL _FINAL/main.c @@ -52,7 +52,7 @@ void time() interrupt 1 // if(PIN_4 == 0) { - delay(50); + delayms(15); if(PIN_4 == 0) opr = confirm; } diff --git a/MCU/MCU_REAL _FINAL/menu.c b/MCU/MCU_REAL _FINAL/menu.c index 482ce47..9400f60 100644 --- a/MCU/MCU_REAL _FINAL/menu.c +++ b/MCU/MCU_REAL _FINAL/menu.c @@ -102,17 +102,15 @@ void m_block(struct _menu* this) { opr = idle; moveLeftPiece(); - dropPiece(); - drawBlock(); - return; + drawBlock(); + return; } if(opr == right) { opr = idle; moveRightPiece(); - dropPiece(); - drawBlock(); - return; + drawBlock(); + return; } switch(blockGameStatus) { @@ -134,7 +132,7 @@ void m_block(struct _menu* this) dropPiece(); //若有需要,块下落 judgeBlock(); //若有需要,清除一行 drawBlock(); //绘制界面 - delay(800); + delayms(400); } @@ -148,7 +146,7 @@ void m_about(struct _menu* this) LAST = &M_ABOUT; drawNAME(); //绘制名字 - delay(5000); + delayms(2000); drawNUMBER(); //绘制学号 }