资源描述:
《JLX12864G-086-P官方例程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、sbitcs1=P1^1;sbitreset=P1^0;sbitrs=P3^0;sbitsclk=P3^1;sbitsid=P3^2;//sid就是SDA,串行数据信号voidTransfer_data(intdata1);voidTransfer_command(intdata1);unsignedcharcodegraphic1[];voidDelay(inti);voidDelay1(inti);voidDisplayGraphic1();voidInitial_Lcd();voidclear_screen();voidSwitch();//=============
2、==mainprogram===================voidmain(void){inti,j,k;Initial_Lcd();while(1){clear_screen();//clearalldotsDisplayGraphic1();//displayapictureof128*64dotsSwitch();}}//============initialvoidInitial_Lcd(){reset=0;//Resetthechipwhenreset=0Delay(50);reset=1;Delay(50);Transfer_command(0xe2);/
3、*软复位*/Transfer_command(0x2c);/*升压步聚1*/Transfer_command(0x2e);/*升压步聚2*/Transfer_command(0x2f);/*升压步聚3*/Transfer_command(0x23);/*粗调对比度,可设置范围20~27*/Transfer_command(0x81);/*微调对比度*/Transfer_command(0x28);/*微调对比度的值,可设置范围0~63*/Transfer_command(0xa2);/*1/9偏压比(bias)*/Transfer_command(0xc8);/*行扫描顺序
4、:从上到下*/Transfer_command(0xa0);/*列扫描顺序:从左到右*/Transfer_command(0xaf);/*开显示*/}//===============clearalldotmartrics=============voidclear_screen(){unsignedchari,j;for(i=0;i<9;i++){cs1=0;Transfer_command(0xb0+i);Transfer_command(0x10);Transfer_command(0x00);for(j=0;j<132;j++){Transfer_data(0x00
5、);}}}//==================displayapitureof128*64dots================voidDisplayGraphic1(){unsignedchar*address;//definepointerinti,j;address=graphic1;//datapointer:pointto"graphic[]",one-dimensionalarrayfor(i=0;i<8;i++)}{chari;cs1=0;rs=0;for(i=0;i<8;i++){sclk=0;if(data1&0x80)sid=1;elsesid=0
6、;Delay1(2);sclk=1;Delay1(2);data1=data1<<=1;}}/*--------写数据------------*/voidTransfer_data(intdata1){chari;cs1=0;rs=1;for(i=0;i<8;i++){sclk=0;if(data1&0x80)sid=1;elsesid=0;sclk=1;data1=data1<<=1;}}}/*=========等按键=====================*/voidSwitch(){repeat:if(P2&0x01)gotorepeat;elseDelay(1);
7、if(P2&0x01)gotorepeat;else;}//--------------------------------------------unsignedcharcodegraphic1[]={/*--调入了一幅图像:d:MyDocumentsMyPictures多字.bmp--*//*--宽度x高度=128x64--*/0x00,0x00,0x00,0x00,0x7E,0x2A,0x2A,0x2A,0x2A,0x2A,0x2A,0x7E,0x00,0x00,0x00,0x00,0x02,0xFE,