📄 lcddrive.lst
字号:
C51 COMPILER V8.05a LCDDRIVE 04/20/2009 18:39:19 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE LCDDRIVE
OBJECT MODULE PLACED IN lcddrive.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE lcddrive.c OPTIMIZE(4,SPEED) REGFILE(.\gongz.ORC) BROWSE DEBUG OBJECTEXTEND
line level source
1 #include "lcddrive.h"
2 #include <string.h>
3
4 #define databus P2
5 sbit CS=P1^1;
6 sbit CD=P3^5;
7 sbit WRB=P3^6;
8
9
10 //sbit TCK = P1^4; //底板时钟线接口,待连接外部中断0 P3.2
11 sbit TDA = P1^3; //底板数据线接口
12
13 void LCD_WriteCommand(char com)
14 {
15 1 CS=0;
16 1 CD=0; //write command
17 1 WRB=0;
18 1 databus=com;
19 1 WRB=1;
20 1 CD=1;
21 1 CS=1;
22 1 }
23
24 void LCD_WriteData(char dat)
25 {
26 1 CS=0;
27 1 CD=1; //write display datas
28 1 WRB=0;
29 1 databus=dat;
30 1 WRB=1;
31 1 CD=0;
32 1 CS=1;
33 1 }
34
35 void CopyRAMToLCD(int x1, int y1, int x2, int y2)
36 {
37 1 unsigned char row,row1,bytenum,j;
38 1 int validbytecnt;
39 1 unsigned char temp,temp1,temp2,temp3,temp4,temp5,temp6,temp7,temp8;
40 1 unsigned char h11,h12,h13,h14,h15,h16,h17,h18,d1,d2,d3,d4;
41 1 unsigned char *pdatabuf_1=0;
42 1 //unsigned char *pdatabuf_2=0;
43 1
44 1 validbytecnt=0;
45 1
46 1 // GUI_FillSCR(0xaa);
47 1
48 1 // if((x1 > GUI_LCM_XMAX)||(y1 > GUI_LCM_YMAX)) return;
49 1
50 1 //截取有效图形-有效行数
51 1 // if( (y2-y1) < GUI_LCM_YMAX) validcolnum=y2-y1+1;
52 1 // else validcolnum=GUI_LCM_YMAX-y1+1;
53 1
54 1 //截取有效图形-有效列数
55 1 // if((x2-x1) < GUI_LCM_XMAX) validrownum=x2-x1+1;
C51 COMPILER V8.05a LCDDRIVE 04/20/2009 18:39:19 PAGE 2
56 1 // else validrownum=GUI_LCM_XMAX-x1+1;
57 1
58 1 // pdatabuf=&DispBuff[0][0];//(INT8U*)malloc(sizeof(INT8U)*validcolnum*((pPicture->width/8)*4+1));//动态
-申请内存,行字节数扩展至4倍加1
59 1 // memcpy(pdatabuf, 0xFF, 20);
60 1 // *pdatabuf=0xff;
61 1 for (row=y1,row1=0; row<=y2; row++,row1++) //行
62 1 {
63 2
64 2 // pdata_1=DispRAM+row*((GUI_LCM_XMAX/8)*4+1); //扩展后图:pdata_1指向第col行首地址
65 2 pdatabuf_1=DispBuff_uc1698; //扩展后图:pdata_1指向第col行首地址
66 2 //pdatabuf_2=&DispBuff[0][0];
67 2 //pdatabuf_2 += row*(GUI_LCM_XMAX/8); //原图:pdata_2指向第col行首地址
68 2 // DispBuff[1][2]=0x36;
69 2 for (bytenum=0; bytenum<(GUI_LCM_XMAX/8);bytenum++) //列
70 2 {
71 3 // temp=*(pdatabuf_2+bytenum); //change 1byte B/W data to 4k-color data
72 3 // DispBuff[row][bytenum]=0x25;
73 3 temp=DispBuff[row1][bytenum]; //change 1byte B/W data to 4k-color data
74 3 temp1=temp&0x80;
75 3 temp2=(temp&0x40)>>3;
76 3 temp3=(temp&0x20)<<2;
77 3 temp4=(temp&0x10)>>1;
78 3 temp5=(temp&0x08)<<4;
79 3 temp6=(temp&0x04)<<1;
80 3 temp7=(temp&0x02)<<6;
81 3 temp8=(temp&0x01)<<3;
82 3 h11=temp1|temp1>>1|temp1>>2|temp1>>3;
83 3 h12=temp2|temp2>>1|temp2>>2|temp2>>3;
84 3 h13=temp3|temp3>>1|temp3>>2|temp3>>3;
85 3 h14=temp4|temp4>>1|temp4>>2|temp4>>3;
86 3 h15=temp5|temp5>>1|temp5>>2|temp5>>3;
87 3 h16=temp6|temp6>>1|temp6>>2|temp6>>3;
88 3 h17=temp7|temp7>>1|temp7>>2|temp7>>3;
89 3 h18=temp8|temp8>>1|temp8>>2|temp8>>3;
90 3
91 3 d1=h11|h12;
92 3 d2=h13|h14;
93 3 d3=h15|h16;
94 3 d4=h17|h18;
95 3 //扩展后的数据保存扩展内存中
96 3 *(pdatabuf_1++)=d1;
97 3 // validbytecnt++;
98 3 // row+=2;
99 3 // if(row>=validrownum) break;
100 3
101 3 *(pdatabuf_1++)=d2;
102 3 // validbytecnt++;
103 3 // row+=2;
104 3 // if(row>=validrownum) break;
105 3
106 3 *(pdatabuf_1++)=d3;
107 3 // validbytecnt++;
108 3 // row+=2;
109 3 // if(row>=validrownum) break;
110 3
111 3 *(pdatabuf_1++)=d4;
112 3 // validbytecnt++;
113 3 // row+=2;
114 3 // if(row>=validrownum) break;
115 3 }
116 2 LCD_WriteCommand(0x70|(row>>4)); //set row MSB address
C51 COMPILER V8.05a LCDDRIVE 04/20/2009 18:39:19 PAGE 3
117 2 LCD_WriteCommand(0x60|(row&0x0F)); //set row LSB address
118 2 LCD_WriteCommand(0x12); //set column MSB address // 12
119 2 LCD_WriteCommand(0x05); //set column LSB address //37 05
120 2
121 2 for(j=x1;j<(x2+3)/2;j++) //保证每行写满81个字节
122 2 {
123 3 //DispBuff_uc1698[j]=0xf0;
124 3 LCD_WriteData(DispBuff_uc1698[j]);
125 3 }
126 2 }
127 1
128 1 }
129
130 void delay(uint t)
131 {
132 1 uint i;
133 1 while(--t)
134 1 for(i=0;i<100;i++);
135 1 }
136
137 void init_uc1698(void)
138 {
139 1 LCD_WriteCommand(0xe2); //system reset
140 1 delay(100);
141 1 LCD_WriteCommand(0x31);
142 1 LCD_WriteCommand(0x08);
143 1 LCD_WriteCommand(0x2b); // internal power control
144 1 //wr_command(0x25); //set TC=-0.05%
145 1 LCD_WriteCommand(0xA0); //set line rate
146 1 LCD_WriteCommand(0xeb); //0XEA//set bias
147 1 LCD_WriteCommand(0xf1); //set com end
148 1 LCD_WriteCommand(0x9f); //set duty :1/160
149 1 LCD_WriteCommand(0x81); //set VLCD value
150 1 LCD_WriteCommand(0x80); //VLCD=(CV0+Cpm*pm)*(1+(T-25)*CT%)
151 1 LCD_WriteCommand(0xc4); //0XC4 //set LCD mapping control //scan dirction com0~127
152 1 LCD_WriteCommand(0x89); //set RAM address control
153 1 LCD_WriteCommand(0xd1); // R_G_B
154 1 LCD_WriteCommand(0xd5); //4k color
155 1 LCD_WriteCommand(0xc8);
156 1 LCD_WriteCommand(0x18);
157 1 //wr_command(0xde);
158 1 //wr_command(0xad); //0xad//display on
159 1 LCD_WriteCommand(0xad); //0xad//display on
160 1 }
161
162 void RAM_ADDRESS(void)
163 {
164 1 LCD_WriteCommand(0xf4); //set oolumn start address
165 1 LCD_WriteCommand(0x25); // start address
166 1 LCD_WriteCommand(0xf6); // set column end address
167 1 LCD_WriteCommand(0x5a); //(0x4f+1)*3=240 5a //90
168 1
169 1 LCD_WriteCommand(0xf5); //set row start address
170 1 LCD_WriteCommand(0x00); //start address=0x00
171 1 LCD_WriteCommand(0xf7); //set row end address
172 1 LCD_WriteCommand(0x9f); //row end address=9f
173 1 LCD_WriteCommand(0x70); //set row MSB address
174 1 LCD_WriteCommand(0x60); //set row LSB address
175 1 LCD_WriteCommand(0x12); //set column MSB address // 12
176 1 LCD_WriteCommand(0x05); //set column LSB address //37 05
177 1 LCD_WriteCommand(0xf8); //inside mode
178 1 }
C51 COMPILER V8.05a LCDDRIVE 04/20/2009 18:39:19 PAGE 4
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 776 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 36
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -