Making a menu


Closed Thread
Results 1 to 37 of 37

Thread: Making a menu

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    That's because "start" is a 5 byte string and it will not fit in a byte or word variable. It will fit into a 5 byte array.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    ok well i had text deffined as a word so that will be why then!

    So how do you use a 5 byte array?

    Also the words that im currecntly using will be replaced and could be upo 16 characters long!

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There's always different thought for x problem, if it was me, i would use one of the next approach.

    1. Store Text string in internal or external EEPROM, Text variable would return the start address of your text string. Your string should be terminated by a NULL (or 0), so when you call the Display routine, it just read from the eeprom, show it, go to next character and continue untill it reach the NULL (0).

    2. Almost like the above, but storing text String in the codespace. Something around the following
    http://www.pbpgroup.com/modules/wfse...p?articleid=10 There's quite a few version of it on this forum.
    Last edited by mister_e; - 10th November 2008 at 18:58.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Thanks for that mister_e!

    ok so i have the code as this now:

    '************************************************* ***************
    '* Name : STRINGS.PBP *
    '* Author : Darrel Taylor / John Barrat *
    '* Date : 5/30/2003 *
    '* Note: Strings must be NULL Terminated *
    '************************************************* ***************
    DEFINE LOADER_USED 1 ' If using bootloader
    DEFINE OSC 4
    DEFINE HSER_TXSTA 24h ' Use this for Higher Baud Rates
    DEFINE HSER_SPBRG 25 ' 9600 Baud at 4mhz
    '
    DEFINE LCD_DREG PORTB 'Define PIC port used for LCD Data lines
    DEFINE LCD_DBIT 4 'Define first pin of portb connected to LCD DB4
    DEFINE LCD_RSREG PORTB 'Define PIC port used for RS line of LCD
    DEFINE LCD_RSBIT 3 'Define Portb pin used for RS connection
    DEFINE LCD_EREG PORTB 'Define PIC prot used for E line of LCD
    DEFINE LCD_EBIT 0 'Define PortB pin used for E connection
    DEFINE LCD_BITS 4 'Define the 4 bit communication mode to LCD
    DEFINE LCD_LINES 2 'Define using a 2 line LCD
    DEFINE LCD_COMMANDUS 2000 'Define delay between sending LCD commands
    DEFINE LCD_DATAUS 50 'Define delay time between data sent.

    ' Control Buttons/Lines
    ' ---------------------
    ButStart var Portc.0 ' Take this pin low momentarily to START timing
    ButStop var Portc.1 ' Take this pin low momentarily to STOP timing
    ButReset var Portc.2 ' Take this pin low momentarily to RESET clock
    Butup var portc.3 ' Take this pin low momentarily to increase clock time
    Butdwn var portc.4 ' Take this pin low momentarily to decrease clock time


    Addr var word
    TwoChars var word
    Char var byte

    Clear

    goto StartLoop ' Required

    String1:
    @ da "This is a string",0

    AnotherString:
    @ da "Here is another string",0

    '------------GetAddress Macro - Location insensitive -------------------------
    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


    StartLoop ' This loop repeats continuously just as a test.
    @ GetAddress _String1, _Addr ' Get address of String
    gosub StringOut ' Send the String
    hserout [13,10] ' New Line

    @ GetAddress _AnotherString, _Addr ' Get address of String
    gosub StringOut ' Send the String
    hserout [13,10] ' New Line
    pause 500
    goto StartLoop ' Repeat


    StringOut: ' Send the string out via Hserout
    Readcode Addr, TwoChars ' Get the 14 bit packed characters
    Char = TwoChars >> 7 ' Separate first char
    if Char = 0 then StringDone ' Look for Null char, Stop if found
    hserout [Char] ' Send first char
    Char = TwoChars & $7F ' Separate second char
    if Char = 0 then StringDone ' Look for Null char, Stop if found
    hserout [Char] ' Send the second char
    Addr = Addr + 1 ' Point to next two characters
    goto StringOut ' Continue with rest of the string
    StringDone:
    return

    end
    If somone could point a way to a LCDOUT command to display one of the strings on there it would be greatly appreciated! As i have tried a few ways but due to my lack of understanding fail

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    replacing HSEROUT with LCDOUT should work?

    Which PIC you work with? The above is for 16F
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Oct 2008
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Im using the P16F876A

    i tried


    StartLoop ' This loop repeats continuously just as a test.
    @ GetAddress _String1, _Addr ' Get address of String
    gosub StringOut ' Send the String
    LCDOUT $FE, 1, [13,10] ' New Line

    @ GetAddress _AnotherString, _Addr ' Get address of String
    gosub StringOut ' Send the String
    LCDOUT $FE, 1, [13,10] ' New Line
    pause 500
    goto StartLoop ' Repeat


    but this just gave me a bad expression

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    you don't need those square brackets []
    try something like...
    Code:
    Start
        @ GetAddress _AnotherString, _Addr ' Get address of String
        LCDOUT $FE,1  ' Here you place your LCD cusor where you want
        gosub StringOut ' Send the String
        pause 500
        goto Start ' Repeat
    
    
    StringOut: ' Send the string out via Hserout
        Readcode Addr, TwoChars ' Get the 14 bit packed characters
        Char = TwoChars >> 7 ' Separate first char
        if Char = 0 then StringDone ' Look for Null char, Stop if found
        LCDOUT Char ' Send first char
        Char = TwoChars & $7F ' Separate second char
        if Char = 0 then StringDone ' Look for Null char, Stop if found
        LCDOUT Char ' Send the second char
        Addr = Addr + 1 ' Point to next two characters
        goto StringOut ' Continue with rest of the string
    StringDone:
        return
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. interactive menu with hyperterminal
    By jamied in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 5th January 2009, 11:13
  2. Sending menu to PC from PIC16F876A
    By joseph Degorio in forum Serial
    Replies: 2
    Last Post: - 12th November 2007, 07:03
  3. Interrupt/timer not really interrupting...
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd May 2005, 22:05
  4. Interrupt Menu System Example and Help Needed
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 1st April 2005, 17:05
  5. Lcd Menu
    By eliecer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 19:29

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