基于stc51單片機(jī)的光立方c語(yǔ)言源代碼 作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對(duì)面交流海量資料庫(kù)查詢(xún) 收藏 void shandian(char v){char i,j;uchar a[64];for(i=0;i<64;i++)a[i]=tab_shandian[64*21+i];for(i=0;i<22;i++)zhen(tab_shandian+64*i,v);for(i=0;i<22;i++){for(j=0;j<64;j++)a[j]=a[j]&(~tab_shandian[64*i+j]);zhen(a,v);}}void cut(){uchar a[64]={0};char i;for(i=0;i<4;i++){a[i*8+7]=0xff;a[(7-i)*8+7]=0xff;zhen(a,8);}zhen(a,30);for(i=3;i>=0;i--){a[i*8+7]=0;a[(7-i)*8+7]=0;zhen(a,8);}}void shensuo(uchar v){char i,j;uchar a[64]={0};for(i=0;i<64;i++)a[i]=0xff;for(i=0;i<7;i++){move(a,0,0,1);zhen(a,v);}for(i=0;i<7;i++){move(a,0,1,1);for(j=0;j<64;j++)a[j]|=0x01;zhen(a,v);}for(i=0;i<7;i++){move(a,2,0,1);zhen(a,v);}for(i=0;i<7;i++){move(a,2,1,1);for(j=0;j<8;j++)a[j]|=0xff;zhen(a,v);}for(i=7;i>0;i--){for(j=0;j<8;j++)a[j*8+i]=0;zhen(a,v);}for(i=1;i<8;i++){for(j=0;j<8;j++)a[j*8+i]|=0xff;zhen(a,v);}}void linkpc1(char v){uchar i,a[64]={0};for(i=0;i<7;i++)a[7*8+i]=0xff;for(i=0;i<8;i++){move(a,2,0,1);zhen(a,v);}}void link00(){uchar a[64]={0};char i;for(i=10;i>7;i--){zhen(bianxing_table+i*64,70);}produce_cube(a,6);move(a,1,1,1);move(a,0,1,1);zhen(a,110);produce_cube(a,8);zhen(a,110);}void link_jb0(char v){uchar a[64]={0};char i;for(i=0;i<64;i++){a[i]=0x80;zhen(a,v);}}int STC_ADC(){uchar i;ADC_RES=0;ADC_RESL=0;ADC_CONTR=0x88;i=3;while(i--);while(1) {if(ADC_CONTR&0x10) break;}ADC_CONTR=0x80;return(ADC_RESL+ADC_RES<<2);}short sqrt_16( unsigned long M) {unsigned int N,i;unsigned long tmp,ttp; if(M==0) return 0;N=0;tmp=(M>>30); M<<=2;if(tmp>1) {N++; tmp-=N;}for(i=15;i>0;i--) {N<<=1; tmp<<=2;tmp+=(M>>30); ttp=N;ttp=(ttp<<1)+1;M<<=2;if(tmp>=ttp) {tmp-=ttp;N++;} }return N;}void FFT(){int xdata i,bb,j,k,p;int max,a[6];int xdata TR,TI,temp;for(i=0; i<64;i++){Real[BRTable[i]]=STC_ADC();Image[i]=0;}for(i=1;i<=6;i++) { bb=1;bb<<=(i-1); for(j=0;j<=bb-1;j++) { p=1;p<<=(6-i); p=p*j;for(k=j;k<64;k=k+2*bb) { key_amenu_scan(); key_out_scan();TR = Real[k]; TI = Image[k];temp=Real[k+bb];Real[k]=Real[k]+((Real[k+bb]*cos_tabb[p])>>7)+((Image[k+bb]*sin_tabb[p])>>7);Image[k]=Image[k]-((Real[k+bb]*sin_tabb[p])>>7)+((Image[k+bb]*cos_tabb[p])>>7);Real[k+bb]=TR-((Real[k+bb]*cos_tabb[p])>>7)-((Image[k+bb]*sin_tabb[p])>>7);Image[k+bb]=TI+((temp*sin_tabb[p])>>7)-((Image[k+bb]*cos_tabb[p])>>7); Real[k]>>=1; Image[k]>>=1; Real[k+bb]>>=1; Image[k+bb]>>=1; } }}max=0;for(i=0;i<6;i++){a[i]=sqrt_16((Real[i+1]*Real[i+1]+Image[i+1]*Image[i+1])>>1);if(a[i]<2 ) a[i]=0;elsea[i]-=2;if(max7){max/=7;for(i=0;i<6;i++){a[i]/=max;}}for(i=0;i<6;i++)c[i]=a[i];}void disp() interrupt 1{TR0=0;TH0=(65536-2500)/256;TL0=(65536-2500)%256;if(num>=(amenu-1))num=0;elsenum++;if(b[num]c[num])b[num]--;if(b[num]>8)b[num]=8;if(amenu==1)fun(table1+num*8);else if(amenu==2)fun(table2+num*8);else if(amenu==3)fun(table3+num*8);else if(amenu==4)fun(table4+num*8);else if(amenu==5)fun(table5+num*8);elsefun(table6+num*8); P3=tuku1[b[num]];TR0=1;}/**********初始化函數(shù)*****************/void init(){/***********I/O口初始化*************/P1M1=1; //p1.0口高阻輸入P1ASF=1; P3M0=0xff; //P3口推挽輸出P2M0=0xff;P0M0=0xff;P4SW = 0x31;TMOD=0x01;TH0=(65536-4000)/256; TL0=(65536-4000)%256;EA=1; ET0=1; TR0=0; menu=0;out=0;amenu=0;num=0;}/*************主函數(shù)******************/void main(){int i,j;char go;delay(800);init(); //初始化函數(shù)////////////////////////呼吸燈P2=0xff;P0=0;P2=0x80;P3=1;while(!menu){for(i=0;i<400;i++){key_menu_scan();if(menu)break;P0=0x80;delay1(i);P0=0;delay1(400-i);if(i<200){j=2;while(j--){P0=0x80;delay1(i);P0=0;delay1(400-i);}}}for(i=0;i<401;i++){if(menu)break; key_menu_scan();P0=0x80;delay1(400-i);P0=0;delay1(i);if(i>200){j=2;while(j--){P0=0x80;delay1(400-i);P0=0;delay1(i);}}}}P3M0=0x00;///////////////////////////開(kāi)機(jī)掃描turn_on(10);H_scan(20);V_scan(20);W_scan(20);/////////////////主菜單選項(xiàng)while(1){hy(number+37*8,2);while(!amenu){W_side(number+(36+menu)*8,1,45);}switch(menu){case 1://音譜顯示delay(400);while(!out){TR0=1;FFT();} TR0=0;break;case 2://動(dòng)畫(huà)顯示delay(400);amenu=0;//menu=1;go=1;cut();while(go){for(i=0;i<10;i++)hy(number+27*8+i*8,3);if(out)go=1;elsego=0;}go=1;while(go){zimu(number,19,12,1);if(out)go=1;elsego=0;}go=1;while(go){fn(4);if(out)go=1;elsego=0;}go=1;while(go){out=0;flash0(2);if(out)go=1;elsego=0;}go=1;while(go){linkpc1(10);pc1(4,3);if(out)go=1;elsego=0;}go=1;while(go){leitu(yc_table,5,2); if(out)go=1;elsego=0;}go=1;while(go){denghuo(3);if(out==1)go=1;elsego=0;}go=1;while(go){water1(1,2,10);water1(2,4,10);water1(4,3,10);water1(7,1,10);water1(5,6,10); water2(0,2,7,1,9);water2(2,4,7,7,9);water2(4,7,7,1,9);water2(3,6,7,7,9);water2(4,1,6,6,9);water2(7,3,1,2,9);water3(0,4,7,4,5,1,9);water3(7,7,0,0,0,7,9);water3(0,6,6,6,5,1,9);water3(6,7,0,0,2,2,9);water3(3,3,6,6,2,2,9);if(out)go=1;elsego=0;}go=1;while(go){clc();link_pingmian1(1);pingmian1(8,3);if(out)go=1;elsego=0;}go=1;while(go){for(i=0;i<7;i++)print(tab_print+i*8,1);for(i=7;i<11;i++)print(tab_print+i*8,0);if(out)go=1;elsego=0;}go=1;while(go){clc();link_jb0(1);jb0(10,3);if(out)go=1;elsego=0;}go=1;while(go){yinchu(yc_table,5,9);if(out)go=1;elsego=0;}go=1;while(go){clc();link_jb0(1);jb0(10,3);if(out)go=1;elsego=0;}go=1;while(go){link(9);xuanzhuantiao(1,8,4);xuanzhuantiao(0,8,4);if(out)go=1;elsego=0;}go=1;while(go){xuanzhuantiao2(3,3);if(out)go=1;elsego=0;}go=1;while(go){qumianxuanzhuan(1,10,4);qumianxuanzhuan(0,10,4);if(out)go=1;elsego=0;}go=1;while(go){qumianxuanzhuan2(13,4);if(out)go=1;elsego=0;}go=1;while(go){xuanzhuantiao(1,4,4);xuanzhuantiao(1,3,5);xuanzhuantiao(1,2,6);xuanzhuantiao(1,1,7);if(out)go=1;elsego=0;}go=1;while(go){donghua(bianxing_table,11,1,24);xzcube();donghua(y_table,6,5,5);donghua(x_table,6,5,5);donghua(z_table,6,5,5);link00();if(out)go=1;elsego=0;}go=1;while(go){shensuo(5);if(out)go=1;elsego=0;}go=1;while(go){donghua(sin_cube_table,14,22,5);if(out)go=1;elsego=0;}go=1;while(go){for(i=0;i<3;i++)for(j=0;j<3;j++)cube(0,j,6);for(i=0;i<3;i++)for(j=0;j<3;j++)cube(1,j,6);if(out)go=1;elsego=0;}go=1; while(go){donghua(hart_table,2,10,32);if(out)go=1;elsego=0;}go=1;while(go){for(i=2;i>0;i--)shandian(i);if(out)go=1;elsego=0;}go=1;while(go){szfc0(10);if(out)go=1;elsego=0;}go=1;while(go){rain(1,10,9);rain(0,10,9);if(out)go=1;elsego=0;}break;case 3://夜燈模式delay(200);LED();break;}out=0;amenu=0;menu=1;}} 上一頁(yè) 1 2 3 4 下一頁(yè)
評(píng)論