Shop OBEX P1 Docs P2 Docs Learn Events
How do I use BRANCH to determine what get's sent to an lcd without creating lar — Parallax Forums

How do I use BRANCH to determine what get's sent to an lcd without creating lar

beazleybubbeazleybub Posts: 102
edited 2008-08-20 21:23 in BASIC Stamp
I am trying to use a branch statement to determine what·gets printed on an lcd screen but am having trouble.
How can I acomplish using something similar to below? "I know it's not right but you get the idea."
   English DATA "English"
 
 Spanish DATA "Spanish"
 
 GET 54, Work
 
 BRANCH Work,[noparse][[/noparse]N,E,S]
 
 N:
 E: English:
 S: Spanish:
 
 SEROUT 11, 240, [noparse][[/noparse]"?f?y0    LANGUAGE?y1?x07", [color=green]What Goes Here?[/color] ]
 
 RETURN

Edited to clarify the question.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
How can there be·nothing? Nothing is something!

Post Edited (beazleybub) : 8/18/2008 7:23:18 PM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-08-18 18:46
    Well your question reads, determine what is printed on an LCD screen…but unless your display is parallel, you won’t usually be able to determine that. Of course, you should already know since you are in control of what is being sent, however I still don’t understand the use of DATA statements mixed with a GET instruction. GET will fetch a character from location 54 of the SPRAM into the variable work. Assuming that location contains a character, such as S or E the branch instruction won’t work as you have it. The variable should contain an offset for the position within the list for a label to branch to. If you are trying to do it based on a character then you will first need to use a LOOKDOWN command to find the correct offset prior to your BRANCH command. I hope this helps. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-18 18:48
    In order to do output on strings stored as data in the EEPROM, you have to write a subroutine to take the characters one at a time and send them out the serial port. You supply this routine with the address of the text to be output and usually terminate the text with a zero byte. Something like this:
    dataOut:
     READ addr,c
     addr = addr + 1
     IF c = 0 THEN RETURN
     SEROUT 11,240,[noparse][[/noparse]c]
     GOTO dataOut
    


    Alternatively, you could put most of the SEROUT statement before the BRANCH and, at each label, put a SEROUT with only the language specific words like
    SEROUT 11,240,[noparse][[/noparse]"?f?y0   LANGUAGE?y1?x07"]
     BRANCH Work,[noparse][[/noparse]N,E,S]
    N: SEROUT 11,240,[noparse][[/noparse]"Invalid"] : RETURN
    E: SEROUT 11,240,[noparse][[/noparse]"English"] : RETURN
    S: SEROUT 11,240,[noparse][[/noparse]"Espanol"] : RETURN
    
  • beazleybubbeazleybub Posts: 102
    edited 2008-08-18 19:20
    Chris,

    The I used the data statement because of something I had looked at earlier that shows printing characters one at a time like what Mike has described below. I am not very familiar with using DATA.

    What I am asking is how to send a specific word to the lcd based on the input.

    As it is currently written my subroutine sends out the value of work in the serout to the LCD.
    In my case it would be a "1" or a "2". But I wanted to substitute the "1" with "ENGLISH" and the "2" with "SPANISH".

    I just do not understand how to inject·a text string into the serout statement instead of a decimal number.

    Dsp3:
    
    GET 54, Work
    SEROUT lcd, Baud, [noparse][[/noparse]"?f?y0?x04LANGUAGE?y1?x07",DEC Work]
     
    RETURN
    

    Mike,

    I will try to use your "alternitave" you have suggested if what I am asking for is what you are describing.

    Thank you

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    How can there be·nothing? Nothing is something!
  • beazleybubbeazleybub Posts: 102
    edited 2008-08-18 19:25
    Mike,

    I know I am not the best wordsmith and I also do not understand how you read between the lines with my jumbled question.

    Never less,·thank you very much your suggestion worked perfectly!


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    How can there be·nothing? Nothing is something!
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-18 19:30
    beazleybug,
    You can't "inject" a text string into a serout statement. PBasic doesn't really have text strings except as constants in I/O statements and DATA statements. As far as you're concerned, there are only single characters or small arrays of single characters. That's why you have to use a subroutine like I showed.
  • beazleybubbeazleybub Posts: 102
    edited 2008-08-18 19:53
    Mike,

    I must have used a word that is used in programming or something to get the response you just gave.
    Not ("inject" programming word) but ("inject" place·text there).

    What you had described as a subroutine I basically already knew because I even used something similar in another part of my program.
    IF Language = 1 THEN SEROUT lcd, Baud, [noparse][[/noparse]"?f?y0     PLEASE?y1?x02INSERT MONEY"]
    IF Language = 2 THEN SEROUT lcd, Baud, [noparse][[/noparse]"?f?y0  INTRODUZCA EL  ?y1?x02 DINERO AQUI"]
    

    · And here...
     GET 62, Work
     BRANCH Work,[noparse][[/noparse]null,MenuLevel,ScrollDown,ScrollUp,Set]
    


    I was looking for an alternitave though because I hoped to find a way to cut down on the program size.
    If I used as an example say seven diferent languages the serout statement would be repeated so many times it would gobble up too much program space. I know I could use another subroutine for that but thought maybe that using something like.....

    GET 54, Work
     BRANCH Work,[noparse][[/noparse]N,E,S]
     
     N:
     E: English:
     S: Spanish:
     
     SEROUT 11, 240, [noparse][[/noparse]"?f?y0    LANGUAGE?y1?x07", [color=green]What Goes Here?[/color] ]
    
    


    Would work to save space on the serout commands but was not sure how to accomplish that.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    How can there be·nothing? Nothing is something!
  • Mike GreenMike Green Posts: 23,101
    edited 2008-08-18 20:06
    All I can say is that you need to understand the "dataOut" subroutine that I wrote. It would be called like this
    None DATA "Invalid",0
    English DATA "English",0
    Spanish DATA "Espanol",0
    
    LOOKUP Work,[noparse][[/noparse] None,English,Spanish ],addr
    GOSUB dataOut
    SEROUT 11,240,[noparse][[/noparse] CR ]
    
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-08-20 21:23
    It appears I was unsuccessful at interpreting what you meant and Mike guessed correctly. He has provided you with some working examples but I will add this…since you’re using a two language system my advice would be to optimize your language selection/lookup.

    Some years ago I built a board for a customer which displayed data on a 4X40 LCD. The data had to be displayed in two languages. Due to the number of items that had to be displayed I used a BS2p24 and I assigned SLOT 1 to English selections and SLOT 2 to Spanish selections. This way the lookup subroutine needed only change the slot it was picking data from.

    In your case I don’t know how much data you have, but if you have sufficient room for it and want to simplify lookup then you can always group the English and Spanish words together and then your program can simply add an offset to the English address when Spanish is selected. Of course, this requires the word fields to be the same length (English and Spanish words are often not), but in my case I padded each line of text for formatting anyway, so everything had the same relative offset.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.