📄 dog_glcd.lst
字号:
288 + DESCRIPTION: it writes one character INVERTED to the next position
289 +
290 + INPUT: ch - the character needs to be writen
291 +
292 + RETURN: None
293 +
294 + NOTES: if the position is invalid (the line is full) it writes
295 + the character from the begining of the line.
296 + The function increments the CurrentChPos variable!
297 + If the character invalid, it prints a space char.
298 +
299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
300 void LcdPutInvCh(uint8 ch)
301 {
302 1 uint8 column, data_out, temp8;
C51 COMPILER V8.00 DOG_GLCD 11/17/2008 10:50:29 PAGE 6
303 1
304 1 if( (ch > ASCII_5X7_MAX) || (ch < ASCII_5X7_MIN) )
305 1 {
306 2 data_out = ' ';
307 2 }
308 1 else
309 1 {
310 2 data_out = ch;
311 2 }
312 1
313 1 //write character
314 1 LCD_A0_PIN = 1; //set A0 to 1 -> access to the DDRAM
315 1 LCD_NSEL_PIN = 0;
316 1 for(column=0;column<5;column++)
317 1 {
318 2 //write column data
319 2 temp8 = ascii_table5x7[data_out - ASCII_5X7_MIN][column];
320 2 temp8 ^= 0xFF;
321 2 temp8 &= 0x7F;
322 2 SpiWrite( temp8 );
323 2 }
324 1 //space between the characters
325 1 SpiWrite(0x7F);
326 1 LCD_A0_PIN = 0;
327 1 LCD_NSEL_PIN = 1;
328 1 if( ++CurrentChPos > LCD_MAX_CHAR )
329 1 {//end of the line -> set cursor to the beginning of the line
330 2 CurrentChPos = 1;
331 2 LcdSetColumn( 1 );
332 2 }
333 1 }
334
335 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
336 +
337 + FUNCTION NAME: void LcdPutChar(uint8 line, uint8 ch_pos, uint8 ch)
338 +
339 + DESCRIPTION: it writes one character to the next position
340 +
341 + INPUT: ch - the character needs to be writen
342 +
343 + RETURN: None
344 +
345 + NOTES: if the position is invalid (the line is full) it writes
346 + the character from the begining of the line.
347 + The function increments the CurrentChPos variable!
348 + If the character invalid, it prints a space char.
349 +
350 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
351 void LcdPutCh(uint8 ch)
352 {
353 1 uint8 column, data_out;
354 1
355 1 if( (ch > ASCII_5X7_MAX) || (ch < ASCII_5X7_MIN) )
356 1 {
357 2 data_out = ' ';
358 2 }
359 1 else
360 1 {
361 2 data_out = ch;
362 2 }
363 1
364 1 //write character
C51 COMPILER V8.00 DOG_GLCD 11/17/2008 10:50:29 PAGE 7
365 1 LCD_A0_PIN = 1; //set A0 to 1 -> access to the DDRAM
366 1 LCD_NSEL_PIN = 0;
367 1 for(column=0;column<5;column++)
368 1 {
369 2 //write column data
370 2 SpiWrite(ascii_table5x7[data_out - ASCII_5X7_MIN][column]);
371 2 }
372 1 //space between the characters
373 1 SpiWrite(0);
374 1 LCD_A0_PIN = 0;
375 1 LCD_NSEL_PIN = 1;
376 1 if( ++CurrentChPos > LCD_MAX_CHAR )
377 1 {//end of the line -> set cursor to the beginning of the line
378 2 CurrentChPos = 1;
379 2 LcdSetColumn( 1 );
380 2 }
381 1 }
382
383 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
384 +
385 + FUNCTION NAME: void LcdPutChar(uint8 line, uint8 ch_pos, uint8 ch)
386 +
387 + DESCRIPTION: it write one character to the requested position
388 +
389 + INPUT: line - number of the line (1...8
390 + the LCD is divided to 8 lines
391 + line1 is the top line
392 + ch_pos - character position
393 + up to 21 character (1...21) could be in a line
394 + character 1 is the first on left hand side
395 + ch - the character needs to be writen
396 +
397 + RETURN: None
398 +
399 + NOTES: If the position is invalid, the function returns without
400 + changing the registers.
401 + The function sets the CurrentLine, CurrentChPos variables!
402 +
403 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
404 void LcdPutChar(uint8 line, uint8 ch_pos, uint8 ch)
405 {
406 1 if( LcdSetCharCursor(line, ch_pos) == FALSE )
407 1 {
408 2 return;
409 2 }
410 1 LcdPutCh(ch);
411 1 }
412
413 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
414 +
415 + FUNCTION NAME: void LcdWriteLine(uint8 line, uint8 * text)
416 +
417 + DESCRIPTION: it writes one complete line
418 +
419 + INPUT: line - number of the line (1...8
420 + the LCD is divided to 8 lines
421 + line1 is the top line
422 + text - address of the string needs to be written
423 +
424 + RETURN: None
425 +
426 + NOTES: If the line is invalid, the function returns without any changes.
C51 COMPILER V8.00 DOG_GLCD 11/17/2008 10:50:29 PAGE 8
427 + The function doesn't set the CurrentLine, CurrentChPos variables!
428 +
429 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
430 void LcdWriteLine(uint8 line, uint8 * text)
431 {
432 1 uint8 i,column,temp8;
433 1
434 1 if( (line < LCD_MIN_LINE) || (line > LCD_MAX_LINE) )
435 1 {
436 2 return;
437 2 }
438 1 //set page address
439 1 LcdSetPage( line-1 );
440 1 //set column address
441 1 LcdSetColumn( 0 );
442 1 for(i=0;i<21;i++)
443 1 {
444 2 if( (text[i] > ASCII_5X7_MAX) || (text[i] < ASCII_5X7_MIN) )
445 2 {
446 3 temp8 = ' ';
447 3 }
448 2 else
449 2 {
450 3 temp8 = text[i];
451 3 }
452 2
453 2 ;
454 2 //write character
455 2 LCD_A0_PIN = 1; //set A0 to 1 -> access to the DDRAM
456 2 LCD_NSEL_PIN = 0;
457 2 for(column=0;column<5;column++)
458 2 {
459 3 //write column data
460 3 SpiWrite(ascii_table5x7[temp8 - ASCII_5X7_MIN][column]);
461 3 }
462 2 //space between the characters
463 2 SpiWrite(0);
464 2 LCD_A0_PIN = 0;
465 2 LCD_NSEL_PIN = 1;
466 2 }
467 1 }
468
469 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
470 +
471 + FUNCTION NAME: uint8 LcdSetPictureCursor(uint8 page, uint8 column)
472 +
473 + DESCRIPTION: it sets the character position
474 +
475 + INPUT: page - number of the pages (1...8
476 + the LCD is divided to 8 pages
477 + page1 is the top page
478 + column - number of start column
479 + column1 is the left one
480 +
481 + RETURN: TRUE - operation was successfull
482 + FALSE - operation was ignored
483 +
484 + NOTES: If the position is invalid, the function returns without
485 + changing the registers.
486 + The function sets the CurrentLine, CurrentChPos variables!
487 +
488 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
C51 COMPILER V8.00 DOG_GLCD 11/17/2008 10:50:29 PAGE 9
489 uint8 LcdSetPictureCursor(uint8 page, uint8 column)
490 {
491 1 //check whether the input parameters are correct or not
492 1 if( ((page < LCD_MIN_LINE) || (page > LCD_MAX_LINE)) || ((column < LCD_MIN_COLUMN) || (column > LCD_MAX_C
-OLUMN)) )
493 1 {
494 2 return FALSE;
495 2 }
496 1
497 1 //set page address
498 1 LcdSetPage(page-1);
499 1 //set column address
500 1 LcdSetColumn( column-1 );
501 1 CurrentPage = page;
502 1 CurrentColumn = column;
503 1
504 1 return TRUE;
505 1 }
506
507 /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
508 +
509 + FUNCTION NAME: void LcdDrawPicture(const uint8 * picture)
510 +
511 + DESCRIPTION: it draw a picture
512 +
513 + INPUT: picture - address of the picture (must be stored in the
514 + FLASH
515 +
516 + RETURN: None
517 +
518 + NOTES: The uint8 LcdSetPictureCursor(uint8 page, uint8 column) function
519 + has to be called before calling this function!
520 + The function changes the CurrentPage and CurrentColumn variables!
521 +
522 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
523 void LcdDrawPicture(const * picture)
524 {
525 1 uint8 p,pages,page,i,col;
526 1 uint16 j;
527 1
528 1 p = picture[LCD_PIC_PAGE_NMBR];
529 1 //check wheter there are enough column for the picture or not
530 1 if( (LCD_MAX_COLUMN - CurrentColumn + 1) < picture[LCD_PIC_COLUMN_NMBR] )
531 1 {//there are not enough space for the pic -> limit to the available space
532 2 col = (LCD_MAX_COLUMN - CurrentColumn + 1);
533 2 }
534 1 else
535 1 {
536 2 col = picture[LCD_PIC_COLUMN_NMBR];
537 2 }
538 1 //check wheter there are enough pages for the picture or not
539 1 if( (LCD_MAX_LINE - CurrentPage + 1) < picture[LCD_PIC_PAGE_NMBR] )
540 1 {
541 2 page = (LCD_MAX_LINE - CurrentPage + 1);
542 2 }
543 1 else
544 1 {
545 2 page = picture[LCD_PIC_PAGE_NMBR];
546 2 }
547 1
548 1 //draw the picture
549 1 for(pages=0;pages<page;pages++)
C51 COMPILER V8.00 DOG_GLCD 11/17/2008 10:50:29 PAGE 10
550 1 {
551 2 LCD_A0_PIN = 1; //set A0 to 1 -> access to the DDRAM
552 2 LCD_NSEL_PIN = 0;
553 2 j = LCD_PIC_ADDRESS_OFFSET + pages;
554 2 for(i=0;i<col;i++)
555 2 {
556 3 //write column data
557 3 SpiWrite( picture[j] );
558 3 j += p;
559 3 }
560 2 LCD_A0_PIN = 0;
561 2 LCD_NSEL_PIN = 1;
562 2 //set next page
563 2 LcdSetPictureCursor( ++CurrentPage,CurrentColumn );
564 2 }
565 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 933 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 31
IDATA SIZE = 26 ----
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 + -