upsd3300_lcd.lst
来自「增强型8位单片机upsd33xx系列芯片PWM结合ADC例程」· LST 代码 · 共 1,169 行 · 第 1/4 页
LST
1,169 行
267 /*---------------------------------------------------------------------------------------
268 Function:
269 set the display page of master LCD and slave LCD simultaneously,the page range is 0 to 3,make sure the in
-put
270 will not exceed this range ,otherwise it will reach a undecided result.
271 Parameters:
272 page0 is the user expected display page of slave LCD and page1 is that of master LCD.
273 Note:
274 the parameter page0 and page1 is ORed with 0xB0 respectively, the reason is to meet "set page address" co
-mmand
275 requirement of LCD controler SED1520,Please refer to SED1520 series spec .
276
277 ----------------------------------------------------------------------------------------*/
278 void SetPage( unsigned char page0, unsigned char page1 ) //set page
279 {
280 1
281 1 OutSlaveCom ( 0xB8|page0 );
282 1 OutMasterCom( 0xB8|page1);
283 1
284 1 }
285
286 /*---------------------------------------------------------------------------------------
287 Function:
288 set the display column of master LCD and slave LCD simultaneously,the column range is 0 to 61.
289 Parameters:
290 address0 is the user expected display column of slave LCD and address1 is that of master LCD.
291 Note:
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 6
292 the parameter address0 and address1 is ANDed with 0x7f respectively, the reason is to meet "set column ad
-dress" command
293 requirement of LCD controler SED1520,Please refer to SED1520 series spec
294
295 ----------------------------------------------------------------------------------------*/
296
297 void SetAddress( unsigned char address0, unsigned char address1 ) //set column
298 {
299 1
300 1 OutSlaveCom ( address0&0x7F );
301 1 OutMasterCom( address1&0x7F );
302 1
303 1 }
304
305 /*---------------------------------------------------------------------------------------
306 Function:
307 display one byte data to slave LCD.
308 Parameters:
309 ch is the user expected data to disply on slave LCD.
310 Note:
311 none
312
313 ----------------------------------------------------------------------------------------*/
314 void PutChar0 ( unsigned char ch )
315 {
316 1 OutSlaveDat ( ch );
317 1 }
318
319 /*---------------------------------------------------------------------------------------
320 Function:
321 display one byte data to master LCD.
322 Parameters:
323 ch is the user expected data to disply on master LCD.
324 Note:
325 none
326
327 ----------------------------------------------------------------------------------------*/
328 void PutChar1( unsigned char ch )
329 {
330 1 OutMasterDat ( ch );
331 1 }
332
333 /*---------------------------------------------------------------------------------------
334 Function:
335 this function will clear the LCD disply,both slave and master LCD.
336 Parameters:
337 none
338 Note:
339 none
340
341 ----------------------------------------------------------------------------------------*/
342 void lcd_clear ( void ) //clear screen
343 {
344 1 unsigned char i;
345 1 unsigned char page;
346 1 unsigned char orig_buscon;
347 1 orig_buscon = BUSCON; // Save buscon value
348 1 BUSCON |= 0x3C; // Set Xdata Read/Write to max wait states
349 1 for (page = 0;page<4;page++)
350 1 {
351 2 SetPage( page,page );
352 2 SetAddress( 0,0 );
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 7
353 2 for (i=0;i<61;i++)
354 2 {
355 3 PutChar0 ( 0 );
356 3 PutChar1 ( 0 );
357 3 }
358 2 }
359 1 ucol = 0;
360 1 ulayer = 0;
361 1 BUSCON = orig_buscon; // Restore buscon value
362 1 }
363
364
365 /*---------------------------------------------------------------------------------------
366 Function:
367 this function is used to display a Chinese word.
368 Parameters:
369 x0: start column address.
370 layer: if layer = 0,display the first line Chinese word,otherwise display the second line.
371 width: the number of column of a Chinese word dot matrix.
372 bmp: the pointer of the dot matrix data.
373 Note:
374 the LCD can only display two line Chinese word,so page 0 and 1 is to display the first line,page2
375 and page 3 is to display the second line.
376
377 ----------------------------------------------------------------------------------------*/
378 void DrawBmp ( unsigned char x0,bit layer,unsigned char width,unsigned char *bmp)
379 {
380 1 unsigned char x, address;
381 1 unsigned char * dat;
382 1
383 1 unsigned char i=0;
384 1 unsigned char page =0; // if layer = 0;page = 0,so it will disply the first line Chinese word
385 1
386 1 bit window = 0; //display on master LCD
387 1 dat = bmp;
388 1
389 1 if(layer)
390 1 page=2; //if layer >=0;then page = 2, it will disply the second line Chinese word
391 1
392 1 for(x=x0;x<x0+width;x++)
393 1 {
394 2 if(x>121)
395 2 return; //the column exceeded 121 will be ignored
396 2 if (x>60)
397 2 {
398 3 window =1; //disply on slave LCD
399 3 address = x%61;
400 3 }
401 2 else
402 2 address = x; //display on master LCD
403 2
404 2 SetPage (page,page); //disply the upper part of a Chinese word
405 2 SetAddress(address,address);
406 2
407 2 if (window)
408 2 PutChar0(dat[i]);
409 2 else
410 2 PutChar1(dat[i]);
411 2
412 2
413 2 SetPage (page+1,page+1); //disply the lower part of a Chinese word
414 2 SetAddress(address,address);
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 8
415 2
416 2 if (window)
417 2 PutChar0(dat[i+1]);
418 2 else
419 2 PutChar1(dat[i+1]);
420 2
421 2 i+=2;
422 2 }
423 1 }
424
425 #ifdef STlogo_support
void DrawSTlogo (unsigned char *bmp)
{
unsigned char orig_buscon;
orig_buscon = BUSCON; // Save buscon value
BUSCON |= 0x3C; // Set Xdata Read/Write to max wait states
DrawBmp(ucol,ulayer,16,bmp);//display logo here
ucol+=16;
BUSCON = orig_buscon; // Restore buscon value
}
#endif
437
438 #ifdef ENGLISH_CHINESE_FONT
void DrawBmpAsc ( unsigned char x0,unsigned char layer,unsigned char width,unsigned char *bmp)
{
unsigned char x, address;
unsigned char * dat;
unsigned char i=0;
unsigned char page =0; // if layer = 0;page = 0,so it will disply the first line Chinese word
bit window = 0; //display on master LCD
dat = bmp;
if(layer)
page=2; //if layer >=0;then page = 2, it will disply the second line Chinese word
for(x=x0;x<x0+width;x++)
{
if(x>121)
return; //the column exceeded 121 will be ignored
if (x>60)
{
window =1; //disply on slave LCD
address = x%61;
}
else
address = x; //display on master LCD
SetPage (page,page); //disply the upper part of a Chinese word
SetAddress(address,address);
if (window)
PutChar0(dat[i]);
else
PutChar1(dat[i]);
SetPage (page+1,page+1); //disply the lower part of a Chinese word
SetAddress(address,address);
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 9
if (window)
PutChar0(dat[i+1]);
else
PutChar1(dat[i+1]);
i+=2;
}
}
#endif
486
487
488 void disp_one_asc(unsigned char col,unsigned char layer,unsigned char ascii_code,unsigned char mode)
489 {
490 1
491 1 unsigned char i,j;
492 1 unsigned char xdata *ascii;
493 1 extern xdata PSD_REGS PSD_reg;
494 1
495 1 j = PSD_reg.PAGE; // page number will be changed in fetching ASC font data, so reserve page number first
496 1 PSD_reg.PAGE =ENGLISH_FONT_PAGE;
497 1
498 1 ascii = (unsigned char xdata *)(FONT_BASE_ADDRESS);
499 1
500 1 for (i=0;i<14;i++)
501 1 {
502 2 if(mode)
503 2 {
504 3 if(i%2==0)
505 3 {
506 4 dot_buffer[i] = ~ascii[ascii_code*14+i+1];
507 4
508 4 }
509 3 else
510 3 {
511 4 dot_buffer[i] = ~ascii[ascii_code*14+i-1];
512 4 }
513 3 }
514 2 else
515 2 {
516 3 if(i%2==0)
517 3 {
518 4 dot_buffer[i] = ascii[ascii_code*14+i+1];
519 4
520 4 }
521 3 else
522 3 {
523 4 dot_buffer[i] = ascii[ascii_code*14+i-1];
524 4 }
525 3 }
526 2 }
527 1
528 1 DrawBmp(col,layer,7,dot_buffer); //disply the asc code after conversion
529 1 PSD_reg.PAGE = j; //restore page number
530 1 }
531
532 #ifdef ENGLISH_CHINESE_FONT
void disp_one_asc2(unsigned char width,unsigned char length,unsigned char *pic)
{
unsigned long i;
for (i=0;i<width*length;i++)
{
if(mode)
C51 COMPILER V7.50 UPSD3300_LCD 07/11/2005 15:30:33 PAGE 10
{
if(i%2==0)
{
dot_buffer[i] = ~pic[i+1];
}
if(i%2==1)
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?