Shop OBEX P1 Docs P2 Docs Learn Events
Help with LCD's — Parallax Forums

Help with LCD's

DuctapemasterDuctapemaster Posts: 90
edited 2007-12-29 13:41 in General Discussion
I had a 20x4 LCD (parallel) laying around and this afternoon I was messing with it. I got it to initialize and display whatever cursor I specify and I am able to send data to it and have it display it. However, I want to be able to send a string a data to it instead of sending it character by character. I messed around with lookup tables (just input the string in a table, each character separated by a comma) and it works, but thats a really dumb solution...

So basically I'm asking if there is a way to split a string up into individual characters so I can output one, then move to the next, output it, etc, etc.

Anyone have a solution?

Thanks in advance!

-Dan

Comments

  • David BDavid B Posts: 592
    edited 2007-12-13 15:57
    Here's a way to do this with fixed strings, using assembly.

    What I've been doing is to declare a string so it ends with a zero, like this -

    hello dw 'Hello World! ',0

    To display the string, write its address to the W register, then call the write_string routine -

    mov W, #hello
    call @lcd_write_string

    The write_string routine copies the contents of W to an address pointer, which it then steps along, displaying each individual character until it reaches a zero -

    _lcd_write_string

    bank48 bank_LCD
    mov string, W

    :loop

    bank48 bank_LCD
    mov W,string
    mov M, #0
    iread ; reads value from 11-bit code address in M, W
    test W
    jz @:end
    call @lcd_write_data

    bank48 bank_LCD
    inc string
    jmp @:loop

    :end
    retp

    Does that help?

    David
  • DuctapemasterDuctapemaster Posts: 90
    edited 2007-12-13 22:01
    Heh, I'm an SX/B person (plan on learning more assembly during the Christmas holiday) but I will decipher it. It's pretty simple and I get the overall workings of it, I just need to understand what each individual instruction does.

    Thanks a lot!

    -Dan
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-12-13 22:44
    You can find an example of one possible way to process text strings in the RFID Reader example of the SX/B help file. Look at the LCD_OUT subroutine. The example uses a serial LCD but this should not present a significant problem for you since you already have the basic parallel LCD communication routines working. Just replace the SEROUT statement in the example with whatever you presently use to send a byte to your parallel LCD.

    The example also uses a zero byte to terminate a text string. This is a common practice. If you place the text of the string in quotes SX/B includes the terminating zero byte for you automatically in the generated code.

    - Sparks
  • BeanBean Posts: 8,129
    edited 2007-12-29 13:41
    Assuming you already have an LCD_Char subroutine, do this:



    
    
     
    tempW       VAR WORD
    temp        VAR BYTE
     
    LCD_Char    SUB 1 ' Pass character to print
    LCD_Str     SUB 2 ' Pass string to print
     
    Program Start
     
    Start:
      LCD_Str "Hello there"
      LCD_Str Message1
    END
     
    SUB LCD_Char
      ' What ever code you need here
    ENDSUB
     
    SUB LCD_Str
      tempW = __WPARAM12
      DO
        READINC tempW, temp
        IF temp = 0 THEN EXIT
        LCD_Char temp
      LOOP
    ENDSUB
     
    Message1:
      Data "This is a message", 0  ' Don't forget the zero at the end
     
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
Sign In or Register to comment.