资源描述:
《LCD12864画点画线画圆画正弦波.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.LCD12864画点画线画圆画正弦波实际效果图如下:C程序如下:#include#include#defineucharunsignedchar#defineuintunsignedint#defineLCDP0ucharchip_select=1;bitcolor=0;sbite=P2^1;sbitrw=P2^2;sbitrs=P2^3;sbitcs2=P2^4;sbitcs1=P2^5;ucharline=0;ucharselect=0;voiddelay(uinti){while(i--);}/************************
2、***checkbusy************************/voidcheckBusy()//检查LCD是否忙{uchardat;rs=0;Word资料.//指令操作rw=1;//读出操作do{LCD=0xff;//P0设置为输入e=1;//给使能信号dat=0x80&LCD;//只判断DB7位的状态e=0;}while(dat==0x80);//忙则继续检测}voidlcdWrite(bitml,ucharzifu){checkBusy();rs=ml;rw=0;P0=zifu;e=1;delay(1);e=0;}voidClearLCD(ucharzifu){uch
3、ari,j;lcdWrite(0,0x3f);cs1=1;cs2=1;for(i=0;i<8;i++){lcdWrite(0,0xb8+i);lcdWrite(0,0xc0);lcdWrite(0,0x40);for(j=0;j<64;j++){lcdWrite(1,zifu);}}}voidinitLCD()//初始化{cs1=1;Word资料.cs2=1;lcdWrite(0,0x3e);//关显示lcdWrite(0,0x3f);//开显示ClearLCD(0x0f);//清屏}/*液晶显示函数*//*x和y来控制显示的位置,x为行,y为列,x1和y1为字的像素行数,x2为显示
4、几行,y2为显示几个字数*/voidjis(ucharx,uchary,ucharx1,uchary1,ucharx2,uchary2,ucharcode*hz){uchari,j,k,l,a;lcdWrite(0,0x3f);//开显示for(i=0;i5、hz[a+l]);}}}}}/*****************************writedata************************/voidWriteData(uchardsp_data){if(chip_select==1){cs1=1;cs2=0;}else{Word资料.cs1=0;cs2=1;}checkBusy();lcdWrite(1,dsp_data);}/****************************readdata***********************/ucharReadData(void){uchardsp_data;ch
6、eckBusy();LCD=0xFF;if(chip_select==1){cs2=0;cs1=1;}else{cs2=1;cs1=0;}rw=1;rs=1;e=1;e=0;e=1;//E的下降沿,然后E持续拉高读才有效dsp_data=LCD;e=0;return(dsp_data);}ucharj=0,i=0;ucharr=32;ucharcodehz[]={0x20,0x30,0xAC,0x63,0x10,0x00,0x40,0x20,0x58,0x47,0x44,0x48,0x50,0x20,0x20,0x00,0x22,0x23,0x22,0x12,0x12,0x00,0x
7、42,0x62,0x5A,0x46,0x42,0x42,0x52,0xE2,0x42,0x00,/*"绘",0*/0x00,0xFE,0x42,0x42,0x22,0x1E,0xAA,0x4A,0xAA,0x9A,0x0A,0x02,0x02,0xFE,0x00,0x00,0x00,0xFF,0x42,0x42,0x41,0x41,0x48,0x72,0x54,0x40,0x41,0x43,0x41,0xFF,0x00,0x00,/*"图",1*/0x10