Shop OBEX P1 Docs P2 Docs Learn Events
Using Parallax Serial Terminal to output multi-column ADC numbers — Parallax Forums

Using Parallax Serial Terminal to output multi-column ADC numbers

roboticsrobotics Posts: 90
edited 2014-12-12 21:10 in General Discussion
Hi,

When I output adc values (0-255) from a sensor using the Spin Parallax Serial Terminal using the following code, the original and continually updated adc readings appear fine:

pst.Position(0,0)
pst.Dec(adc_reading_1)
pst.ClearEnd

When I want to place another adc reading to right of the first output (ie, in a second column) using the following code, the numbers for the first adc get mangled as the adc values change due to the
number of digits changing and the lack of the pst.ClearEnd command after the first adc reading.

pst.Position(0,0)
pst.Dec(adc_reading_1)


pst.Position(15,0)
pst.Dec(adc_reading_2)
pst.ClearEnd

Best way to handle this please as I would like to have 2 columns of streaming data.

Thank you

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-12-12 21:10
    The easiest way is to add spaces after the first value to blank out the old data and let the second column bounce back and forth depending on the number of digits of the first value.

    If you want the display nice and neat, then you'll want to use a string formating object like the one included in several of the attached archives in this thread. (I'd try the first attachment to post #1.)

    The name of the object I commonly used (and which should be included in the above linked thread) is "strfmt.spin". I think there is also a "numbers" object included with the Propeller library which should help you in this matter. You will want to use one of the methods with will pad the number displayed with spaces. I don't recall the names of these methods off hand.
Sign In or Register to comment.