1、完整word版160128LCD图文演示#include LCD_160128。h#include extern void cls();extern uchar LCD_Initialise();extern uchar LCD_Write_Command(uchar cmd);extern uchar LCD_Write_Command_P2(uchar cmd,uchar para1,uchar para2);extern uchar LCD_Write_Data(uchar dat);extern void Set_LCD_POS(uchar row,uchar col);extern
2、void Line(uchar x1,uchar y1,uchar x2,uchar y2,bit Mode);extern uchar Display_Str_at_xy(uchar x,uchar y,char *fmt);extern uchar code LCD_WIDTH;extern uchar code LCD_HEIGHT;sbit S1 = P10;sbit S2 = P11;sbit S3 = P12;sbit S4 = P13;uchar code ImageX= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
3、,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,;uchar Current_Operation = 0;uchar Statistics_Data=20,70,80,40,90,65,30; void Draw_Bar_Graph(uchar d) uchar i,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); Li
4、ne(158,100,152,97,1); Line(158,100,152,103,1); for(i=0;i7;i+) h=100di; Line(10+i20,h,10+i20,100,1); Line(10+i*20,h,10+i20+15,h,1); Line(10+i*20+15,h,10+i*20+15,100,1); void main() uchar i,j,m,c=0;uint k,x; LCD_Initialise(); Set_LCD_POS(0,0); cls(); while(1) if(S1=0) Current_Operation = 1; if(S2=0) C
5、urrent_Operation = 2; if(S3=0) Current_Operation = 3; if(S4=0) Current_Operation = 4; if(c=Current_Operation) goto delayx; c=Current_Operation; switch(Current_Operation) case 1: case 2: LCD_Write_Command_P2(LC_GRH_STP,0x00,0x00); for(i=0;iinclude stdio.hinclude math.h#include #include include string
6、。h#include 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; return 0;uchar Display_Str_at_xy(uchar x,uchar y,uchar *fmt) char c1,c2,cData; uchar i=0,j,uLen; uLen = strlen(fmt); while(iuLen) c1 = fmti; c2 =
7、 fmti+1; Set_LCD_POS(y,x/8); if(c1=0) if(c10x20) switch(c1) case CR: case LF: i+; x=0; if(y=0x1f) cData = ASC_MSK(c10x1f)*ASC_CHR_HEIGHT+j; Set_LCD_POS(y+j,x/8); if((x8)=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
8、,x/8); if(c1!=BS) x+=ASC_CHR_WIDTH; i+; return uLen;void OutToLCD(uchar Dat,uchar x,uchar y) uchar dat1,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(); dat1 = (dat1 &(0xffb)) (Data); LCD_Write_Command(LC_AUT_OVR); Set_LCD_
9、POS(y,x/8); LCD_Write_Command(LC_AUT_WR); LCD_Write_Data(dat1); LCD_Write_Data(dat2); LCD_Write_Command(LC_AUT_OVR);void Pixel(uchar x,uchar y,bit Mode) uchar start_addr,dat; start_addr=7(x%8); dat = LC_BIT_OP start_addr; if(Mode) dat |= 0x08; Set_LCD_POS(y,x/8); LCD_Write_Command(LC_BIT_OP dat);voi
10、d Exchange(uchar a,uchar *b) uchar t; t = a;a = *b;*b = t;void Line(uchar x1,uchar y1,uchar x2,uchar y2,bit Mode) uchar x,y; float k,b; if(abs(y1y2)=abs(x1-x2) k=(float)(y1-y2)/(float)(x2-x1); b=y1k*x1; if(x1x2) Exchange(x1,x2); for(x=x1;x=x2;x+) y=(uchar)(kx+b); Pixel(x,y,Mode); else k=(float)(x2x1
11、)/(float)(y2y1); b=x1-k*y1; if(y1y2) Exchange(&y1,y2); for(y=y1;y=y2;y+) x=(uchar)(ky+b); Pixel(x,y,Mode); include include intrins.hinclude stdarg。h#include include #include define uint unsigned int#define uchar unsigned chardefine STX 0x02#define ETX 0x03#define EOT 0x04define ENQ 0x05#define BS 0x
12、08define CR 0x0ddefine LF 0x0a#define DLE 0x10define ETB 0x17#define SPACE 0x20#define COMMA 0x2cdefine TRUE 1define FALSE 0#define HIGH 1#define LOW 0define LCMDW XBYTE0x8000define LCMCW XBYTE0x8100define DISRAM_SIZE 0x7fffdefine TXTSTART 0x0000define GRSTART 0x6800define CGRAMSTART 0x7800#define L
13、C_CUR_POS 0x21define LC_CGR_POS 0x22#define LC_ADD_POS 0x24#define LC_TXT_STP 0x40define LC_TXT_WID 0x41define LC_GRH_STP 0x42#define LC_GRH_WID 0x43define LC_MOD_OR 0x80#define LC_MOD_XOR 0x81define LC_MOD_AND 0x82define LC_MOD_TCH 0x83define LC_DIS_SW 0x90#define LC_CUR_SHP 0xa0#define LC_AUT_WR 0xb0#define LC_AUT_RD 0xb1#define LC_AUT_OVR 0xb2#define LC_INC_WR 0xc0define LC_INC_RD 0xc1#define LC_DEC_WR 0xc2define LC_DEC_RD 0xc3#define LC_NOC_WR 0xc4#define LC_NOC_RD 0xc5#define LC_SCN_RD 0xe0define LC_INC_CP 0xe8define LC_BIT_OP 0xf0
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1