perf(MCU课设): 更改延时选项以加强显示效果

This commit is contained in:
iridiumR 2022-06-06 19:36:45 +08:00
parent 81d8da0747
commit b77d77f03b
3 changed files with 30 additions and 50 deletions

View file

@ -1,29 +1,9 @@
#include "delay.h"
#include <intrins.h>
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--);
}

View file

@ -52,7 +52,7 @@ void time() interrupt 1 //
if(PIN_4 == 0)
{
delay(10);
delay(50);
if(PIN_4 == 0)
opr = confirm;
}

View file

@ -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
}