12864液晶显示器(ST7920)显示程序(并口) 附字模软件
前两天写了一个ST7920控制12864显示的串口程序,今天瞎逛的时候发现了这个超强悍的并口程序,转载一下。来源:CnChina
做了比较详细的注释,看不懂的可以问我。下面的图片中12864所显示的logo就是我用这个程序得到的。
附程序:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
/****************************************************************************** Copyright 2007 All rights reserved. 文件名 : .c 模块名称:st7920 并行方式驱动12864液晶驱动 功能概要:st7920显示驱动 取代版本:0.0.1 修改人 :pulan 完成日期:2007.07.08 升级说明:create CPU: stc89c58 主频:11.0592M 液晶型号:128*64 生产厂家: 驱动芯片:st7920 ******************************************************************************/ #include <reg52.h> #define uint unsigned int #define uchar unsigned char #define x1 0x80 //1000 0000 #define x2 0x88 //1000 1000 #define y 0x80 //1000 0000 #define comm 0 //定义传送指令代码为0 #define dat 1 //定义传送数据代码为1 sbit RS = P2^0; //H=数据; L=指令; sbit RW = P2^1; //H=读操作; L=写操作; sbit E = P2^3; //使能端 sbit PSB= P2^4; //H=并口; L=串口; sbit RST= P2^2; //复位信号 低电平有效 sbit busy=P0^7; //LCD忙信号 void wr_lcd (uchar dat_comm,uchar content); void chk_busy (void); void delay (uint us); uchar code tab1[]={ "本系列中文模块内" "任意位置反白显示" "置二级字库,可在" "使用更方便更灵活" }; uchar code tab31[]={ "金鹏科技有限公司" "Golden Palm TECH" }; uchar code tab32[]={ /*-- 调入了一幅图像:F:梁画图HOCO12832.bmp --*/ /*-- 宽度x高度=128x32 --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x18,0x0C,0x00,0x00,0x01,0x00,0x00,0x00,0x00, 0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x13,0x10,0x03,0xFE,0x00, 0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x3F,0x30,0x1F,0xFF,0xC0, 0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,0x8C,0x03,0xF0,0x00,0x7F,0xE0,0x7C,0x01,0xE0, 0x03,0xFF,0xF0,0x00,0x00,0x00,0x01,0x36,0x06,0xC0,0x00,0x5F,0xC0,0xFF,0xFC,0x60, 0x01,0xFF,0xF0,0x00,0x00,0x00,0x02,0x1B,0x0F,0x80,0x00,0xFF,0x01,0xFE,0x0F,0x30, 0x00,0xEF,0xF0,0x00,0x00,0x00,0x02,0x6D,0x9F,0x00,0x00,0x3E,0x03,0xFF,0xF1,0x90, 0x00,0xFF,0xF8,0x00,0x00,0x00,0x04,0x36,0xFE,0x00,0x01,0xFF,0x07,0xFF,0xFC,0x90, 0x00,0xEF,0xFF,0xFF,0x80,0x00,0x04,0xDB,0x7E,0x00,0x03,0xFF,0x87,0xFF,0xFC,0xD0, 0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x04,0x6D,0xFC,0x00,0x07,0xFF,0x8F,0xFF,0xFE,0x50, 0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x36,0xFC,0x10,0x07,0xFF,0x8F,0xFF,0xFE,0x90, 0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x1B,0xF8,0x10,0x07,0xFF,0xCF,0xFF,0xFE,0x80, 0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x04,0x0F,0xF8,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00, 0x00,0x07,0xFF,0xFF,0xF0,0x00,0x04,0x07,0xF0,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00, 0x00,0xFF,0xFF,0xFF,0xF8,0x00,0x02,0x03,0xF0,0x20,0x07,0xFF,0xFF,0xFF,0xBA,0x00, 0x00,0xFD,0xFF,0xFF,0xFC,0x00,0x02,0x03,0xF0,0x20,0x03,0xFF,0xFF,0xDF,0xB8,0x00, 0x00,0xC1,0xC0,0x3F,0xFC,0x00,0x01,0x01,0xE0,0x40,0x00,0xFF,0xFF,0xDF,0xB0,0x00, 0x00,0x81,0xC0,0x3F,0xCE,0x00,0x00,0x81,0xE0,0x80,0x00,0x7F,0xFF,0xDF,0xA0,0x00, 0x00,0x81,0x80,0x1D,0xCF,0x00,0x00,0x41,0xE1,0x00,0x00,0x3F,0xFF,0x9B,0x00,0x00, 0x01,0x83,0x80,0x1F,0xC7,0x80,0x00,0x21,0xE2,0x00,0x00,0x1F,0xFD,0xB6,0x00,0x00, 0x01,0xC3,0x00,0x0E,0xE6,0x80,0x00,0x19,0xEC,0x00,0x00,0x07,0xFE,0x20,0x00,0x00, 0x00,0xC3,0x00,0x07,0x67,0x40,0x00,0x07,0xF0,0x00,0x00,0x03,0x3E,0x00,0x00,0x00, 0x00,0x02,0x00,0x03,0xE7,0xA0,0x00,0x00,0x00,0x00,0x00,0x02,0x8E,0x00,0x00,0x00, 0x00,0x06,0x00,0x03,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x00,0x00,0x00, 0x00,0x06,0x00,0x07,0x03,0x00,0x77,0x46,0x74,0x24,0x80,0x06,0x04,0x00,0x00,0x00, 0x00,0x1C,0x00,0x06,0x00,0x00,0x55,0x45,0x54,0x57,0x80,0x00,0x00,0x00,0x00,0x00, 0x00,0x1C,0x00,0x0E,0x00,0x00,0x45,0x45,0x74,0x57,0x80,0x08,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x1C,0x00,0x00,0x55,0x45,0x44,0x74,0x80,0xF0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x38,0x00,0x00,0x77,0x76,0x47,0x54,0x80,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; uchar code tab5[]={ /*-- 调入了一幅图像:F:梁画图COCK.bmp --*/ /*-- 宽度x高度=128x64 --*/ 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, 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, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00,0x00,0x00, 0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00,0x00,0x00, 0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00,0x00,0x00, 0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00,0x00,0x00, 0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00,0x00,0x00, 0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00,0x00,0x00, 0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00, 0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x40,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,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 }; /****************************************************************************************** * 函数名称 :init_lcd * 功能描述 :初始化LCD ******************************************************************************************/ void init_lcd (void) { RST = 1; PSB = 1; wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据 基本指令操作 wr_lcd(comm,0x01); //0000 0001 清屏——将DDRAM填满"20H",并且设定DDRAM的地址计数器为"00H" wr_lcd(comm,0x06); //0000 0110 进入点设定——指定在数据的读取与写入时,设定游标的移动方向 wr_lcd(comm,0x0c); //0000 1100 游标或显示移位控制——开显示,关游标 } /****************************************************************************************** * 函数名称 :chn_disp * 功能描述 :显示汉字或字符 ******************************************************************************************/ void chn_disp(uchar code *chn) { uchar i,j; //i为横坐标,j为纵坐标 wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据 基本指令操作 wr_lcd(comm,0x80); //1000 0000 设定DDRAM地址——0000000 for(j=0;j<4;j++) //写四行数据 { for(i=0;i<16;i++) wr_lcd(dat,chn[j*16+i]); } } /****************************************************************************************** * 函数名称 :chn_disp1 * 功能描述 : 上半屏显示汉字或字符 ******************************************************************************************/ void chn_disp1(uchar code *chn) { uchar i,j; wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据 基本指令操作 wr_lcd(comm,0x80); //1000 0000 设定第一行的DDRAM地址——0x80 j=0; //第一行 for(i=0;i<16;i++) wr_lcd(dat,chn[j*16+i]); wr_lcd(comm,0x90); //1001 0000 设定第二行的DDRAM地址——0x90 j=1; //第二行 for(i=0;i<16;i++) wr_lcd(dat,chn[j*16+i]); } /****************************************************************************************** * 函数名称 :img_disp * 功能描述 :显示图形 ******************************************************************************************/ void img_disp(uchar code *img) { uchar i,j; for(j=0;j<32;j++) //绘制上半屏 { for(i=0;i<8;i++) { wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据 扩充指令操作 绘图开 wr_lcd(comm,y+j); //1xxx xxxx 设定绘图RAM——先设定垂直(列)地址AC6 AC5…AC0 wr_lcd(comm,x1+i); //1000 0xxx 设定绘图RAM——再设定水平(行)地址AC3AC2AC1AC0 wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据 基本指令操作 wr_lcd(dat,img[j*16+i*2]); wr_lcd(dat,img[j*16+i*2+1]); } } for(j=32;j<64;j++) //绘制下半屏 { for(i=0;i<8;i++) { wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据 扩充指令操作 绘图开 wr_lcd(comm,y+j-32); //1xxx xxxx 设定绘图RAM——先设定垂直(列)地址AC6 AC5…AC0 wr_lcd(comm,x2+i); //1000 1xxx 设定绘图RAM——再设定水平(行)地址AC3AC2AC1AC0 wr_lcd(comm,0x30); //0011 0000 扩充功能设定——8位数据 基本指令操作 wr_lcd(dat,img[j*16+i*2]); wr_lcd(dat,img[j*16+i*2+1]); } } wr_lcd (comm,0x36); //0011 0110 扩充功能设定——8位数据 扩充指令操作 绘图关 } /****************************************************************************************** * 函数名称 :img_disp1 * 功能描述 :下半屏显示图形 ******************************************************************************************/ void img_disp1(uchar code *img) { uchar i,j; for(j=0;j<32;j++) { for(i=0;i<8;i++) { wr_lcd(comm,0x34); wr_lcd(comm,y+j); wr_lcd(comm,x2+i); wr_lcd(comm,0x30); wr_lcd(dat,img[j*16+i*2]); wr_lcd(dat,img[j*16+i*2+1]); } } wr_lcd(comm,0x36); } /****************************************************************************************** * 函数名称 :lat_disp * 功能描述 :显示点阵 ******************************************************************************************/ void lat_disp(uchar data1,uchar data2) { uchar i,j,k,x; x=x1; //1000 0000 for(k=0;k<2;k++) //第一次循环x=1000 0000 第二次循环x=1000 1000 { for(j=0;j<16;j++) { for(i=0;i<8;i++) { wr_lcd(comm,0x34); //0011 0100 扩充功能设定——8位数据 扩充指令操作 绘图开 wr_lcd(comm,y+j*2); wr_lcd(comm,x+i); wr_lcd(comm,0x30); wr_lcd(dat,data1); wr_lcd(dat,data1); } for(i=0;i<8;i++) { wr_lcd(comm,0x34); wr_lcd(comm,y+j*2+1); wr_lcd(comm,x+i); wr_lcd(comm,0x30); wr_lcd(dat,data2); wr_lcd(dat,data2); } } x=x2; } wr_lcd(comm,0x36); } /****************************************************************************************** * 函数名称 :con_disp * 功能描述 :当data1=0xff,data2=0xff时,在x0,y0处反白显示16xl*yl ******************************************************************************************/ void con_disp(uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl) { uchar i,j; for(j=0;j<yl;j++) { for(i=0;i<xl;i++) { wr_lcd(comm,0x34); wr_lcd(comm,y0+j); wr_lcd(comm,x0+i); wr_lcd(comm,0x30); wr_lcd(dat,data1); wr_lcd(dat,data2); } } wr_lcd(comm,0x36); } /****************************************************************************************** * 函数名称 :clrram * 功能描述 :将DDRAM填满"20H",并且设定DDRAM的地址计数器(AC)到"00H" ******************************************************************************************/ void clrram(void) { wr_lcd(comm,0x30); wr_lcd(comm,0x01); } /****************************************************************************************** * 函数名称 :wr_lcd * 功能描述 :当dat_comm=0时,写入指令,dat_comm=1时,写入数据 ******************************************************************************************/ void wr_lcd(uchar dat_comm,uchar content) { chk_busy (); if(dat_comm) { RS = 1; //数据 RW = 0; //写 } else { RS = 0; //指令 RW = 0; //写 } P0=content; //输出数据或指令 E = 1; E = 0; } /****************************************************************************************** * 函数名称 :chk_busy * 功能描述 :检测LCD忙信号 ******************************************************************************************/ void chk_busy(void) { P0 = 0xff; RS = 0; RW = 1; E = 1; while(busy==1); E = 0; } /****************************************************************************************** * 函数名称 :delay * 功能描述 :延时函数 ******************************************************************************************/ void delay(uint us) //delay time { while(us--); } /****************************************************************************************** * 函数名称 :delay1 * 功能描述 :延时函数 1ms ******************************************************************************************/ void delay1(uint ms) { uint i,j; for(i=0;i<ms;i++) for(j=0;j<15;j++) delay(1); } /****************************************************************************************** * 函数名称 :main * 功能描述 :主函数 ******************************************************************************************/ void main() { SP=0x5f; init_lcd(); while(1) { lat_disp(0x00,0x00); //显示点阵 chn_disp(tab1); //整屏显示汉字或字符 con_disp(0xff,0xff,0x8c,0x80,2,16);//反白 delay1(8000); clrram(); //清屏 lat_disp(0xcc,0xcc); //显示点阵 delay1(8000); lat_disp(0x00,0x00); //显示点阵 chn_disp1(tab31); //上半屏显示字符 img_disp1(tab32); //下半屏显示图像 delay1 (8000); clrram(); lat_disp (0xff,0x00); //显示点阵 delay1(8000); img_disp(tab5); //整屏显示图像 delay1(8000); } } |
附字模软件:
你好,我最近在做一个ST7920的驱动,用的是C8051F020,不知道移植代码时候有什么需要注意的么。一直不成功。
路过打酱油~~~~ :zzz
.-= Lxhome的日志 ..Windows7的一些资源及应用(继续跟新中) =-.
.。。看到汇编
.-= 小鬼的日志 ..童年的记忆-多啦A梦大结局 =-.