Shop OBEX P1 Docs P2 Docs Learn Events
Graphics OBJect to print values of variable? — Parallax Forums

Graphics OBJect to print values of variable?

HarleyHarley Posts: 997
edited 2010-08-20 18:50 in Propeller 1
I'm using a copy of PTP Paint which uses Chip's Graphic object. Paint has PrintStr(...), dec(...), hex(...) which allows one to display strings and values of variables. The font is rather large; can only get 20 characters across a 320 pixel (20 tiles) LCD screen.

Graphic object has all things 'graphic' plus displaying zero-terminated strings in a much smaller font; it has it's own font table for all normal ASCII characters plus three special ones (delta, omega and bullet). With this font, one can display at least 53 characters across the same LCD. However, I find NO ability to display values with Graphic object. Is this an exercise which Chip left up to the 'student'? Or do I just not recognize how to display values in the smaller font.

With a magnifying glass, it appears to be 5 x 11 pixel font with a 3 pixel decender. Being a vector font I'd otherwise not be able to know how many pixels were generated.

If one wrote a dec(...) and hex(...) routine to make use of this font, would it have to be placed in Graphic object? Else I'd not know how to reference the font table in Graphic.

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-08-19 15:03
    Harley,

    Check out the Simple_Numbers object located in the install directory of the Propeller IDE (or the attachment I have provided)
  • HarleyHarley Posts: 997
    edited 2010-08-19 19:01
    Thanks Beau,

    I'll try that tomorrow. It's already downloaded and ready to use. Now to look it over and figure out what I need to add to make use of it.
  • HarleyHarley Posts: 997
    edited 2010-08-19 22:35
    Beau,

    I'm a bit confused with Simple_Numbers (SN). It appears that it takes a call to, say SN.dec(value), and then a gr.text(x,y,@nstr) to print the decimal result. Is that correct?

    If so, a bit awkward. Else, I don't see how it ever gets displayed on-screen. I didn't see an example in Simple_Numbers to illustrate HOW to use it.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-08-20 06:19
    Harley,

    You are essentially correct, but you can combine the terms into one line like this...
    gr.text(x,y,SN.dec(value))
    

    Since the Simple_Numbers object is separate from the Graphics object and outside of your main object you have to do it this way.


    EDIT


    Alternatively to 'clean things up' aesthetically in your main object you could add another PUB that looks like this ...
    PUB dec(x,y,value)
        gr.text(x,y,SN.dec(value))
        gr.finish
    

    ... This way when you call your routine from your main object it would look like this ...
    dec(x,y,value)
    


    ...So there are several different ways that you can wrap and modify a particular function to fit your needs.

    See the attached example code below
  • HarleyHarley Posts: 997
    edited 2010-08-20 10:03
    Got it, Beau.

    That clarified things well. And the Minimized Numbers demo was nicely clear as to other details. Thanks so much for having the time to comment on this.

    Unfortunately, things seem to ADD to the code, as I was hoping to minimize it all to also have access to a SD card for logging some captured info. Not sure how to implement SD unless there is a way to swap in and out of RAM some of the code. Presently don't even have enough space for ViewPort, let alone SD. More 'head scratching' to do.
  • HarleyHarley Posts: 997
    edited 2010-08-20 17:06
    Beau, A photo to show Simple-Numbers has been incorporated and is working. No major problems, except for the programmer's 'typos'.

    When the cursors are just barely apart the orange-red background, text and values are displayed; else they are not. I'd planned on that background being black, but to get things working and displayable I tried the other two colors and this was where I left it for now. The A/D input isn't yet filtered, just raw (1-, 2-, 4-, 8-R values) on the D/A output; need larger C than I have on hand.

    A project can really be fun when a display of some sort is part of the design. And with a battery box, goes anywhere. (The LCD is still too bright for the digital camera; gotta crank it down lots more I note.)
    640 x 480 - 39K
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2010-08-20 18:50
    Harley,

    Glad that you are getting this working!

    here is a link to something that I just posted that you might be interested in ...

    http://forums.parallax.com/showthread.php?p=932953#post932953
Sign In or Register to comment.