程序与原理图如下:- /*******************************************************************************************************************************
-
- 长沙太阳人”杯红外波形显示单片机设计大赛
- ***
- ***** 作品: 红外波形显示
- ***
- **** 功能描述: 检测 显示32位红外遥控编码
- ******** ******
- ***** ***** ****** 显示32位遥控编码波形
- ***** **********
- ***** ******* 显示16位系统及系统反码波形
- ***** *****
- ***** ***** 显示16位用户及用户反码波形
- ********** **********
- ********** **********
- *** ***
- *** ***
- ********** **********
- ********** ********** 制作人:小杨(杨再兴)
- *** ***
- *** *** <2016.7.5>
- ********** **********
- ********** **********
-
- *******************************************************************************************************************************/
- #include
- #include
- #define uint unsigned int
- #define uchar unsigned char
- #define LCD_DATA P1
- sbit LCD_RS=P3^4;
- sbit LCD_RW=P3^1;
- sbit LCD_EN =P3^0;
- sbit LCD_PSB=P3^6;
- sbit IRDATA=P3^2;
- sbit key1=P2^0;
- sbit key2=P2^1;
- sbit key3=P2^2;
- sbit key4=P2^3;
- sbit key5=P2^4;
- uchar b=35; //波形的初始位置垂直坐标 初值35
- uchar w=4; //波形脉宽位位4(个像素点)
- uchar amp=15; //波形幅值初值为15(个点)
- uchar stat=1; //根据按键画波形的状态标志
- uchar boma[8]; //存放波形码
- uchar xitongma[4],yonghuma[4]; //存放波形码
- unsigned long recode; //接收码
- uint recodehigh,recodelow; //接收码的高低16位
- uchar code zifu1[]={" 红外波形显示"};
- uchar code zifu2[]={"遥控码为:"};
- uchar code zifu3[]={" 系统及系统反码"};
- uchar code zifu4[]={"码值为:0X "};
- uchar code zifu5[]={" 操作及操作反码"};
- uchar code zifu6[]={"码值为:0X "};
- uchar Y_Coord,X_Byte,X_Bit; //定义 Y坐标 X字节坐标 X位坐标
- uchar High_8bit=0,Low_8bit=0; //读出 2个字节的 高8位 和 低8位 先高8位 后低8位
- uchar data hongwaicode[4]; //定义一个4字节的数组用来存储代码
- uchar CodeTemp; //编码字节缓存变量
- uchar i,j,k; //延时用的循环变量
- bit biaozhi=0;
- void key(void);
- void boxing(unsigned long temp);
- void LCD12864_DisplayCLR();//清屏
- void LCD12864_IfBusy(void);//判断液晶是否忙
- void LCD_writedcmd(uchar Rom);//写指令
- void LCD_writedata(uchar Data);//写数据
- void LCD12864_DisplayChinese(uchar Addr,uchar *p);//显示中文或字符串
- uchar LCD12864_ReadByte();//读取函数
- void LCD_Point(uchar X, uchar Y );//画点
- void LCD12864_DrawXline(uchar X0,uchar X1,uchar Y);//画 X轴水平线
- void LCD12864_DrawYline(uchar X,uchar Y0,uchar Y1);//画 Y轴水平线
- void LCD12864_Init(void);//液晶初始化
- unsigned char code tu1[] = // 数据表 图1
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x03,0xC0,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x01,0x81,0x80,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x07,0xC0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x07,0xE0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x1F,0x80,0x0F,0xE0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x3F,0xC0,0x0F,0xE0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x7F,0xE0,0x07,0xC0,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0xFF,0xF0,0x03,0x80,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x01,0xFF,0xF9,0xF8,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x03,0xF9,0xFD,0xF8,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x07,0xF0,0xFF,0xF8,0x00,0x60,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x0F,0xE0,0x7F,0xF8,0x00,0x60,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x1F,0xC0,0x3F,0xF8,0x00,0x60,0x00,
- 0x00,0x00,0x60,0x04,0x00,0x30,0x06,0x00,
- 0x00,0x3F,0x80,0x1F,0xF8,0x00,0x60,0x7F,
- 0xCF,0xF9,0xEF,0x85,0xF8,0x30,0xFF,0xF8,
- 0x00,0x7F,0x00,0x07,0xF8,0x07,0xFE,0x7F,
- 0xCF,0xFB,0xEF,0x95,0xF8,0x30,0xFF,0xF8,
- 0x00,0xFE,0x00,0x03,0xFC,0x07,0xFE,0x03,
- 0x8F,0xF8,0xC9,0x94,0x61,0xFE,0x80,0x08,
- 0x01,0xFC,0x00,0x01,0xFE,0x06,0x66,0x03,
- 0x00,0xC3,0xEF,0x95,0xF9,0xFE,0xBF,0xC8,
- 0x03,0xF8,0x00,0x00,0xFF,0x07,0xFE,0x07,
- 0x00,0xC3,0xE0,0x15,0xF8,0x0E,0x07,0x80,
- 0x07,0xF0,0x00,0x00,0x7F,0x87,0xFE,0x7F,
- 0xE0,0xC0,0x9F,0x95,0x68,0x0C,0x3E,0x00,
- 0x0F,0xE0,0x00,0x00,0x3F,0xC6,0x66,0x7F,
- 0xE0,0xC0,0x9F,0x95,0x68,0x1C,0x73,0x20,
- 0x1F,0xC0,0x00,0x00,0x1F,0xF6,0x66,0x06,
- 0x00,0xC1,0xE6,0x15,0x68,0x38,0x0F,0xC0,
- 0x3F,0x80,0x00,0x00,0x0F,0xF7,0xFE,0x06,
- 0x00,0xC1,0xEF,0x15,0x69,0xF0,0x73,0x00,
- 0x7F,0x00,0x00,0x00,0x07,0xFB,0xF0,0x06,
- 0x00,0xC3,0xCF,0x05,0x69,0xE0,0x0F,0xC0,
- 0xFE,0x00,0x00,0x00,0x03,0xFC,0x62,0x26,
- 0x00,0xC0,0xC6,0x05,0x79,0xE0,0x19,0x60,
- 0xFC,0xFF,0xFC,0x7F,0xFF,0xFC,0x66,0x36,
- 0x1F,0xFC,0xDF,0x9C,0x63,0x7F,0x31,0x30,
- 0xF8,0xFF,0xFC,0x7F,0xFE,0x7C,0x7E,0x3E,
- 0x1F,0xFC,0xDF,0x98,0x63,0x3F,0x01,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFE,0x00,0x7E,0x1E,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xF0,0x00,0x78,0x00,0x24,0xA4,0xA4,
- 0x80,0xFB,0xEF,0x9E,0x7F,0x7C,0x1D,0xF8,
- 0x00,0xF0,0x00,0x78,0x00,0x24,0xA4,0xA4,
- 0x80,0xCB,0x2F,0x9E,0x7F,0x64,0x3D,0xF8,
- 0x00,0xF0,0x00,0x78,0x00,0x24,0xA4,0xA4,
- 0x80,0xFB,0xEC,0x92,0x49,0x7C,0x31,0x98,
- 0x00,0xF0,0x00,0x78,0x00,0x2E,0xAE,0xAE,
- 0x80,0xC3,0x0C,0x92,0x49,0x60,0x31,0x98,
- 0x00,0xF0,0x00,0x78,0x00,0x3B,0xBB,0xBB,
- 0x98,0xC3,0x0C,0x9E,0x49,0x61,0xB9,0x98,
- 0x00,0xF0,0x00,0x78,0x00,0x31,0xB1,0xB1,
- 0x98,0xF3,0xEC,0x9E,0x49,0x7D,0x9D,0x98,
- 0x00,0xFF,0xFC,0x7F,0xFF,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFF,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFF,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0xFF,0xFC,0x7F,0xFF,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
- };
- /**************************延时50us子程序**********************/
- void Delay_50us(uint t)
- {
- uchar j;
- for(;t>0;t--)
- for(j=20;j>0;j--);
- }
-
- /**************************延时0.9ms子程序**********************/
- void Delay0_9ms(void)
- {uchar j,k;
- for(j=18;j>0;j--)
- for(k=20;k>0;k--) ;
- }
- /***************************延时1ms子程序**********************/
- void Delay1ms(void)
- {uchar i,j;
- for(i=2;i>0;i--)
- for(j=240;j>0;j--) ;
- }
- /***************************延时4.5ms子程序**********************/
- void Delay4_5ms(void)
- {uchar i,j;
- for(i=10;i>0;i--)
- for(j=230;j>0;j--) ;
- }
- /************************中断0解码服务子程序**********************/
- void int0(void) interrupt 0
- {
- EA=0;
- for(k=0;k<10;k++)
- {Delay0_9ms();
- if (IRDATA==1) //如果0.9ms后IRDATA=1,说明不是引导码
- {k=10;break;}
- else if(k==9) //如果持续了10×0.9ms=9ms的低电平,说明是引导码
- {while(IRDATA==0);
- Delay4_5ms(); //跳过持续4.5ms的高电平
- for(i=0;i<4;i++) //分别读取4个字节
- {for(j=1;j<=8;j++) //每个字节8个bit的判断
- { while(IRDATA==0); //等待上升沿
- Delay0_9ms(); //从上升沿那一时刻开始延时0.9ms,再判断IRDATA
- if(IRDATA==1) //如果IRDATA是"1",则向右移入一位"1"
- {Delay1ms();
- CodeTemp=CodeTemp|0x80;
- if(j<8) CodeTemp=CodeTemp>>1;
- }
- else
- if(j<8)CodeTemp=CodeTemp>>1;//如果IRDATA是"0",则向右移一位,自动补"0"
- }
- hongwaicode[i]=CodeTemp;
- CodeTemp=0;
- }
-
- }
- }
- recodehigh=hongwaicode[0]<<8|hongwaicode[1];
- recodelow=hongwaicode[2]<<8|hongwaicode[3];
- recode=recodehigh;
- recode=recode<<16;
- recode=recode|recodelow;
- biaozhi=1;
- EA=1;
- }
- void LCD12864_IfBusy(void)//判断液晶是否忙
- {
- LCD_RS=0;
- LCD_RW=1;
- LCD_EN =1;
- LCD_DATA=0xff;
- while((LCD_DATA&0x80)==0x80);
- LCD_EN =0;
- }
- void LCD_writedcmd(uchar Rom)//写指令
- {
- LCD12864_IfBusy();
- LCD_RS=0;
- LCD_RW=0;
- LCD_EN =1;
- LCD_DATA=Rom;
- LCD_EN =0;
- }
- void LCD_writedata(uchar Data)//写数据
- {
- LCD12864_IfBusy();
- LCD_RS=1;
- LCD_RW=0;
- LCD_EN =1;
- LCD_DATA=Data;
- LCD_EN =0;
- }
- void LCD12864_DisplayChinese(uchar Addr,uchar *p)//显示中文或字符串
- {
- LCD12864_IfBusy();
- LCD_writedcmd(Addr);
- LCD12864_IfBusy();
- while(*p !='')
- {
- LCD_writedata(*p);
- p++;
- LCD12864_IfBusy();
- }
- }
- uchar LCD12864_ReadByte()//读取函数
- {
- uchar ReadByte;
- LCD12864_IfBusy();
- LCD_DATA=0xff;//读操作之前 先拉高IO口
- LCD_RS=1;
- LCD_RW=1;
- LCD_EN =0;
- Delay1ms();
- LCD_EN =1;
- ReadByte=LCD_DATA;
- LCD_EN =0;
- return (ReadByte);
- }
- void LCD_Point(uchar X, uchar Y)//画点
- {
- LCD12864_IfBusy();
- LCD_writedcmd(0x34);//开启 扩充功能
- LCD_writedcmd(0x36);//开启 绘图功能
- X_Byte = X>>4; //取坐标的 字节坐标
- X_Bit = X&0x0f;//取坐标的 位坐标
- if( Y < 32 ) //上屏
- {
- Y_Coord = Y ;
- }
- else //下屏
- {
- Y_Coord = Y - 32 ;
- X_Byte += 8 ;
- }
- LCD_writedcmd( 0x80+Y_Coord ); //确定 操作字节地址
- Delay_50us(1);
- LCD_writedcmd( 0x80+X_Byte );
- LCD12864_ReadByte(); //读操作
-
- Delay_50us(12);
- High_8bit =LCD12864_ReadByte();
- Low_8bit=LCD12864_ReadByte();
- LCD_writedcmd( 0x80 + Y_Coord );
- LCD_writedcmd( 0x80 + X_Byte );
- if( X_Bit < 8 ) //修改 数据
- {
- High_8bit |= ( 0x01 << ( 7 - X_Bit )) ;
- LCD_writedata( High_8bit) ;
- LCD_writedata( Low_8bit ) ;
- }
- else
- {
- Low_8bit |= ( 0x01 << ( 15 - X_Bit ));
- LCD_writedata( High_8bit ) ;
- LCD_writedata( Low_8bit ) ;
- }
- LCD_writedcmd( 0x30 );
- }
- void LCD12864_DrawXline(uchar X0,uchar X1,uchar Y)//画 X轴水平线
- {
- if (X0<x1)
- for(;X0<x1;x0++)
- {
- LCD_Point(X0,Y);
- }
- else
- for(;X0>X1;X0--)
- {
- LCD_Point(X0,Y);
- }
- }
- void LCD12864_DrawYline(uchar X,uchar Y0,uchar Y1)//画 Y轴水平线
- {
- if (Y0<y1)
- for(;Y0<y1;y0++)
- {
- LCD_Point(X,Y0);
- }
- else
- for(;Y0>Y1;Y0--)
- {
- LCD_Point(X,Y0);
- }
- }
- void LCD12864_DisplayCLR()
- {
- uchar i, j, k ;
- LCD12864_IfBusy();
- LCD_writedcmd(0x34);
- LCD_writedcmd(0x36);
- for( i = 0 ; i < 2 ; i++ )//分上下两屏写
- {
- for( j = 0 ; j < 32 ; j++ )
- {
- LCD12864_IfBusy();
-
- LCD_writedcmd( 0x80 + j ) ;//写Y坐标
- Delay_50us(1);
- if( i == 0 ) //写X坐标
- {
- LCD_writedcmd( 0x80 ) ;
- Delay_50us(1);
- }
- else
- {
- LCD_writedcmd( 0x88 ) ;
- Delay_50us(1);
- }
- for( k = 0 ; k < 16 ; k++ ) //写一整行数据
- {
- LCD12864_IfBusy();
- LCD_writedata(0x00) ;
- Delay_50us(1);
- }
- }
- }
- LCD_writedcmd( 0x30 ) ;
- }
- void LCD12864_Init(void)//液晶初始化
- {
- P0=0x00;
- LCD_PSB=1;
- LCD_writedcmd(0x30);
- Delay_50us(2);
- LCD_writedcmd(0x06);
- Delay_50us(2);
- LCD_writedcmd(0x0c);
- Delay_50us(2);
- LCD_writedcmd(0x01);
- Delay_50us(2);
- }
- void boxing32(unsigned long temp)
- {
- unsigned long bit1,bit0;
- uchar i;
-
- LCD12864_DrawYline(0,0,63);
- LCD12864_DrawXline(0,128,b+3);
- for(i=1;i<=(128/w);i++)
- {
- LCD_Point(w*i,b+2 );
- if(i==8||i==16||i==24||i==32||i==40||i==48)
- LCD12864_DrawYline(w*i,b-1,b+6);
- }
- bit1=temp&0x80000000;
- temp<<=1;
- bit0=bit1;
- if(bit1!=0)
- LCD12864_DrawXline(0,w,b-amp);
- else
- LCD12864_DrawXline(0,w,b);
- for(i=1;i<32;i++)
- {
- bit0=bit1;
- bit1=temp&0x80000000;
-
- if(bit1!=bit0)
- {
- if(bit1<bit0)
- {
- LCD12864_DrawYline(i*w,b-amp,b);
- LCD12864_DrawXline(i*w,(i+1)*w,b);
- }
- else
- {
- LCD12864_DrawYline(i*w,b,b-amp);
- LCD12864_DrawXline(i*w,(i+1)*w,b-amp);
-
- }
- }
- else
- {
- if(bit1!=0)
- LCD12864_DrawXline(i*w,(i+1)*w,b-amp);
- else
- LCD12864_DrawXline(i*w,(i+1)*w,b);
- }
- temp<<=1;
-
- }
- }
- void boxing16(uint temp)
- {
- uint bit1,bit0;
- uchar i;
-
- LCD12864_DrawYline(0,0,63);
- LCD12864_DrawXline(0,128,b+3);
- for(i=1;i<=(128/w);i++)
- {
- LCD_Point(w*i,b+2 );
- if(i==8||i==16||i==24||i==32||i==40||i==48)
- LCD12864_DrawYline(w*i,b-1,b+6);
- }
- bit1=temp&0x8000;
- temp<<=1;
- bit0=bit1;
- if(bit1!=0)
- LCD12864_DrawXline(0,w,b-amp);
- else
- LCD12864_DrawXline(0,w,b);
- for(i=1;i<16;i++)
- {
- bit0=bit1;
- bit1=temp&0x8000;
-
- if(bit1!=bit0)
- {
- if(bit1<bit0)
- {
- LCD12864_DrawYline(i*w,b-amp,b);
- LCD12864_DrawXline(i*w,(i+1)*w,b);
- }
- else
- {
- LCD12864_DrawYline(i*w,b,b-amp);
- LCD12864_DrawXline(i*w,(i+1)*w,b-amp);
-
- }
- }
- else
- {
- if(bit1!=0)
- LCD12864_DrawXline(i*w,(i+1)*w,b-amp);
- else
- LCD12864_DrawXline(i*w,(i+1)*w,b);
- }
- temp<<=1;
-
- }
- }
- void huatu(uchar *p)
- {
- uchar i,j,k;
- LCD_writedcmd(0x36);
- for(i=0;i<2;i++)
- {
- for(j=0;j<32;j++)
- {
- LCD_writedcmd(0x80+j);
- if(i==0)
- {
- LCD_writedcmd(0x80);
- }
- else
- {
- LCD_writedcmd(0x88);
- }
- for(k=0;k<16;k++)
- {
- LCD_writedata(*p++);
- }
- }
- }
- LCD_writedcmd(0x36);
- }
- void key(void)
- {
- P2=0xff;
- if(!key1)
- {
- Delay1ms();
- if(!key1)
- {
- while(!key1);
- amp--; amp--;
- if(amp<3)
- amp=20;
- biaozhi=1;
- }
- }
- if(!key2)
- {
- Delay1ms();
- if(!key2)
- {
- while(!key2);
- b--;b--;
- if(b<30)
- b=42;
- biaozhi=1;
- }
- }
- if(!key3)
- {
- Delay1ms();
- if(!key3)
- {
- while(!key3);
- stat++;
- if(stat>3)
- stat=1;
- switch(stat)
- {
- case 1: w=4;break;
- case 2: w=8;break;
- case 3: w=8;break;
- default:break;
- }
- biaozhi=1;
-
- }
- }
- if(!key4)
- {
- Delay1ms();
- if(!key4)
- {
- while(!key4);
- w--;
- if(stat==1)
- {
- if(w<2)
- w=4;
- }
- else
- {
- if(w<2)
- w=8;
- }
- biaozhi=1;
- }
- }
- if(!key5)
- {
- Delay1ms();
- if(!key5)
- {
- while(!key5);
- amp++; amp++;
- if(amp>20)
- amp=20;
- biaozhi=1;
- }
- }
- }
- /**************************主程序*************************/
- void main()
- {
- LCD12864_Init();
- LCD12864_DisplayCLR();
- IT0=1; //INT0为负边沿触发, (1:负边沿触发,0:低电平触发)
- EX0=1; //外部中断INT0开, (1:开, 0:关 )
- EA=1; //开所有中断
- CodeTemp=0; //初始化红外编码字节缓存变量
- for(i=10;i>0;i--)
- huatu(tu1);
- while(1)
- {
-
- while(!biaozhi)
- key();
- if(biaozhi)
- {
- LCD12864_Init();
- LCD12864_DisplayCLR();
- LCD_writedcmd(0x01);
- if(stat==1)
- {
-
- LCD12864_DisplayChinese(0x80,zifu1);
- LCD12864_DisplayChinese(0x98,zifu2);
- boxing32(recode);
- sprintf(boma,"%04X",recodehigh);
- sprintf(&boma[4],"%04X",recodelow);
- LCD12864_DisplayChinese(0x9c,boma);
- }
-
- else if(stat==2)
- {
-
- LCD12864_DisplayChinese(0x80,zifu3);
- LCD12864_DisplayChinese(0x98,zifu4);
- boxing16(recodehigh);
- sprintf(xitongma,"%04X",recodehigh);
- LCD12864_DisplayChinese(0x9d,xitongma);
-
- }
-
- else if(stat==3)
- {
-
- LCD12864_DisplayChinese(0x80,zifu5);
- LCD12864_DisplayChinese(0x98,zifu6);
- boxing16(recodelow);
- sprintf(yonghuma,"%04X",recodelow);
- LCD12864_DisplayChinese(0x9d,yonghuma);
- }
- biaozhi=0;
- }
- }
- }
复制代码
程序.zip
(46.89 KB, 下载次数: 229)
|