Announcement

Collapse
No announcement yet.

scrolling 1 x 16 lcd output

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • scrolling 1 x 16 lcd output

    i have included the code that i use when i need to output strings larger that 16 characters to a 1 line x 16 character display..... please note that the displays i use treat the 1 kine as 2 8 character lines. this is common for the standard controllers.

    i'm sure there are more elegant ways of doing this but it works for me.

    As i commented in the code, if using DT interrupts you don't need to create the macro.


    'lcd routine to send more than 16 characters to a 1 line x 16 character display.
    'MOST 1 x 16 character line DISPALYS ARE TREATED AS 2 - 1 x 8 character LINES.

    '************ THIS MACRO GETS THE ADDRESS OF THE STRING AND PASSES THAT ADDRESS TO THE WORD VARIABLE
    '************ THIS IS NOT NEEDED IF YOU ARE INCLUDING DT_INTS-18.BAS, AS THE MACRO IS ALREADY IN THE INCLUDE FILE AND SHOULD NOT BE USED!
    ASM
    GETADDRESS macro Label, W
    CHK?RP W
    movlw low Label
    movwf W
    movlw High Label
    movwf W + 1
    endm
    ENDASM
    '*********** END MACRO




    I CON 254 'ATTENTION COMMAND FOR DISPLAY (LCD)
    CLRLCD CON 1 'CLEAR COMMAND FOR LCD
    HOME CON 2 'CURSOR HOME COMMAND FOR LCD
    SHIFT CON 24 'SHIFT LEFT COMMAND FOR LCD
    PRN_AT CON 128 'FIRST START LOCATION ON LCD
    PRN_AT2 CON 192 'SECOND START LOCATION ON LCD

    JJ VAR BYTE
    LL VAR BYTE
    KK VAR BYTE
    STRING_ADD VAR WORD
    CHAR VAR BYTE

    STRING1:
    @ da "put whatever you want here up to 40 characters",0

    STRING2:
    @ da "put whatever you want here up to 40 characters",0

    ETC, ETC, ETC.



    '************************************ MAIN CODE *****************************************
    main:

    @ GETADDRESS _STRING1, _STRING_ADD 'this will get the address of string1 and place in variable string_add
    GOSUB STRINGOUT 'THE CALL TO THIS SUB WILL OUTPUT THE STRING TO THE LCD DISPLAY


    @ GETADDRESS _STRING2, _STRING_ADD 'this will get the address of string2 and place in variable string_add
    GOSUB STRINGOUT 'THE CALL TO THIS SUB WILL OUTPUT THE STRING TO THE LCD DISPLAY


    goto main
    '******************************** END MAIN CODE *******************************



    '******************************* STRINGOUT SUB-ROUTINE ************************
    STRINGOUT: 'sub-routine to output the string to the display
    JJ = 0: KK = 0: LL = 0
    LCDOUT I,CLRLCD
    STRINGOUT2:
    READCODE STRING_ADD + LL, CHAR
    IF CHAR = 0 THEN
    PAUSE 2000
    LCDOUT I,HOME 'RETURN LCD CURSOR TO HOME POSITION
    RETURN
    ENDIF
    IF LL < 8 THEN
    LCDOUT I,PRN_AT+JJ,CHAR
    JJ = JJ + 1
    ELSE
    LCDOUT I,PRN_AT+JJ,CHAR
    LCDOUT I,PRN_AT2+KK,CHAR
    JJ = (JJ + 1)//40
    KK = (KK + 1)//40
    ENDIF
    LL = LL + 1
    IF LL = 16 THEN
    PAUSE 450 'FIRST 16 CHARACTERS GO OUT FAST, THEN THERE IS A 450 mS PAUSE THEN THE REST IS SCROLLED OUT
    ELSEIF LL > 16 THEN 'AT 220 mS INTERVALS.
    LCDOUT I,SHIFT 'THIS SHIFTS THE DISPLAY LEFT 1 CHARACTER
    PAUSE 220
    ENDIF
    GOTO STRINGOUT2
    RETURN
Working...
X