Shop OBEX P1 Docs P2 Docs Learn Events
Recieving a string via serial and display it via graphics.spin — Parallax Forums

Recieving a string via serial and display it via graphics.spin

propwellpropwell Posts: 87
edited 2009-12-05 17:21 in Propeller 1
Hi together,

i've got some serious problems with programming my propeller:
I've got an ATMega-Microcontoller communicating with my prop, and i want to send a message via printf("Hello World"); from the ATMega to the propeller.
The Propeller should read the message, save it in an array or string, and finally display it via the graphics.spin!

Unfortunately, i don't have any clue how to deal with strings etc.!

Is there a function how to convert a byte-variable into a string?

Please, could anyone help me?

Thank you,

propwell

Post Edited (propwell) : 12/5/2009 1:47:25 PM GMT

Comments

  • propwellpropwell Posts: 87
    edited 2009-12-05 15:30
    hm, i tried several things, i'm now at that point:
    i don't have to use an array, an byte-Variable works.

    msg:=STRING("Hello World!")  
    gr.colorwidth(1, 0)
        gr.textmode(2,2,5,0)
        gr.colorwidth(2, 4)
        gr.text(-105, 55,msg) 
    
    


    that example works just fine. But now, i want to replace the static text with a text, transmitted via SerialMirror.spin and the printf/putchar-functions of the ATMega-Controller.

    The Code in the ATMega:
    printf("Hello World!");
    
    



    in the propeller, it should work anyhow like this:
    msg:=sm.rxtime(20)
    gr.colorwidth(1, 0)
        gr.textmode(2,2,5,0)
        gr.colorwidth(2, 4)
        gr.text(-105, 55,msg) 
    
    


    Unfortunately, there are just some stupid signs appearing on the screen, which have nothing to do with the text i transmitted.
    I think it has something to do with the conversion to a string!
    Can anyone help me? the string() function doesn't work with a variable as an argument.

    Thank you very much,

    propwell
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-12-05 15:44
    You may want to switch to the Extended Full Duplex Serial object which is a
    bit more suited toward what you want to do.

    obex.parallax.com/objects/31/

    Your current code is receiving "bytes" not strings and is likely part of the
    problem you are running into. Also that graphics driver isn't exactly
    suited for much more than simple text display. If you want the text
    to scroll, etc you want to move to a "text" driver.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • propwellpropwell Posts: 87
    edited 2009-12-05 15:48
    thank you very much for your answer! Do you have an example for a text driver?
    Isn't there a way to convert bytes to a string? I'll have a try with the Extenden FDSD, but as i've seen, it is just able to handle 15 characters, 20-30 would be my dream.
  • propwellpropwell Posts: 87
    edited 2009-12-05 16:26
    hm a question to the rxstr-function! How do i have to call it?
    esx.rxstr(@msg)  
    
    


    like this? i can't get anything to display with that!
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-05 17:21
    A typical text driver is "tv_text.spin" which is included with the Propeller Tool and provides for a 40 x 13 TV display.

    Note that it's possible (easy) to modify the extended full duplex serial object to handle any given size string. Just change the internal buffer (datain) to a larger one and modify the limits (15 / 16) in the code to whatever you want. I'm surprised that the limit wasn't coded in as a named constant so it could be changed with a recompilation, but it's easy enough to change.
Sign In or Register to comment.