Displaying strings from codespace.


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323

    Default Displaying strings from codespace.

    Well, the "strings in codespace" question seems to come up often enough, but my search still didn't come up with an answer that I like.

    What I want is to store several strings in codespace (not EEPROM) and pull different ones up for display depending on the contents of a variable.

    This is a pseudocode equivalent of what I WANT, but I don't know how to make it work in "real life"...

    Code:
    daynumber      var	        byte
    weekday		var		byte[9]
    
    
    If daynumber = 0 then weekday = "  SUNDAY "
    If daynumber = 1 then weekday = "  MONDAY "
    If daynumber = 2 then weekday = " TUESDAY "
    If daynumber = 3 then weekday = "WEDNESDAY"
    
    LCDOUT $fe, 1, STR weekday\9
    Is there a clever way to do this?

    HELP! (please!)


    steve

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default

    This is how I do it for my seven segment displays.

    Code:
    msg_LoBatt:
      PokeCode  Cblank,$13,$15,$1b,$0B,$0a,$18,$18
    msg_Func:
      PokeCode  Cblank,Cblank,Cblank,Cblank,$0f,$19,$14,$0c
    
    '- thanks to Darrell Taylor @ picbasic forum -- Hi Darell ;)
    ASM
    GetAddress macro Label, Wout       ; Returns the Address of a Label as a Word
        CHK?RP Wout
        movlw low Label
        movwf Wout
        movlw High Label
        movwf Wout + 1
        endm
    ENDASM
    
    
    ShowMsgLoBatt:
    @ GetAddress  _msg_LoBatt, _Address
      goto  Disp_msg
    ShowMsgFunc:
    @ GetAddress  _msg_Func, _Address
      goto  Disp_msg
    
    ' Display a message from the Address specified
    Disp_msg:
      for gR[1] = 0 to 7
        peekcode Address, gr[0]
        DispBuf[gR[1]] = gR[0]
        Address = Address+1
      next
      return
    What it does is to load the starting address of the string, and Disp_msg displays the string.

    Gr[0] and Gr[1] are general use registers byte wide
    DispBuf is a buffer for the seven segment codes that go to the display

    This will not directly work like you want it to, but it is close

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Do you have PBP2.60? If so this should do it, I think:

    Code:
    daynumber      var	        byte
    weekday		var		byte[9]
    
    If daynumber = 0 then Arraywrite weekday, ["  SUNDAY "]
    If daynumber = 1 then Arraywrite weekday, ["  MONDAY "]
    If daynumber = 2 then Arraywrite weekday, [" TUESDAY "]
    If daynumber = 3 then Arraywrite weekday, ["WEDNESDAY"]
    
    LCDOUT $fe, 1, STR weekday\9
    /Henrik.

  4. #4
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Henrik! Thank you! That did the trick.

    So... uhhh.... where the heck did this "Arraywrite" come from?
    I don't see any mention of it in the PBP 2.60 manual, not is it in the "Help" file...
    And it doesn't even capitalize itself & "go bold" when I type it.

    Is there a list somewhere of the new "features" in PBP 2.60?
    Clearly the manual doesn't tell the whole story.


    Jerson,
    Thanks for your example. I found some similar ASM code while I was searching, but most of the threads were years old and I was hoping there was an easier way. It looks like ARRAYWRITE will do it for me.

    Thanks!


    steve

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,
    It's definitely covered in the printed manual that came with my 2.60 upgrade. It's not in the help-files for MicroCodeStudio because they are not updated by the authour of the software (Mecanique) and that is also why it doesn't "go bold" in MCS.

    Have a another look in the manual, it should be there, together with it's companion ArrayRead.

    /Henrik.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    You guys have probably already figured this out, but using ArrayWrite is the best way to send messages out multiple ports. I have many occasions where I need to send the same messages out of whatever port is available - HSEROUT, HSEROUT2, or SEROUT2. This, combined with STR can get the job done.
    Charles Linquist

  7. #7
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson View Post
    It's definitely covered in the printed manual that came with my 2.60 upgrade. It's not in the help-files for MicroCodeStudio because they are not updated by the authour of the software (Mecanique) and that is also why it doesn't "go bold" in MCS.

    Have a another look in the manual, it should be there, together with it's companion ArrayRead.
    Groan... if only I could get both my brain cells to work together....

    Here it is in this OTHER manual that says "2.60" on it.


    steve

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts