带红外 51单片机 源程序 功能很多.
单片机源程序如下:
- /*---------------------------------------------------------------------------------------------------
- -----------------------------------------------------------------------------------------------------
- * 上升沿电子科技
- * 时间2015.8.1
- *Build target 'Target 1'
- *compiling stc8x8x8.c...
- *linking...
- *Program Size: data=17.1 xdata=355 code=53475
- *creating hex file from "stc8x8x8"...
- *"stc8x8x8" - 0 Error(s), 0 Warning(s).
- *没有关闭本店字样的显示函数 FLASH_12 FLASH_14 FLASH_18 如果需要自己关闭函数即可
- ------------------------------------------------------------------------------------------------------
- -----------------------------------------------------------------------------------------------------*/
- #include "STC12C5A.H" //包含单片机的头文件使用KEIL必须添加进来否则编译不了
- #include "intrins.h" //包含NOP延时头文件
- #include"main.h" //主程序头文件
- #include "shuju.h" //包含字模数据数组
- #include "flash.h" //动画部分程序
- #include "hongwai.h" //红外部分程序
- #include "key.h" //按键部分程序
- /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@定义变量@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
- uchar xdata display[8][8];
- uchar xdata msd=4;
- uint ld=500;
- uchar test=0,key1=0,key2=0,key3=0,key4=0;
- bit pu;
- uchar xsdsq=0;
- uchar cd=0,cnt=0,errd_flag=0,read_flag=0,layerr=0,saom=0;
- unsigned int CYCLE=100,PWM_LOW=1110,shan=0,shuzi1=0,shuzi2=0,shuzi3=0,shuzi4=0,m=0;//定义周期并赋值
- unsigned short T_PCA0; // unsigned short 范围是0至65535
- unsigned short T_PCA1;
- /*##########################################################################################*/
- //************************************上升沿电子科技************************************
- //函数名称:void init();
- //功 能:定义IO口功能
- //出口参数:无
- //编 写 人:上升沿电子科技
- //编写日期:2015-08-1
- //修改历史:V1.0
- //************************************上升沿电子科技************************************
- void init()
- {
- P4SW=0xff; //定义P4口为I/O口
- P0M1=0x00;
- P0M0=0xff; //定义P0为强上拉输出.
- P1M1=0x01;
- P1M0=0xfe; //定义P1为强上拉输出. P1.0作为AD此时不能作为强上蜡
- P2M1=0x00;
- P2M0=0xff; //定义P2为强上拉输出.
- P3M1=0x00;
- P3M0=0xf8; //定义P2为强上拉输出.
- P4M1=0x00;
- P4M0=0xff; //定义P4为强上拉输出.
- }
- /********************* AD初始化************************/
- void ADC0_Init (void)
- {
- P1ASF = 0x01; //Open 8 channels ADC function
- ADC_RES = 0; //Clear previous result 清零ADC的8位数据
- AUXR1 &=0xFB; //1111,1011, 令 ADRJ=0 (10位A/D转换结果的高8位放在ADC_RES寄存器, 低2位放在ADC_RESL寄存器)
- ADC_CONTR = ADC_POWER | ADC_SPEEDLL;//配置ADC寄存器
- _nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
- _nop_();_nop_();_nop_(); _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
- }
- /********************* 使用PCA定时初始化************************/
- void PCA_init()
- {
- CCON = 0; //Initial PCA control register
- //PCA timer stop running
- //Clear CF flag
- //Clear all module interrupt flag
- CL = 0; //Reset PCA base timer
- CH = 0;
- CMOD = 0x00;
- T_PCA0 = 1024;//46080; //定时50ms,11.0592MHZ晶振,T_Value=46080.要2秒需循环40次
- CCAP0L = T_PCA0;
- CCAP0H = T_PCA0 >> 8; //Initial PCA module-0
- T_PCA0 += 1024; //PCA module-0 work in 16-bit timer mode
- CCAPM0 = 0x49; //and enable PCA interrupt //Set PCA timer clock source as Fosc/12
- CR = 0; //PCA timer start run
- PPCA = 1; //高优先级
- EA=1;
- }
- /********************* 串口初始化************************/
- void init_uart(void)
- {
- PCON |= 0x80;
- SCON = 0x50;
- AUXR |= 0x40;
- AUXR &= 0xFE;
- TMOD &= 0x0F;
- TMOD |= 0x20;
- TL1 = 0xE8;
- TH1 = 0xE8;
- ET1 = 0;
- TR1 = 1;
- ES=1;
- EA=1;
- }
- /*##########################################################################################*/
- //************************************上升沿电子科技************************************
- //函数名称:void sinter()
- //功 能:中断初始化
- //出口参数:无
- //编 写 人:上升沿电子科技
- //编写日期:2015-08-1
- //修改历史:V1.0
- //************************************上升沿电子科技************************************
- void sinter()
- {
- IE=0x82;
- TCON=0x01;
- TH0=0x10;
- TL0=0x00;
- EX0 = 1;
- init();
- PWM_POW=1;
- ADC0_Init();
- PCA_init();
- init_uart();
- EA=1;
- }
- /*##########################################################################################*/
- //************************************上升沿电子科技************************************
- //函数名称:void delayus(unsigned int yanshi);
- //功 能:根据yanshi值的大小进行延时等待操作,1默认为2uS
- //入口参数:yanshi的值,范围0-65535
- //出口参数:无
- //编 写 人:上升沿电子科技
- //编写日期:2015-08-1
- //修改历史:V1.0
- //************************************上升沿电子科技************************************
- void delayus(unsigned int yanshi)
- {
- unsigned int wmys; //定义延时循环控制变量
- for(wmys=0;wmys<=yanshi;wmys++); //根据延时参数进行空循环操作,达到延时功能
- }
- void delay10us(void) //误差 -0.026765046296us STC 1T 22.1184Mhz
- {
- unsigned char a,b;
- for(b=1;b>0;b--)
- for(a=2;a>0;a--); //默认的速度为5,变速1-5-25-125
- }
- void delay5us(void) //误差 -0.026765046296us STC 1T 22.1184Mhz
- {
- unsigned char a,b;
- for(b=1;b>0;b--)
- for(a=5;a>0;a--); //默认的速度为5,变速1-5-25-125
- }
- void delay(uint ihk)
- {
- if(key3==2){return;}
- else
- {
- while(ihk--)
- {
- delay5us(); //12t的mcu 注释这个延时即可
- }
- }
- }
- void delays(int t)
- {
- int i;
- while(t--)
- for(i=0;i<700;i++);
- }
- /*##########################################################################################*/
- //************************************上升沿电子科技************************************
- //函数名称:void hansao(unsigned char hs); 138驱动程序
- //功 能:根据入口参数hs的值,进行判断选择哪一行,选通1-8行的选通
- //入口参数:hs的值,范围0-7
- //出口参数:无
- //编 写 人:上升沿电子科技
- //************************************上升沿电子科技************************************
- void hansao(unsigned char hs)
- {
- if(hs<8) //判断hs的值是否在行扫描的值范围内,不在范围内不执行任何操作
- {
- if(hs==7) //选通第1行
- {
- M_A=0;M_B=0;M_C=0;M_D=0; return;
- }
- if(hs==6) //选通第2行
- {
- M_A=1;M_B=0;M_C=0;M_D=0; return;
- }
- if(hs==5) //选通第3行
- {
- M_A=0;M_B=1;M_C=0;M_D=0; return;
- }
- if(hs==4) //选通第4行
- {
- M_A=1;M_B=1;M_C=0;M_D=0; return;
- }
- if(hs==3) //选通第5行
- {
- M_A=0;M_B=0;M_C=1;M_D=0; return;
- }
- if(hs==2) //选通第6行
- {
- M_A=1;M_B=0;M_C=1;M_D=0; return;
- }
- if(hs==1) //选通第7行
- {
- M_A=0;M_B=1;M_C=1;M_D=0; return;
- }
- if(hs==0) //选通第8行
- {
- M_A=1;M_B=1;M_C=1;M_D=0; return;
- }
- }
- }
- //************************************595芯片驱动程序1************************************
- void sendbyte(unsigned int num1,unsigned int num2,unsigned int num3,unsigned int num4)
- {
- unsigned char c;
- for(c=0;c<8;c++)
- {
- CLK=0;
- M_LR_DS0=num1&0x80;
- M_LG_DS0=num2&0x80;
- M_HR_DS0=num3&0x80;
- M_HG_DS0=num4&0x80;
- CLK=1;
- num1<<=1;
- num2<<=1;
- num3<<=1;
- num4<<=1;
- }
- }
- //************************************595芯片驱动程序2************************************
- void sendbyte1(unsigned int num1,unsigned int num2,unsigned int num3,unsigned int num4)
- {
- unsigned char c;
- for(c=0;c<8;c++)
- {
- CLK=0; //模拟时钟控制端口
- M_LR_DS0=num1&0x01; //模拟数据发送端口
- M_LG_DS0=num2&0x01;
- M_HR_DS0=num3&0x01;
- M_HG_DS0=num4&0x01;
- CLK=1;
- num1>>=1;
- num2>>=1;
- num3>>=1;
- num4>>=1;
- }
- }
- //************************************595芯片驱动程序3 上位机控制部分***********************************
- void sendbyteck(unsigned int num1,unsigned int num2,unsigned int num3,unsigned int num4)
- {
- unsigned char c;
- for(c=0;c<8;c++)
- {
- CLK=0;
- M_LR_DS0=num1&0x01;
- M_LG_DS0=num2&0x01;
- M_HR_DS0=num3&0x01;
- M_HG_DS0=num4&0x01;
- CLK=1;
- num1>>=1;
- num2>>=1;
- num3>>=1;
- num4>>=1;
- }
- }
- /************************************呼吸灯************************************/
- void Delaypwm(unsigned int tpwm)
- {
- while(--tpwm);
- }
- /************************************呼吸灯************************************/
- void PWM_LED()
- {
- unsigned int CYCLE=100,PWM_LOW=1110,xhs=60000;
- PWM_POW=0;
- if (xhs>1)
- {
- CYCLE=1950,PWM_LOW=201;
- PWM_POW=1;
- Delaypwm(60000);
- for(PWM_LOW=1;PWM_LOW<CYCLE;PWM_LOW++)
- {
- PWM_POW=0;
- Delaypwm(PWM_LOW);
- PWM_POW=1;
- Delaypwm(CYCLE-PWM_LOW);
- }
- for(PWM_LOW=CYCLE-1;PWM_LOW>0;PWM_LOW--)
- {
- PWM_POW=0;
- Delaypwm(PWM_LOW);
- PWM_POW=1;
- Delaypwm(CYCLE-PWM_LOW);
- }
- xhs--;
- }
- }
- /************************************扫描一面************************************/
- void turn_on(uchar v)
- {
- uchar a[64]={0};
- char i,j;
- a[7]=0x80;
- if(key3==1){return;}
- else{zhen(a,v);}
- delay(50);
- for(i=1;i<8;i++)
- {
- a[i*8+7]=0x80;
- if(key3==1){break;}
- else{zhen(a,v);}
- delay(50);
- }
- for(i=6;i>=0;i--)
- {
- for(j=0;j<8;j++)
- a[j*8+i]=0x80;
- if(key3==1){break;}
- else{zhen(a,v);}
- delay(50);
- }
- for(i=0;i<64;i++)
- a[i]=0;
- }
- /************************************左向右扫描检测************************************/
- void H_scan(uchar v)
- {
- uchar b[64]={0};
- char i,j;
-
- for(i=0;i<64;i++)
- b[i]=0x80;
- for(i=0;i<8;i++)
- {
- if(key1==4)
- {
- return;
- }
- for(j=0;j<8;j++)
- b[j*8+i]=0x80;
- if(key3==1){break;}
- else{zhen(b,1);}
- }
- for(i=0;i<8;i++)
- {
- if(key1==4)
- {
- return;
- }
- for(j=0;j<64;j++)
- b[j]>>=1;
- if(key3==1){break;}
- else{zhen(b,v);}
- delay(50);
- }
- }
- /************************************下向上扫描检测************************************/
- void V_scan(uchar v)
- {
- uchar a[64]={0};
- char i,j;
- for(i=0;i<8;i++)
- a[i]=0xff;
- if(key1==4)
- {
- return;
- }
- if(key3==1){return;}
- else{zhen(a,v);}
- delay(50);
- for(i=1;i<8;i++)
- {
- if(key1==4)
- {
- return;
- }
- for(j=0;j<8;j++)
- {
- a[i*8+j]=0xff;
- a[(i-1)*8+j]=0;
- }
- if(key3==1){break;}
- else{zhen(a,v);}
- delay(50);
- }
- }
- /************************************前向后扫描检测************************************/
- void W_scan(uchar v)
- {
- uchar a[64]={0};
- char i,j;
- for(i=0;i<8;i++)
- a[i*8+7]=0xff;
- if(key1==4)
- {
- return;
- }
- if(key3==1){return;}
- else{zhen(a,v);}
- delay(50);
- for(i=6;i>=0;i--)
- {
- if(key1==4)
- {
- return;
- }
- for(j=0;j<8;j++)
- {
- a[j*8+i]=0xff;
- a[j*8+i+1]=0;
- }
- if(key3==1){break;}
- else{zhen(a,v);}
- delay(50);
- }
- M_EN=0;
- }
- void W_side(uchar *tab,char num,char v)
- {
- uchar a[64]={0};
- int i,j;
- for(j=0;j<num;j++)
- {
- for(i=0;i<8;i++)
- a[i*8+7]=tab[j*8+i];
- if(key3==1){break;}
- else{zhen(a,v);}
- delay(50);
- }
- }
- void delayyp(unsigned int n1)
- {
- unsigned int xdata i;
- while(n1--)
- for (i=0;i<200;i++);
- }
- unsigned int Read_ADC0()
- {
- ADC_CONTR|=0x08;
- _nop_();
- _nop_();
- _nop_();
- _nop_();
- while(!(ADC_CONTR&0x10));
- ADC_CONTR&=~0x10;
- return ((ADC_RES<<2)|(ADC_RESL));
- }
- unsigned int voivol(unsigned int n)
- {
- unsigned int xdata val,result,rel=0;
- while(n)
- {
- val=Read_ADC0();
- delayyp(2);
- result=val;
- rel=rel+result;
- n--;
- }
- return rel;
- }
- void Vol_watch_0(unsigned char kxg)
- {
- unsigned int xdata result=0,l=1,n=500;
- while(n)
- {
- if ((result>>5)>l)
- l=result>>5;
- else
- if (l>1)
- l--;
- if (l>7)
- l=7;
-
- if(kxg==1)
- {
- box(0,0,0,l,l,l,0,1);
- result=voivol(16);
- box(0,0,0,7,7,7,1,0);
- }
- if(kxg==2)
- {
- box(7,7,7,7-l,7-l,7-l,0,1);
- result=voivol(16);
- box(7,7,7,7-l,7-l,7-l,1,0);
- }
- if(kxg==3)
- {
- box(7,0,7,0,l,0,0,1);
- result=voivol(16);
- box(l,0,l,0,7,0,1,0);
- }
- if(kxg==4)
- {
- box(l,l,l,7-l,7-l,7-l,0,1);
- result=voivol(16);
- box(7-l,7-l,7-l,l,l,l,1,0);
- }
- if(kxg==5)
- {
- box(0,7,7,l,7-l,0,0,1);
- result=voivol(16);
- box(0,7,7,l,7-l,0,1,0);
- }
- if(kxg==6)
- {
- box(l,l,l,7-l,7-l,7-l,0,1);
- result=voivol(16);
- box(7-l,7-l,7-l,7,7,7,1,0);
- }
- if(kxg==7)
- {
- box(l,0,7,0,7,0,0,1);
- result=voivol(16);
- box(7,0,l,0,l,0,1,0);
- }
- n--;
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}
- }
- }
- void Vol_watch_2()
- {
- unsigned int xdata result=0,l=0,n=500;
- while(n)
- {
- if ((result>>5)>l)
- l=result>>5;
- else
- if (l>0)
- l--;
- if (l>7)
- l=7;
- clear(0);
- switch(l)
- {
- case 0:point(4,4,4,1);break;
- case 1:box(3,3,3,4,4,4,1,1);break;
- case 2:box(2,2,2,4,4,4,1,1);break;
- case 3:box(2,2,2,5,5,5,1,1);break;
- case 4:box(1,1,1,5,5,5,1,1);break;
- case 5:box(1,1,1,6,6,6,1,1);break;
- case 6:box(0,0,0,6,6,6,1,1);break;
- default:box(0,0,0,7,7,7,1,1);
- }
- result=voivol(16);
- n--;
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}
- }
- }
- void Vol_watch_3()
- {
- unsigned int result,l,n=500;
- while(n)
- {
- result=voivol(3);
- l=result>>3;
- if (l>7)
- l=7;
- transss();
- box_apeak_xy(0,0,0,0,7,l,1,1);
- delayyp(60);
- n--;
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}
- }
- }
- void Vol_watch_1(unsigned char kxg1)
- {
- unsigned int xdata result=0,l=0,n=500,saa,sad;
- unsigned char code disxin[8][8]={
- 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x99,
- 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xA5,
- 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81, 0xC3,
- 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81, 0x81,
- 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x81,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x99,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0xE7,
- 0xFF, 0xC3, 0xA5, 0x81, 0x81, 0xA5, 0xC3, 0xFF,
- };
- while(n)
- {
- if ((result>>5)>l)
- l=result>>5;
- else
- if (l>0)
- l--;
- if (l>7)
- l=7;
- if(kxg1==1)
- {
- box(3,3,0,4,4,l,1,1);
- if (l<7)
- box(3,3,7,4,4,l+1,1,0);
- result=voivol(16);
- }
- if(kxg1==2)
- {
- box(2,2,0,5,5,l,1,1);
- if (l<7)
- box(2,2,7,5,5,l+1,1,0);
- result=voivol(16);
- }
- if(kxg1==3)
- {
- box(1,1,0,6,6,l,1,1);
- if (l<7)
- box(1,1,7,6,6,l+1,1,0);
- result=voivol(16);
- }
- if(kxg1==4)
- {
- box(0,0,0,7,7,l,1,1);
- if (l<7)
- box(0,0,7,7,7,l+1,1,0);
- result=voivol(16);
- }
- if(kxg1==5)
- {
- for(saa=0;saa<8;saa++)
- {
- for(sad=0;sad<8;sad++)
- {
- display[saa][sad]= disxin[saa][sad];
- }
- }
- box(3,3,0,4,4,l,1,1);
- if (l<7)
- box(3,3,7,4,4,l+1,1,0);
- result=voivol(16);
- }
- n--;
- if(key2==3||key2==2)
- {
- if(key2==3)
- {
- msd=3;
- break;
- }
- else
- {
- if(key2==2)
- {
- msd=2;break;
- }
- }
- }
- }
- }
- void fvb() //上位机
- {
- if(read_flag)
- {
- read_flag=0;
- for(saom=0;saom<8;saom++)
- {
- displayck[saom+0]=((shuzu8X8[saom*8]>>7)&0x01)+(((shuzu8X8[saom*8+1]>>7)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>7)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>7)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>7)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>7)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>7)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>7)&0x01)<<7);
- displayck[saom+8]=((shuzu8X8[saom*8]>>6)&0x01)+(((shuzu8X8[saom*8+1]>>6)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>6)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>6)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>6)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>6)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>6)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>6)&0x01)<<7);
- displayck[saom+16]=((shuzu8X8[saom*8]>>5)&0x01)+(((shuzu8X8[saom*8+1]>>5)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>5)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>5)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>5)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>5)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>5)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>5)&0x01)<<7);
- displayck[saom+24]=((shuzu8X8[saom*8]>>4)&0x01)+(((shuzu8X8[saom*8+1]>>4)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>4)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>4)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>4)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>4)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>4)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>4)&0x01)<<7);
- displayck[saom+32]=((shuzu8X8[saom*8]>>3)&0x01)+(((shuzu8X8[saom*8+1]>>3)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>3)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>3)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>3)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>3)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>3)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>3)&0x01)<<7);
- displayck[saom+40]=((shuzu8X8[saom*8]>>2)&0x01)+(((shuzu8X8[saom*8+1]>>2)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>2)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>2)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>2)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>2)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>2)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>2)&0x01)<<7);
- displayck[saom+48]=((shuzu8X8[saom*8]>>1)&0x01)+(((shuzu8X8[saom*8+1]>>1)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>1)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>1)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>1)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>1)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>1)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>1)&0x01)<<7);
- displayck[saom+56]=((shuzu8X8[saom*8]>>0)&0x01)+(((shuzu8X8[saom*8+1]>>0)&0x01)<<1)+(((shuzu8X8[saom*8+2]>>0)&0x01)<<2)+(((shuzu8X8[saom*8+3]>>0)&0x01)<<3)+(((shuzu8X8[saom*8+4]>>0)&0x01)<<4)+(((shuzu8X8[saom*8+5]>>0)&0x01)<<5)+(((shuzu8X8[saom*8+6]>>0)&0x01)<<6)+(((shuzu8X8[saom*8+7]>>0)&0x01)<<7);
- }
- }
- for(layerr=0;layerr<8;layerr++)
- {
- key_baihei_scan(); key_shangwiej_scan(); key_donghua_scan(); key_yinyue_scan();
- hansao(layerr);
- sendbyteck(~displayck[layerr*8+0],~displayck[layerr*8+2],~displayck[layerr*8+4],~displayck[layerr*8+7]);
- sendbyteck(~displayck[layerr*8+3],~displayck[layerr*8+1],~displayck[layerr*8+6],~displayck[layerr*8+5]);
- SUO=0; //模拟锁存信号端口
- _nop_();
- SUO=1;
- M_EN=0;
- delayus(ld);
- M_EN=1;
-
- if(key2==1||key2==2)
- {
- break;
- }
- }
- }
- /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@主函数@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
- void main()
- {
- unsigned char p=0,k=0,l=0; //定义
- sinter();
- IDelay(100);
- IRInit(); //初始化红外中断
- clear(0);
- PWM_LED();//开启PWM呼吸灯功能
- turn_on(10);
- H_scan(10);
- V_scan(10);
- W_scan(10);
- PWM_POW=0;//打开电源指示灯
- test=1;
- while(1)
- {
- ld=500;
- H_scan(40); //左向右扫描检测
- if(key1==1||key1==2||key1==3||key1==4)
- {
- break;
- }
- V_scan(40); //下向上扫描检测
- if(key1==1||key1==2||key1==3||key1==4)
- {
- break;
- }
- W_scan(40); //前向后扫描检测
- if(key1==1||key1==2||key1==3||key1==4)
- {
- break;
- }
- }
- while(1)
- {
- if(key1==3)
- {
- H_scan(40);
- }
- if(key1==2)
- {
- V_scan(40);
- }
- if(key1==1)
- {
- W_scan(40);
- }
- if(key1==4) //k1按下退出检测功能
- {
- test=2;
- msd=2;
- ld=500;
- break; //退出测试功能
- }
- }
- delay(10); TR0=0;
- while(1) /*play list*/
- {
- if(msd==1)
- {
- key3=3;
- TR0=0;
- ET0=0;
- IRInit();
- xsdsq=1;
- hy(number+(36+1)*8,10);
- W_side(number+(36+1)*8,1,200); //显示音乐的标识
- xsdsq=0;
- PWM_POW=0;
- TR0=1; //开启定时器显示扫描
- ET0=1;
- test=2;
- while(1)
- {
- if(key2==3||key2==2)
- {
- if(key2==3)
- {
- msd=3;
- break;
- }
- else
- {
- if(key2==2)
- {
- msd=2;
- break;
- }
- }
- }
- else
- {
- clear(0);
- Vol_watch_0(1);
- }
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_0(2);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_0(3); }
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_0(4); }
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_0(5);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_0(6);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_0(7);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_1(1);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_1(2);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_1(3); }
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_1(4);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_1(5);}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_2();}
- if(key2==3||key2==2){if(key2==3){msd=3;break;}
- else{if(key2==2){msd=2;break;}}}else{ clear(0); Vol_watch_3();}
- }
- }
- if(msd==2)
- {
- key3=3;
- xsdsq=1;
- hy(number+(36+2)*8,10);
- W_side(number+(36+2)*8,1,200);
- xsdsq=0;
- while(1)
- {
- msd=6;
- TR0=0; //关闭定时器显示扫描
- TR1=0;
- ET0=0;
- IRInit();
- flash_20(); //第一个面屏幕上下拉开
- flash_21(); //从后面往前面显示数组的数字9-0
- flash_22(); //围绕着最外面的LED循环滚动显示数组中内容
- flash_23(); //分层升降左右上下前后以此打开升降测试
- flash_24(); //从最上面的一个面往下面的一层移动完
- flash_25(); //光立方全亮并且闪烁5次
- flash_26(); //从下面往上面依次显示出数组中的内容IXU
- flash_27(); //狼七八咋的显示出LED的每一个灯展示灯火效果
- flash_28(); //显示从上面往下面滴水的效果
- flash_29(); //将4个面围城圈圈然后旋转几次
- flash_30(); //空心显示将数组内容打印出来可以打印4个数组内容
- flash_31(); //将左右的四个面围绕成圈圈转起来4次之后从左边往右边显示数组中一幅图像64个的数据
- flash_32(); //从左边显示一个面然后旋转出一个面的空心效果实心效果
- flash_33(); //旋转单个面依次交换到买一个面
- flash_34(); //以中点位轴进行选择左右旋转切换实现波纹的效果
- flash_35(); //旋转左右为中心加快速度实现每个面的抖动效果
- flash_36(); //将数组中的内容显示出现进行旋转是一个正方形的
- flash_37(); //将方形变形缩小然后变成一个全亮的效果
- flash_38(); //前后左右上下伸缩全亮
- flash_39(); //实心和空心缩放和放大正方形全亮显示
- flash_40(); //动画显示一个数组里面的心形数据 会动的心形
- flash_41(); //显示一个电梯的图形
- flash_42(); //显示数字往上移动出来
- flash_15(); //显示下雨的效果
- msd=2;
- TR0=1;
- TR1=1;
- ET0=1;
-
- //显示中有些动画包含本店的数据如果不需要请自己将动画函数屏蔽
- //flash_14();flash_18();flash_12();
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_1();}//包含第一个面显示4321倒计时的文字
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_17();}//显示出一个VI的版本标志然后从最里面往外面滚动出来
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_16();}//从边边的左右中滚动显示默认的英文字母ideasoft
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_14();}//一个一个的字变出来显示上升沿电子光立方可以修改显示数据
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_18();}//显示出上升沿电子8X8X8光立方下雨效果飘出字移动出去
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_2();}//图形圈圈显示出来
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_3();}//从前一排显示到后面一排两次
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_4();}//从前一排斜杆到最后一排两次
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_5();}//框框伸缩从中间到前面到后面
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_6();}//滚四边的圈圈然后下雨效果飘出字移动出去
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_7();}//滚四边包括前后左右滚然后出来半边三角形
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_8();}//从左移动一排到右边中间显示文字图形
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_9();}//从左到右边滚出斜杆然后螺旋转轴旋转框框显示方框伸缩孔空心和实心
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_10();}//从最左小脚伸缩出框框然后变轮子前后左右上下滚动然后收缩还原
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_11();}//象红旗一样被风飘动象蛇一样飘动走动
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_12();}//滚动上升沿电子的字模数据文字移动显示出来
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_13();}//渐变出来文字VI1234IXU的图案
- if(key2==1||key2==3){if(key2==1){msd=1;break;}
- else{if(key2==3){msd=3;break;}}}else{flash_19();}//平行滑动显示出3D CULE FFT的字?
- TR0=0;
- TR1=0;
- ET0=0;
- IRInit();
- PWM_POW=0;
- }
- }
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
最新光立方源程序(2016.7更新).rar
(255.01 KB, 下载次数: 32)
|