201612rw76nslgn7g1g9rp.jpg (66.7 KB, 下載次數: 455)
下載附件
2015-6-6 03:45 上傳
201234vvnygx01t11f8z86.jpg (106.66 KB, 下載次數: 433)
下載附件
2015-6-6 03:45 上傳
201245nif6p6rxi39f34x9.jpg (67.31 KB, 下載次數: 487)
下載附件
2015-6-6 03:45 上傳
201244papbieesbiy5iiei.jpg (71.63 KB, 下載次數: 481)
下載附件
2015-6-6 03:45 上傳
201248up0zf9j4h8j3g70p.jpg (82.8 KB, 下載次數: 473)
下載附件
2015-6-6 03:45 上傳
20124745tv7ttwvwft2zwz.jpg (63.53 KB, 下載次數: 480)
下載附件
2015-6-6 03:45 上傳
201235mvmi22wz1r3g1y2y.jpg (60.3 KB, 下載次數: 437)
下載附件
2015-6-6 03:45 上傳
程序與原理圖如下:- /*******************************************************************************************************************************
-
- 長沙太陽人”杯紅外波形顯示單片機設計大賽
- ***
- ***** 作品: 紅外波形顯示
- ***
- **** 功能描述: 檢測 顯示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)
2015-6-6 03:33 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
原理圖.rar
(11.21 KB, 下載次數: 183)
2015-6-6 03:33 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|