perf(MCU课设): 显著改善操作顺畅度以及屏幕响应速度

This commit is contained in:
iridiumR 2022-06-06 19:52:51 +08:00
parent b77d77f03b
commit a019d644db
7 changed files with 51 additions and 16 deletions

View file

@ -3,5 +3,6 @@
void delay(int i);
void delayms(int n); //@11.0592MHz
#endif

View file

@ -213,7 +213,7 @@
<GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\main.c</PathWithFileName>
@ -273,7 +273,7 @@
<GroupNumber>1</GroupNumber>
<FileNumber>6</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\block.c</PathWithFileName>
@ -373,6 +373,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>14</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\MCU_5 _Wave_Generate\delay.h</PathWithFileName>
<FilenameWithoutPath>delay.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
</ProjectOpt>

View file

@ -446,6 +446,11 @@
<FileType>5</FileType>
<FilePath>.\block.h</FilePath>
</File>
<File>
<FileName>delay.h</FileName>
<FileType>5</FileType>
<FilePath>..\MCU_5 _Wave_Generate\delay.h</FilePath>
</File>
</Files>
</Group>
</Groups>

View file

@ -3,7 +3,26 @@
void delay(int n)
{int i, j;
for(i=n;i>0;i--)
{
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);
}
}

View file

@ -3,5 +3,5 @@
void delay(int i);
void delay100us();
void delayms(int k);
#endif

View file

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

View file

@ -102,7 +102,6 @@ void m_block(struct _menu* this)
{
opr = idle;
moveLeftPiece();
dropPiece();
drawBlock();
return;
}
@ -110,7 +109,6 @@ void m_block(struct _menu* this)
{
opr = idle;
moveRightPiece();
dropPiece();
drawBlock();
return;
}
@ -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(); //绘制学号
}