PDA

View Full Version : Objects and Cogs



Kokovec
07-04-2009, 03:29 AM
Here's a newbie question...

Is it possible to initialize a cog in one object and then access that same cog in another object?
For instance:

"Main" object starts SPI object in COG1
"Client" object uses SPI object in COG1 to send out a byte.

I'm sure this has been iscussed before but I have not been able to find a thread to answer this question.

jazzed
07-04-2009, 03:57 AM
As long as variables used by the lower level object are in a dat section, you should have no problem just including that object in main and client objects and using SPI receive, etc in both objects. A limit is that only one object should "start" the lower level object. Of course, if you have two different COGs objects trying to use the same lower level object, you may up with interference in the dat with indeterminate results on the interface (to get over that, you'll have to use locks).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve


Propalyzer: Propeller PC Logic Analyzer (http://www.brouhaha.com/~sdenson/Propalyzer)
http://forums.parallax.com/showthread.php?p=788230 (http://forums.parallax.com/showthread.php?p=788230)

Kokovec
07-04-2009, 04:11 AM
OK, I see.

What about if I wanted to use an object from the library.

Can I start COG1 in "Main" with the TV_Text object and then have the "Client" object send out a character using the same COG?

Does that make sense?

Dan

jazzed
07-04-2009, 04:38 AM
Usually you have to make some changes. I've attached a Tv_Text example for you.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve


Propalyzer: Propeller PC Logic Analyzer (http://www.brouhaha.com/~sdenson/Propalyzer)
http://forums.parallax.com/showthread.php?p=788230 (http://forums.parallax.com/showthread.php?p=788230)

Kokovec
07-04-2009, 04:42 AM
Cool. I get it now.

Thanks for your help!

Dan

phil kenny
07-04-2009, 09:51 AM
@jazzed,

As one who is just learning the Spin language, I have a question about
some of the syntax you used in xObjectTest.spin.

The ascii strings, "Hello", "Hello1" and "Hello2" are followed by
sd.

What is the significance of sd?

I thought the text string was supposed to be terminated by zero.

phil

jazzed
07-04-2009, 10:08 AM
The character $d (13 decimal) makes a new line for TV_Text and friends. The 0 is appended after the $d.

Syntax for string(...) allows all kinds of constants in any order i.e. string("line",$d,"newline",$9,"tabbed word",$d).
It's kind of like "character-coding" .... In the case of TV_Text.str(...) codes can be used to change colors or
reposition characters, etc... since the str() method calls out() and out "interprets" the character codes (ASCII).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve


Propalyzer: Propeller PC Logic Analyzer (http://www.brouhaha.com/~sdenson/Propalyzer)
http://forums.parallax.com/showthread.php?p=788230 (http://forums.parallax.com/showthread.php?p=788230)

phil kenny
07-04-2009, 10:23 AM
jazzed,

Thanks.

When I first looked at it in the Propeller Tool, it was hard to see
that the character was a dollar sign and not simply 's'. Makes sense
now.

phil