📄 lcd.lst
字号:
229 1 }
230
231 void LCD_puts(unsigned char * buf)
232 {
233 1 while(*buf)
234 1 {
235 2 if(*buf > 0x80)
236 2 {
237 3 put_hz(*(unsigned int *)buf);
238 3 buf += 2;
239 3 }
240 2 else
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 5
241 2 {
242 3 put_asc(*buf);
243 3 buf ++;
244 3 }
245 2 }
246 1 }
247 void LCD_puts_rev(unsigned char * buf)
248 {
249 1 reverse = 0xFF;
250 1 while(*buf)
251 1 {
252 2 if(*buf > 0x80)
253 2 {
254 3 put_hz(*(unsigned int *)buf);
255 3 buf += 2;
256 3 }
257 2 else
258 2 {
259 3 put_asc(*buf);
260 3 buf ++;
261 3 }
262 2 }
263 1
264 1 reverse = 0x00;
265 1 }
266
267 void LCD_putn(unsigned char * buf,unsigned char n)
268 {
269 1 while((*buf != '\0') && (n > 0))
270 1 {
271 2 if(*buf > 0x80)
272 2 {
273 3 put_hz(*(unsigned int *)buf);
274 3 buf += 2;
275 3 }
276 2 else
277 2 {
278 3 put_asc(*buf);
279 3 buf ++;
280 3 }
281 2 n--;
282 2 }
283 1 }
284
285
286
287 static void put_asc(unsigned char ch)
288 {
289 1 unsigned char i;
290 1 unsigned char font_dat[LCD_FONT_WIDTH << 1];
291 1
292 1 DF_rd(LCD_FONT_ASC_BASE + (ch - 0x20) * (LCD_FONT_WIDTH << 1),font_dat,LCD_FONT_WIDTH << 1);
293 1
294 1 if(ch == '\n') nxt_line();
295 1 else
296 1 {
297 2 if(cur_y == 64)
298 2 {
299 3 cur_ic = LCD_IC2;
300 3 set_pg_addr(cur_x,cur_ic);
301 3 set_y_addr(cur_y & 0xBF,cur_ic);
302 3 }
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 6
303 2 else if(cur_y == LCD_Y_DISP_STP_PIX)
304 2 nxt_line();
305 2
306 2 for(i = 0;i < LCD_FONT_WIDTH;i ++)
307 2 {
308 3 wr_dat(font_dat[i] ^ reverse,cur_ic);
309 3 cur_y ++;
310 3 }
311 2
312 2 cur_y -= LCD_FONT_WIDTH;
313 2 set_pg_addr(cur_x + 1,cur_ic);
314 2 set_y_addr(cur_y & 0xBF,cur_ic);
315 2
316 2 for(i = LCD_FONT_WIDTH;i < (LCD_FONT_WIDTH << 1);i ++)
317 2 {
318 3 wr_dat(font_dat[i] ^ reverse,cur_ic);
319 3 cur_y ++;
320 3 }
321 2
322 2 set_pg_addr(cur_x,cur_ic);
323 2 }
324 1 }
325
326 static void put_asc_rev(unsigned char ch)
327 {
328 1 reverse = 0xFF;
329 1 put_asc(ch);
330 1 reverse = 0x00;
331 1 }
332
333 static void put_hz(unsigned int indx)
334 {
335 1 unsigned char i;
336 1 unsigned char font_dat[LCD_FONT_WIDTH << 2];
337 1 unsigned long addr;
338 1
339 1 indx -= 0xB0A1;
340 1 addr = LCD_FONT_HZ_BASE + (unsigned long)((indx >> 8)*94 + (unsigned char)indx)* (LCD_FONT_WIDTH << 2);
341 1
342 1 DF_rd(addr,font_dat,sizeof(font_dat));
343 1 if(cur_y > (LCD_Y_DISP_STP_PIX - (LCD_FONT_WIDTH << 1))) nxt_line();
344 1
345 1 for(i = 0;i < 12;i ++)
346 1 {
347 2 wr_dat(font_dat[i] ^ reverse,cur_ic);
348 2 cur_y ++;
349 2 if(cur_y == 64)
350 2 {
351 3 cur_ic = LCD_IC2;
352 3 set_pg_addr(cur_x,cur_ic);
353 3 set_y_addr(0,cur_ic);
354 3 }
355 2 }
356 1
357 1 cur_y -= (LCD_FONT_WIDTH << 1);
358 1 cur_ic = cur_y >> 6;
359 1 set_pg_addr(cur_x + 1,cur_ic);
360 1 set_y_addr(cur_y & 0xBF,cur_ic);
361 1
362 1 for(i = 12;i < 24;i ++)
363 1 {
364 2 wr_dat(font_dat[i] ^ reverse,cur_ic);
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 7
365 2 cur_y ++;
366 2 if(cur_y == 64)
367 2 {
368 3 cur_ic = LCD_IC2;
369 3 set_pg_addr(cur_x + 1,cur_ic);
370 3 set_y_addr(0,cur_ic);
371 3 }
372 2 }
373 1
374 1 set_pg_addr(cur_x,cur_ic);
375 1 }
376
377 static void put_hz_rev(unsigned int indx)
378 {
379 1 reverse = 0xFF;
380 1 put_hz_rev(indx);
381 1 reverse = 0x00;
382 1 }
383
384 /*
385 ********************************************************************************
386 *
387 * INTERNAL STATIC FUNCTION
388 *
389 ********************************************************************************
390 */
391 /*
392 ********************************************************************************
393 * Function Name : LCD_set_disp
394 * Description : set LCD display status
395 * Parameter : stat, bit type, specify whether display DDRAM data on LCD.
396 * can be set ON or OFF, other value is not permitted.
397 * cs, bit type, sepecify which chip is to set.
398 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
399 * Return : none
400 ********************************************************************************
401 */
402 void set_disp(bit stat,bit cs)
403 {
404 1 wr_inst(0x3E | stat,cs);
405 1 }
406
407 /*
408 ********************************************************************************
409 * Function Name : LCD_set_sta_line
410 * Description : set LCD display start line
411 * Parameter : num_of_line, unsigned char type, range from 0 to 63, specify
412 * which line start to display.
413 * cs, bit type, sepecify which chip is to set.
414 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
415 * Return : none
416 ********************************************************************************
417 */
418 static void set_sta_line(unsigned char num_of_line,bit cs)
419 {
420 1 wr_inst(0xC0 + num_of_line,cs);
421 1 }
422
423 /*
424 ********************************************************************************
425 * Function Name : LCD_set_pg_addr
426 * Description : set LCD page address
C51 COMPILER V8.02 LCD 05/08/2008 13:16:16 PAGE 8
427 * Parameter : pg_addr, unsigned char type, range from 0 to 7, specify the
428 * page address.
429 * cs, bit type, sepecify which chip is to set.
430 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
431 * Return : none
432 ********************************************************************************
433 */
434 static void set_pg_addr(unsigned char pg_addr,bit cs)
435 {
436 1 wr_inst(0xB8 + pg_addr,cs);
437 1 }
438
439 /*
440 ********************************************************************************
441 * Function Name : set_y_addr
442 * Description : set LCD column address
443 * Parameter : y_addr, unsigned char type, range from 0 to 63, specify the
444 * Y address.
445 * cs, bit type, sepecify which chip is to set.
446 * can be set LCD_IC1 or LCD_IC2, other value is not permitted.
447 * Return : none
448 ********************************************************************************
449 */
450 static void set_y_addr(unsigned char y_addr,bit cs)
451 {
452 1 wr_inst(0x40 + y_addr,cs);
453 1 }
454
455 /*
456 ********************************************************************************
457 * Function Name : nxt_line
458 * Description : set cursor to next line
459 * Parameter : none
460 * Return : none
461 ********************************************************************************
462 */
463 static void nxt_line(void)
464 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -