em ko hieu doan code tren mong cac pro giup do
void EF1(unsigned int tre,unsigned char chieu, unsigned char chedo, char loai)
{ //Nhap nhay cung sang, tat
unsigned char m[]={128,64,160,80,168,84,170,85};
unsigned char n[]={1,2,5,10,21,42,85,170};
unsigned char k,a=1,b=31,e=0,f=0,g=0,h=0;
if(chedo==sang)P1=P2=P3=P0=0;
else e=f=g=h=0xaa;
while(a<=b)
{
if(chedo==sang) k=a;
else k=b;
if((chieu==thuan))
{
if(k<=7){e=n[k];f=0;}
if((k>=8)&&(k<=15))
{
e=~e;
g=0;
f=n[k-8];
}
if((k>=16)&&(k<=23))
{
e=f=~e;
h=0;
g=n[k-16];
}
if((k>=24)&&(k<=31))
{
e=g=f=~e;
h=n[k-24];
}
}
else
{
if(k<=7) {h=m[k];g=0;}
if((k>=8)&&(k<=15))
{
h=~h;
f=0;
g=m[k-8];
}
if((k>=16)&&(k<=23))
{
h=g=~h;
e=0;
f=m[k-16];
}
if((k>=24)&&(k<=31))
{
g=f=h=~h;
e=m[k-24];
}
}
if(loai==sang){P1=~e;P2=~f;P3=~g;P0=~h;}
if(loai==tat){P1=e;P2=f;P3=g;P0=h;}
delayt(tre);
if(chedo==sang) a++;
else b--;
}
void EF1(unsigned int tre,unsigned char chieu, unsigned char chedo, char loai)
{ //Nhap nhay cung sang, tat
unsigned char m[]={128,64,160,80,168,84,170,85};
unsigned char n[]={1,2,5,10,21,42,85,170};
unsigned char k,a=1,b=31,e=0,f=0,g=0,h=0;
if(chedo==sang)P1=P2=P3=P0=0;
else e=f=g=h=0xaa;
while(a<=b)
{
if(chedo==sang) k=a;
else k=b;
if((chieu==thuan))
{
if(k<=7){e=n[k];f=0;}
if((k>=8)&&(k<=15))
{
e=~e;
g=0;
f=n[k-8];
}
if((k>=16)&&(k<=23))
{
e=f=~e;
h=0;
g=n[k-16];
}
if((k>=24)&&(k<=31))
{
e=g=f=~e;
h=n[k-24];
}
}
else
{
if(k<=7) {h=m[k];g=0;}
if((k>=8)&&(k<=15))
{
h=~h;
f=0;
g=m[k-8];
}
if((k>=16)&&(k<=23))
{
h=g=~h;
e=0;
f=m[k-16];
}
if((k>=24)&&(k<=31))
{
g=f=h=~h;
e=m[k-24];
}
}
if(loai==sang){P1=~e;P2=~f;P3=~g;P0=~h;}
if(loai==tat){P1=e;P2=f;P3=g;P0=h;}
delayt(tre);
if(chedo==sang) a++;
else b--;
}