Shop OBEX P1 Docs P2 Docs Learn Events
Graphics.spin annoyance — Parallax Forums

Graphics.spin annoyance

HarleyHarley Posts: 997
edited 2010-07-13 20:29 in Propeller 1
I'm using Chip Gracey's Graphics Driver v1.0 and when printing to a LCD screen.

When a previously larger decimal value is displayed, and then later a shorter value is posted, the right most digits are not cleared. Thus a value, say, of 'value=1234' is displayed and then the value becomes smaller and smaller, say '9', the 'value=9xxx' is displayed, where the 'xxx' is the last previously posted numbers shown. Very confusing trying to decipher actual value.

Is there a way to overwrite with spaces or something to remove previous larger number of digits? I wish there were something for decimal similar to hex, where you specify how many digits to display.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-07-13 18:54
    Harley said...
    Is there a way to overwrite with spaces or something ... ?
    Yes, by overwriting with spaces. Just send enough spaces after the decimal number each time you send it to accommodate the maximum difference in decimal number lengths.

    -Phil

    Addendum: Or you could adapt my decn routine, which right-justifies the number in a fixed-width field:

    [b]PUB[/b] decn(value, digits) | mindigits, val
    
    '' Print a decimal number, right-justified in a field width given by digits.
    
      mindigits := ((value < 0) & 1) + 1
      [b]if[/b] (value <> $8000_0000)
        val := || value
        [b]repeat[/b] [b]while[/b] (val /= 10)
          mindigits++
      [b]if[/b] (value < 0 [b]and[/b] digits < 0)
        out("-")
        value := ||value
      [b]repeat[/b] (||digits - mindigits) #> 0
        [b]if[/b] (digits < 0) 
          out("0")
        [b]else[/b]
          out(" ")
      dec(value) 
    
    
    



    -P.
  • RaymanRayman Posts: 14,889
    edited 2010-07-13 19:26
    I think "numbers.spin" and/or "simple_numbers.spin" can give you fixed width strings from numbers...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Apps:· http://www.rayslogic.com/propeller/Programming/Programming.htm

    My Prop Info: ·http://www.rayslogic.com/propeller/propeller.htm
    My Prop Products:· http://www.rayslogic.com/Propeller/Products/Products.htm
  • HarleyHarley Posts: 997
    edited 2010-07-13 20:29
    Thanks for the comments.

    Phil, looks like I could temporarily add your routine. The program is so bloated now I can't add SD card use, not without compressing some 700+ longs!!

    But it can help me NOW during the debug phase on getting everything working up to the point I could possibly make use of a SD card.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
Sign In or Register to comment.