LPL夏季赛:前期绕后包抄打出大优 DMO击败SN扳平比分
142
2024 / 10 / 04
Led & Beep & Delay底层模板
void Led_Disp(unsigned char add,unsigned char enable)
{
static unsigned char temp = 0x00;
static unsigned char temp_old = 0xff;
if(enable)
{
temp |= 0x01 << add;
}
else temp &= ~(0x01 << add);
if(temp != temp_old) //消音
{
P0 = ~temp;
P2 = P2 & 0x1f | 0x80;
P2 = P2 & 0x1f;
temp_old = temp;
}
}
void Beep(unsigned char enable)
{
static unsigned char temp = 0x00;
static unsigned char temp_old = 0xff;
if(enable)
{
temp |= 0x40;
}
else temp &= ~0x40;
if(temp != temp_old)
{
P0 = temp;
P2 = P2 & 0x1f | 0xa0;
P2 = P2 & 0x1f;
temp_old = temp;
}
}
void Delay(unsigned char add,unsigned char enable)
{
static unsigned char temp = 0x00;
static unsigned char temp_old = 0xff;
if(enable)
{
temp |= 0x10;
}
else temp &= ~0x10;
if(temp != temp_old)
{
P0 = ~temp;
P2 = P2 & 0x1f | 0xa0;
P2 = P2 & 0x1f;
temp_old = temp;
}
}
发表评论
暂时没有评论,来抢沙发吧~