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 delay(int i);
void delayms(int n); //@11.0592MHz
#endif #endif

View file

@ -213,7 +213,7 @@
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>1</FileNumber> <FileNumber>1</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\main.c</PathWithFileName> <PathWithFileName>.\main.c</PathWithFileName>
@ -273,7 +273,7 @@
<GroupNumber>1</GroupNumber> <GroupNumber>1</GroupNumber>
<FileNumber>6</FileNumber> <FileNumber>6</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\block.c</PathWithFileName> <PathWithFileName>.\block.c</PathWithFileName>
@ -373,6 +373,18 @@
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
</File> </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> </Group>
</ProjectOpt> </ProjectOpt>

View file

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

View file

@ -3,7 +3,26 @@
void delay(int n) 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--); 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 delay(int i);
void delay100us(); void delayms(int k);
#endif #endif

View file

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

View file

@ -102,7 +102,6 @@ void m_block(struct _menu* this)
{ {
opr = idle; opr = idle;
moveLeftPiece(); moveLeftPiece();
dropPiece();
drawBlock(); drawBlock();
return; return;
} }
@ -110,7 +109,6 @@ void m_block(struct _menu* this)
{ {
opr = idle; opr = idle;
moveRightPiece(); moveRightPiece();
dropPiece();
drawBlock(); drawBlock();
return; return;
} }
@ -134,7 +132,7 @@ void m_block(struct _menu* this)
dropPiece(); //若有需要,块下落 dropPiece(); //若有需要,块下落
judgeBlock(); //若有需要,清除一行 judgeBlock(); //若有需要,清除一行
drawBlock(); //绘制界面 drawBlock(); //绘制界面
delay(800); delayms(400);
} }
@ -148,7 +146,7 @@ void m_about(struct _menu* this)
LAST = &M_ABOUT; LAST = &M_ABOUT;
drawNAME(); //绘制名字 drawNAME(); //绘制名字
delay(5000); delayms(2000);
drawNUMBER(); //绘制学号 drawNUMBER(); //绘制学号
} }