122-32000 Parallax Inc, 122-32000 Datasheet - Page 119

MANUAL PROPELLER

122-32000

Manufacturer Part Number
122-32000
Description
MANUAL PROPELLER
Manufacturer
Parallax Inc
Datasheets

Specifications of 122-32000

Accessory Type
Manual
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
For Use With/related Products
Propeller Education (PE) Kit
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
The VAR Block
In the
the ID of the cog started by the
to the object; they can be used within any
modified by one method, other methods will see the new value when they are referenced.
The Start Method
For the
Since there are a limited number of cogs in the Propeller, the
to activate another cog every time it is called. For this reason, we’ll make it return a Boolean
(
indicates it will return this value we chose to call
returns a long value (4 bytes) whether or not it is specified to have one. When a method is
designed to return a meaningful value, it is always good practice to declare a return value as
we have done here. Our
variable, so we can assign either
exit.
The body of the
then it starts a new process. It calls the
multiple times without first calling
would start up and overwrite another cog’s workspace variables, such as
The next line is similar to our original but may seem a bit overwhelming because it is a
compound expression. We’ll dissect it a piece at a time from the inside out. The
portion of the line is exactly as it was before:
It activates another cog to run the
COGNEW
In the prior version of the Output object, we simply ignored the return value. This time,
however, we use
Cog := cognew(Toggle(Pin, Delay, Count), @Stack) + 1
COGNEW
Cog
We’ll use the
necessary. We’ll explain why we added 1 to it in a moment.
We’re not done with that line yet. To the left of the
assignment statement. So after the new cog’s ID is returned, added to 1 and stored in
that final value is also stored in the
TRUE
. The ‘
or
VAR
, take its returned value and add it to 1, then assign that result to the variable named
always returns the ID of the cog it started; 0 to 7, or -1 if no cog was available to start.
Start
FALSE
:=
block we’ve added a byte-sized variable,
’is the assignment operator; similar to the equal sign ‘
Cog
method, we’ve decided it may be nice to know if it was successful or not.
) value as an indication of its outcome; the “
Start
COGNEW
variable to remember the ID of the cog we started so we can later stop it if
method now does two things: first it stops any existing process and
’s return value in this expression and assign the result to a variable:
Success
Start
Success
symbol becomes an alias for the method’s built-in
Success
Toggle
Stop
method, if any. Both
Stop
from outside the object. Without that, a new cog
or
PUB
method. What you may not have known is that
variable. Remember how
RESULT
cognew(Toggle(Pin, Delay, Count), @Stack)
method first just in case
or
PRI
Success
a value to have that value returned upon
Cog
block in the Output object. If they are
. This will be used to keep track of
Cog :=
. Each
Stack
. This expression says to execute
Start
Propeller Manual v1.0 · Page 119
: Success
and
PUB
=
… part is the
’ in other languages.
method may not be able
Cog
and
Success
Start
Stack
” in its declaration
variables are global
PRI
has been called
.
method always
is supposed to
Success :=
RESULT
COGNEW
Cog
.
,

Related parts for 122-32000