完整word版160128LCD图文演示.docx
- 文档编号:5412116
- 上传时间:2023-05-08
- 格式:DOCX
- 页数:17
- 大小:48.44KB
完整word版160128LCD图文演示.docx
《完整word版160128LCD图文演示.docx》由会员分享,可在线阅读,更多相关《完整word版160128LCD图文演示.docx(17页珍藏版)》请在冰点文库上搜索。
完整word版160128LCD图文演示
#include〈LCD_160128。
h〉
#include h> externvoidcls(); externucharLCD_Initialise(); externucharLCD_Write_Command(ucharcmd); externucharLCD_Write_Command_P2(ucharcmd,ucharpara1,ucharpara2); externucharLCD_Write_Data(uchardat); externvoidSet_LCD_POS(ucharrow,ucharcol); externvoidLine(ucharx1,uchary1,ucharx2,uchary2,bitMode); externucharDisplay_Str_at_xy(ucharx,uchary,char*fmt); externucharcodeLCD_WIDTH; externucharcodeLCD_HEIGHT; sbitS1=P1^0; sbitS2=P1^1; sbitS3=P1^2; sbitS4=P1^3; ucharcodeImageX[]= { 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, }; ucharCurrent_Operation=0; ucharStatistics_Data[]={20,70,80,40,90,65,30}; voidDraw_Bar_Graph(uchard[]) { uchari,h; Line(4,2,4,100,1); Line(4,100,158,100,1); Line(4,2,1,10,1); Line(4,2,7,10,1); Line(158,100,152,97,1); Line(158,100,152,103,1); for(i=0;i〈7;i++) { h=100—d[i]; Line(10+i*20,h,10+i*20,100,1); Line(10+i*20,h,10+i*20+15,h,1); Line(10+i*20+15,h,10+i*20+15,100,1); } } voidmain() { uchari,j,m,c=0;uintk,x; LCD_Initialise(); Set_LCD_POS(0,0); cls(); while (1) { if(S1==0)Current_Operation=1; if(S2==0)Current_Operation=2; if(S3==0)Current_Operation=3; if(S4==0)Current_Operation=4; if(c==Current_Operation)gotodelayx; c=Current_Operation; switch(Current_Operation) { case1: case2: LCD_Write_Command_P2(LC_GRH_STP,0x00,0x00); for(i=0;i { Set_LCD_POS(i,0); LCD_Write_Command(LC_AUT_WR); for(j=0;j〈LCD_WIDTH;j++) { m=ImageX[i*LCD_WIDTH+j]; if(S2==0)m=~m; LCD_Write_Data(m); } LCD_Write_Command(LC_AUT_OVR); } break; case3: k=0; while(k! =LCD_WIDTH*LCD_HEIGHT) { LCD_Write_Command_P2(LC_GRH_STP,k%256,k/256); for(x=0;x〈5000;x++); k+=LCD_WIDTH; } break; case4: LCD_Write_Command_P2(LC_GRH_STP,0x00,0x00); Set_LCD_POS(0,0); cls(); Draw_Bar_Graph(Statistics_Data); Display_Str_at_xy(12,110,"statisticsGraph"); break; } delayx: for(x=0;x〈20000;x++); } } #include〈stdarg.h> #include〈stdio.h> #include〈math.h〉 #include #include h> #include〈string。 h〉 #include h〉 sbitRESET=P3^3; #defineASC_CHR_WIDTH8 #defineASC_CHR_HEIGHT12 #defineHZ_CHR_HEIGHT12 #defineHZ_CHR_WIDTH12 ucharcodeLCD_WIDTH=20; ucharcodeLCD_HEIGHT=128; ucharcodeASC_MSK[96*12]= { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; uchargCurRow,gCurCol; uchartCurRow,tCurCol; ucharShowModeSW; uinttxthome,grhome; ucharStatus_BIT_01(); ucharStatus_BIT_3(); ucharGetCol(); ucharGetRow(); ucharLCD_Write_Command(ucharcmd); ucharLCD_Write_Command_P1(ucharcmd,ucharpara1); ucharLCD_Write_Command_P2(ucharcmd,ucharpara1,ucharpara2); ucharLCD_Write_Data(uchardat); ucharLCD_Read_Data(); voidcls(); ucharLCD_Initialise(); voidSet_LCD_POS(ucharrow,ucharcol); voidcharout(uchar*str); uchardprintf(ucharx,uchary,uchar*fmt); voidOutToLCD(ucharDat,ucharx,uchary); voidLine(ucharx1,uchary1,ucharx2,uchary2,bitMode); voidPixel(ucharx,uchary,bitMode); ucharStatus_BIT_01() { uchari; for(i=5;i〉0;i——) { if((LCMCW&0x03)==0x03) break; } returni; } ucharStatus_BIT_3() { uchari; for(i=5;i〉0;i--) { if((LCMCW&0x08)==0x08) break; } returni; } ucharLCD_Write_Command_P2(ucharcmd,ucharpara1,ucharpara2) { if(Status_BIT_01()==0)return1; LCMDW=para1; if(Status_BIT_01()==0)return2; LCMDW=para2; if(Status_BIT_01()==0)return3; LCMDW=cmd; return0; } ucharLCD_Write_Command_P1(ucharcmd,ucharpara1) { if(Status_BIT_01()==0)return1; LCMDW=para1; if(Status_BIT_01()==0)return2; LCMDW=cmd; return0; } ucharLCD_Write_Command(ucharcmd) { if(Status_BIT_01()==0)return1; LCMDW=cmd; return0; } ucharLCD_Write_Data(uchardat) { if(Status_BIT_3()==0)return1; LCMDW=dat; return0; } ucharLCD_Read_Data() { if(Status_BIT_01()==0)return1; returnLCMDW; } voidSet_LCD_POS(ucharrow,ucharcol) { uintPos; Pos=row*LCD_WIDTH+col; LCD_Write_Command_P2(LC_ADD_POS,Pos%256,Pos/256); gCurRow=row; gCurCol=col; } voidcls() { uinti; LCD_Write_Command_P2(LC_ADD_POS,0x00,0x00); LCD_Write_Command(LC_AUT_WR); for(i=0;i〈0x2000;i++) { Status_BIT_3(); LCD_Write_Data(0x00); } LCD_Write_Command(LC_AUT_OVR); LCD_Write_Command_P2(LC_ADD_POS,0x00,0x00); gCurRow=0; gCurCol=0; } ucharLCD_Initialise() { RESET=0; RESET=1; LCD_Write_Command_P2(LC_TXT_STP,0x00,0x00); LCD_Write_Command_P2(LC_TXT_WID,LCD_WIDTH,0x00); LCD_Write_Command_P2(LC_GRH_STP,0x00,0x00); LCD_Write_Command_P2(LC_GRH_WID,LCD_WIDTH,0x00); LCD_Write_Command_P1(LC_CGR_POS,CGRAMSTART〉>11); LCD_Write_Command(LC_CUR_SHP|0x01); LCD_Write_Command(LC_MOD_OR); LCD_Write_Command(LC_DIS_SW|0x08); grhome=GRSTART; txthome=TXTSTART; return0; } ucharDisplay_Str_at_xy(ucharx,uchary,uchar*fmt) { charc1,c2,cData; uchari=0,j,uLen; uLen=strlen(fmt); while(i〈uLen) { c1=fmt[i]; c2=fmt[i+1]; Set_LCD_POS(y,x/8); if(c1〉=0) { if(c1<0x20) { switch(c1) { caseCR: caseLF: i++; x=0; if(y<112)y+=HZ_CHR_HEIGHT; continue; caseBS: i++; if(y〉ASC_CHR_WIDTH)y—=ASC_CHR_WIDTH; cData=0x00; break; } } for(j=0;j〈ASC_CHR_HEIGHT;j++) { if(c1>=0x1f) { cData=ASC_MSK[(c1—0x1f)*ASC_CHR_HEIGHT+j]; Set_LCD_POS(y+j,x/8); if((x%8)==0) { LCD_Write_Command(LC_AUT_WR); LCD_Write_Data(cData); LCD_Write_Command(LC_AUT_OVR); } else OutToLCD(cData,x,y+j); } Set_LCD_POS(y+j,x/8); } if(c1! =BS)x+=ASC_CHR_WIDTH; } i++; } returnuLen; } voidOutToLCD(ucharDat,ucharx,uchary) { uchardat1,dat2,a,b; b=x%8; a=8-b; Set_LCD_POS(y,x/8); LCD_Write_Command(LC_AUT_RD); dat1=LCD_Read_Data(); dat2=LCD_Read_Data();
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整 word 160128 LCD 图文 演示