Commonly used Propeller methods: Need some feedback.
Oldbitcollector (Jeff)
Posts: 8,091
I'm working on a document of commonly used methods. I could use some feedback on these and if anyone else sees some I missed.
Thanks
OBC
An object’s prefix name is flexible, and is defined at the time the object is called in the OBJ section of the main program. The examples used in this document with use the name “myobject”.
START
The .start method is found in most objects as it is used to launch the object into one of the Propeller’s additional cogs. It also commonly passes I/O or configuration information to the object as well.
myobject.start(9600)
myobject.start(12)
myobject.start(my_variable,my_variable2)
STOP
The .stop method is the opposite of .start. It stops the object and frees the cog.
STR
The .str method can be found in various display and communications objects.
It is commonly used for displaying text or the contents of a variable.
myobject.str(string(“Display a line of text”))
myobject.str(string(“Display a line of text with a carrage return”,13))
myobject.str(my_multibyte_variable)
DEC
The .dec method can be found in various display and communication objects.
It is commonly used for displaying the decimal value of a variable.
myobject.dec(my_variable)
HEX
The .hex method can be found in various display and communication objects.
It is commonly used for displaying the hexadecimal value of a variable.
The secondary data (2 in the example) defines the number places to calculate.
myobject.hex(my_variable,2)
BIN
The .bin method can be found in various display and communication objects.
It is commonly used for displaying the binary value of a variable.
The secondary data (8 in the example) defines the number of digits to calculate.
myobject.bin(my_variable,8)
OUT (or TX)
The .out (sometimes called, .tx) method can be found in various display and communication objects. It is commonly used for displaying the variable. In the case of a video driver, the display will act on the contents of the variable instead of displaying the number itself. .out($08) sends a backspace, instead of displaying an “8”.
NEWLINE
The .newline method can be found in various display and communication objects. It is used to send a carriage return to the device.
Thanks
OBC
An object’s prefix name is flexible, and is defined at the time the object is called in the OBJ section of the main program. The examples used in this document with use the name “myobject”.
START
The .start method is found in most objects as it is used to launch the object into one of the Propeller’s additional cogs. It also commonly passes I/O or configuration information to the object as well.
myobject.start(9600)
myobject.start(12)
myobject.start(my_variable,my_variable2)
STOP
The .stop method is the opposite of .start. It stops the object and frees the cog.
STR
The .str method can be found in various display and communications objects.
It is commonly used for displaying text or the contents of a variable.
myobject.str(string(“Display a line of text”))
myobject.str(string(“Display a line of text with a carrage return”,13))
myobject.str(my_multibyte_variable)
DEC
The .dec method can be found in various display and communication objects.
It is commonly used for displaying the decimal value of a variable.
myobject.dec(my_variable)
HEX
The .hex method can be found in various display and communication objects.
It is commonly used for displaying the hexadecimal value of a variable.
The secondary data (2 in the example) defines the number places to calculate.
myobject.hex(my_variable,2)
BIN
The .bin method can be found in various display and communication objects.
It is commonly used for displaying the binary value of a variable.
The secondary data (8 in the example) defines the number of digits to calculate.
myobject.bin(my_variable,8)
OUT (or TX)
The .out (sometimes called, .tx) method can be found in various display and communication objects. It is commonly used for displaying the variable. In the case of a video driver, the display will act on the contents of the variable instead of displaying the number itself. .out($08) sends a backspace, instead of displaying an “8”.
NEWLINE
The .newline method can be found in various display and communication objects. It is used to send a carriage return to the device.
Comments
I see INIT a lot in objects. It's mainly used to setup varibles in an object that don't use thier own cog. Some objects require a call to INIT before calling START.
Also, if you have a variable array you want to display with .str, you don't use the "string" command, you just use the pointer
myobj.str(@variableArray)
OR
myobj.str(@variableArray[x])
with "x" being the variable to start with.
Good points both! I'll make the adjustment on that str variable entry. Duh!
Hence the reason for a second set of eyes. Thanks
@Duane
Will add the INIT entry under START -- Thanks
I agree with localroger about the TX, DEC, HEX and other routines. I am amazed that experienced Spin programmers print "formatted" output by intermixing calls to STR, TX, DEC, HEX and so on. I think most people do it so that their programs support the lowest common denominator of serial/video/VGA driver. It would be nice if we could start using some standard formatted I/O routines.
OBC