From b77d77f03bfcf37c5fbbe920dd68fc340574b7eb Mon Sep 17 00:00:00 2001 From: iridiumR Date: Mon, 6 Jun 2022 19:36:45 +0800 Subject: [PATCH] =?UTF-8?q?perf(MCU=E8=AF=BE=E8=AE=BE):=20=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E5=BB=B6=E6=97=B6=E9=80=89=E9=A1=B9=E4=BB=A5=E5=8A=A0?= =?UTF-8?q?=E5=BC=BA=E6=98=BE=E7=A4=BA=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MCU/MCU_REAL _FINAL/delay.c | 22 +-------------- MCU/MCU_REAL _FINAL/main.c | 2 +- MCU/MCU_REAL _FINAL/menu.c | 56 ++++++++++++++++++------------------- 3 files changed, 30 insertions(+), 50 deletions(-) diff --git a/MCU/MCU_REAL _FINAL/delay.c b/MCU/MCU_REAL _FINAL/delay.c index e0c3247..983d71c 100644 --- a/MCU/MCU_REAL _FINAL/delay.c +++ b/MCU/MCU_REAL _FINAL/delay.c @@ -1,29 +1,9 @@ #include "delay.h" #include -void delay100us() -{ - unsigned char i, j; - - _nop_(); - _nop_(); - i = 2; - j = 15; - do - { - while (--j); - } while (--i); -} - -//void delay(int i) -//{ -// int j = i; -// for(;j>0;j--) -// delay100us(); -//} void delay(int n) {int i, j; for(i=n;i>0;i--) - for(j = 28; j > 0; j--); + for(j = 7; j > 0; j--); } \ No newline at end of file diff --git a/MCU/MCU_REAL _FINAL/main.c b/MCU/MCU_REAL _FINAL/main.c index 7280e41..9195ad8 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(10); + delay(50); if(PIN_4 == 0) opr = confirm; } diff --git a/MCU/MCU_REAL _FINAL/menu.c b/MCU/MCU_REAL _FINAL/menu.c index 54ab776..482ce47 100644 --- a/MCU/MCU_REAL _FINAL/menu.c +++ b/MCU/MCU_REAL _FINAL/menu.c @@ -17,7 +17,7 @@ Menu M_MAINMENU;// Menu M_BLOCK; //俄罗斯方块 Menu M_BALL; //弹球 -Menu M_STARTUP; +Menu M_ABOUT; Menu* NOW; //当前菜单指针 Menu* LAST = NULL; //上一个状态的菜单 @@ -26,29 +26,8 @@ enum OPR opr = idle; static unsigned char local[10] = {0}; unsigned char score = 0; extern enum GS blockGameStatus; -//初始化显示 -void m_startup(struct _menu* this) -{ - if(LAST != &M_STARTUP) - { - LAST = &M_STARTUP; - - drawNAME(); //绘制名字 - delay(1000); - drawNUMBER(); //绘制学号 - } - - if(opr == right) - { - opr = idle; - NOW = this->n; //转向下一菜单 - clear(); - } - -} - //主菜单 void m_mainmenu(struct _menu* this) { @@ -89,7 +68,7 @@ void m_mainmenu(struct _menu* this) NOW = &M_BALL; //转向下一菜单 break; case 3: - NOW = &M_STARTUP; //转向下一菜单 + NOW = &M_ABOUT; //转向下一菜单 break; } @@ -155,21 +134,42 @@ void m_block(struct _menu* this) dropPiece(); //若有需要,块下落 judgeBlock(); //若有需要,清除一行 drawBlock(); //绘制界面 - delay(200); - + delay(800); } + +//关于页 +void m_about(struct _menu* this) +{ + + + if(LAST != &M_ABOUT) + { + LAST = &M_ABOUT; + + drawNAME(); //绘制名字 + delay(5000); + drawNUMBER(); //绘制学号 + } + + if(opr == confirm) + { + opr = idle; + NOW = &M_MAINMENU; //转向下一菜单 + clear(); + } +} + void menuInit() { - M_STARTUP.n = &M_MAINMENU; - M_STARTUP.f = m_startup; M_MAINMENU.f = m_mainmenu; M_BLOCK.f = m_block; + M_ABOUT.f = m_about; #ifdef DEBUG_MODE NOW = &M_DEBUG; #else - NOW = &M_STARTUP; + NOW = &M_MAINMENU; #endif }