Help with Numbers Object
lfreeze
Posts: 174
Please help me solve this problem…..
I am using the numbers object to convert variables to strings for display on an LCD. The numbers
Object does display the correct converted variables to strings, but it adds a leading blank space for each conversion.
I am using this format from the numbers object to make the conversion,
ser.str(num.tostr(HOUR,%000_000_000_0_0_000000_01010 ))
The format results in an LCD display of “hour= 12” , I need to eliminate the leading blank
Character and display this “hour=12 “
The example program is below.
Is there a Way to format the numbers object to eliminate the leading blank character entirely ,
Or a way to edit the string?
I tried using the formaters associated with the lcd to eliminate the blank “destructive backspace and character positioning”
but they did not help. I hope someone can point me the right direction,
Thank you in advance for any help/
Larry
{{ TEST OF NUMBERS OBJECT
}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
ser :"fullduplexserial"
num : "numbers"
PUB main | hour
hour:=0
ser.start(31, 30, 0, 9600) 'note pin 16 is for the data to the lcd
repeat
ser.tx(13)'carriage return
ser.tx(10)'line feed
waitcnt (20_000_000 + cnt )
num.init
ser.str(STRING("hour="))
ser.str(num.tostr(HOUR,%000_000_000_0_0_000000_01010 ))
waitcnt (20_000_000 + cnt )
HOUR++
if HOUR==11
HOUR:=1
I am using the numbers object to convert variables to strings for display on an LCD. The numbers
Object does display the correct converted variables to strings, but it adds a leading blank space for each conversion.
I am using this format from the numbers object to make the conversion,
ser.str(num.tostr(HOUR,%000_000_000_0_0_000000_01010 ))
The format results in an LCD display of “hour= 12” , I need to eliminate the leading blank
Character and display this “hour=12 “
The example program is below.
Is there a Way to format the numbers object to eliminate the leading blank character entirely ,
Or a way to edit the string?
I tried using the formaters associated with the lcd to eliminate the blank “destructive backspace and character positioning”
but they did not help. I hope someone can point me the right direction,
Thank you in advance for any help/
Larry
{{ TEST OF NUMBERS OBJECT
}}
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
ser :"fullduplexserial"
num : "numbers"
PUB main | hour
hour:=0
ser.start(31, 30, 0, 9600) 'note pin 16 is for the data to the lcd
repeat
ser.tx(13)'carriage return
ser.tx(10)'line feed
waitcnt (20_000_000 + cnt )
num.init
ser.str(STRING("hour="))
ser.str(num.tostr(HOUR,%000_000_000_0_0_000000_01010 ))
waitcnt (20_000_000 + cnt )
HOUR++
if HOUR==11
HOUR:=1
Comments
lcd set up characters. If I can't correct this with the lcd I have, I will purchase the parallax lcd. Can anyone tell me, if
when usning the fullduplexserial object that "ser.dec(anyvariable)" will display correctly without any leading blank character on the parallax lcd?
Thanks
Larry
num.tostr will return the address of the string, so when you add 1 your send will skip the first character.
There is another, simpler, smaller numbers object, and if i remember correctly you can get rid of the leading space.
obex.parallax.com/objects/182/
Massimo
I used that object with "ser.str(num.decf(hour,1))" and this eliminated the leading blank.
Larry
ser.dec(hour)
and not
ser.str(ser.dec(hour))
I just wanted to make that clear.
Dave