1、uchar code dat324=0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x16,0x26,0x36,0x46,0x56,0x66,0x65,0x64,0x63,0x62,0x61,0x60,0x50,0x40,0x30,0x20,0x10;/*3p char*/uchar code table_3p38=0xff,0x89,0xf5,0x93,0x93,0xf5,0x89,0xff,0x0e,0x1f,0x3f,0x7e,0x7e,0x3f,0x1f,0x0e,0x18,0x3c,0x7e,0xff,0x18,0x18,0x18,0x18;/*initial
2、iztionThat is to initialize the program .It is write to set the timer in c52 mcu.So the program can renovate the led_3d_cube in fixed time use the interrupt function.*/void sinter() IE=0x82; TCON=0x01; TH0=0xc0; TL0=0; TR0=1;void delay5us(void) /误差 -0.026765046296us STC 1T 22.1184Mhz unsigned char a
3、,b; for(b=7;b0;b-) for(a=2;aa-);void delay(uint i) while (i-) delay5us();/12t的mcu 注释这个延时即可/*To judge the num bit*/uchar judgebit(uchar num,uchar b) char n; num=num&(1=5) b+; return b;/*To figure out the absolute value*/uchar abss(char a) if (a(*b) t=(*a); (*a)=(*b); (*b)=t; /*The function is to figu
4、re out the max number and return it.*/uchar maxt(uchar a,uchar b,uchar c)b) a=b;c) a=c;void clear(char le) uchar i,j; for (j=0;j8;j+) for (i=0;i=-3;i-) if (i=0) displayji=displayji+1; if (i4) displayji+4=0; delay(speed);void point(uchar x,uchar y,uchar z,uchar le) uchar ch1,ch0; ch1=1x; ch0=ch1; if
5、(le) displayzy=displayzy|ch1; else displayzy=displayzy&ch0;void type(uchar cha,uchar y) uchar xx; for (xx=0;xxxx+) displayxxy=table_chachaxx;/*The first variable is the distance from the midpoint.The second is the layer.the third is the flash speed of the time between each two point.The forth is the
6、 enable io,it controls weather draw or claen.*/void cirp(char cpp,uchar dir,uchar le) uchar a,b,c,cp; if (cpp=0) if (dir) cp=127-cpp; cp=cpp; a=(datcp5)&0x07; b=(datcp2)& c=datcp&0x03; if (cpp63) c=7-c; point (a,b,c,le);void line(uchar x1,uchar y1,uchar z1,uchar x2,uchar y2,uchar z2,uchar le) char t
7、,a,b,c,a1,b1,c1,i; a1=x2-x1; b1=y2-y1; c1=z2-z1; t=maxt(abss(a1),abss(b1),abss(c1); a=x1*10; b=y1*10; c=z1*10; a1=a1*10/t; b1=b1*10/t; c1=c1*10/t;t; point(abs(a),abs(b),abs(c),le); a+=a1; b+=b1; c+=c1; point(x2,y2,z2,le);void box(uchar x1,uchar y1,uchar z1,uchar x2,uchar y2,uchar z2,uchar fill,uchar le) uchar i,j,t=0; max(&x1,&x2);y1,&y2);z1,&z2); for (i=x1;=x2; t|=1i; if (!le) t=t; if (fill) if (le) for (i=z1;=z2; for (j=y1;=y2; displayji|=t; displayji&=t; displayy1z1|=t
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1