您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 人事档案/员工关系 > 160128LCD图文演示
#includeLCD_160128.h#includestdio.hexternvoidcls();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;i7;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;iLCD_HEIGHT;i++){Set_LCD_POS(i,0);LCD_Write_Command(LC_AUT_WR);for(j=0;jLCD_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;x5000;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;x20000;x++);}}#includestdarg.h#includestdio.h#includemath.h#includeintrins.h#includeabsacc.h#includestring.h#includeLCD_160128.hsbitRESET=P3^3;#defineASC_CHR_WIDTH8#defineASC_CHR_HEIGHT12#defineHZ_CHR_HEIGHT12#defineHZ_CHR_WIDTH12ucharcodeLCD_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;i0;i--){if((LCMCW&0x03)==0x03)break;}returni;}ucharStatus_BIT_3(){uchari;for(i=5;i0;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;i0x2000;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,CGRAMSTART11);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(iuLen){c1=fmt[i];c2=fmt[i+1];Set_LCD_POS(y,x/8);if(c1=0){if(c10x20){switch(c1){caseCR:caseLF:i++;x=0;if(y112)y+=HZ_CHR_HEIGHT;continue;caseBS:i++;if(yASC_CHR_WIDTH)y-=ASC_CHR_WIDTH;cData=0x00;break;}}for(j=0;jASC_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);}elseOutToLCD(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,
本文标题:160128LCD图文演示
链接地址:https://www.777doc.com/doc-3519884 .html