need minor help with LM9033a driver ver 002
'*************************************** PRI displayMainScreen '*************************************** 'Setup a screen with the logo gr.color(3) gr.textmode(2,2,5,4) gr.width(0) gr.text(63,67,@TXTlogo) gr.textmode(2,2,5,4) gr.width(1) gr.text(63,45,@TXTprs) gr.colorwidth(3,1) gr.box(0,0,128,50) gr.textmode(4,4,8,5) gr.colorwidth(0,7) gr.text(64,25,@TXTpsi) '*************************************** PRI pauseMSec(Duration) '*************************************** '' Pause execution in milliseconds. '' Duration = number of milliseconds to delay waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt) '*************************************** DAT '*************************************** TXTlogo byte "Boost Leash",0 TXTprs byte "CO2 Psi",0 TXTpsi byte "100",0
At the bottom of this code in the DAT section is some text to be displayed on the lcd. How can I make it display a varible instead of the preset data?
Comments
http://obex.parallax.com/objects/529/
So, you add this object to the OBJ section:
OBJ
stringObj: "ASCII0_STREngine_1"
...
As I learned from the source of this string-object, it has an internal buffer to hold the converted number. So, wherever you want to output the value of your variable you have to say:
gr.text( 64,25, stringObj( count1, 3 ) )
this will output the number with sign
gr.text( 64,25, stringObj( count1, 3 )+1 )
this will output the number without sign
PS: If you have test code, then post it here and we can have a look what your missunderstanding is.
Is there something missing? I dont see anything pointing to a method in the stringObj object. Should there be something like : gr.text( 64,25, stringObj.method( count1, 3 ) ). Im just asking cause im still learning. I just though there should be a .method behind the stringObj
stringObj.integerToDecimal(...)
is the right function.
Don't hesitate to open the *.spin-files of objects you want to use. These are in most cases documented very well. The radiobuttons above the editor in the propeller-tool ("Full source", "Summary") are good for browsing a file. Summary gives you a complete list of functions available in the file. Good function names will speek for themselves.
...
gr.text(64,25,@TXTpsi)
...
and in the DAT section you find:
...
TXTpsi byte "100",0
So, what do we have here? TXTpsi is a label which is used to mark a piece of memory, here it's a piece having 4 bytes. What makes this piece of memory a string is the fact that all bytes used there are characters ( "100" = 3 characters ) and the end of string sign (the 0).
The problem with strings is, that we can not use strings as parameters or return values. The reason for that is that the propeller language simply does not allow that. The only datatype that can be used as parameter or return value is the LONG.
So, how do we pass strings then? We don't, we only pass the address!
The instruction gr.text(..., @TXTpsi) only passes the address of the memory location TXTpsi (that's what the @ means).
And NO, the function call stringObj.integerToDec(..) does not give a zero terminated string. It returns the address where to find that string. And that's exactly what the function gr.text(...) wants to know.
You should only be aware that integerToDec always will use the same buffer to convert a number to string. So, if you convert several numbers, the previous converted number will be overwritten. If you need to keep the strings you have to copy them from that buffer to your own buffer ( for example to TXTpsi ).
Hope that helped.