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

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
3: Propeller Programming Tutorial
Objects vs. Cogs
It’s important to understand that there is no direct relationship between objects and cogs.
Remember, Exercise 5 used just one object but two cogs and Exercise 6 used two objects and
two cogs, but each of these exercises could have used only one cog if they wanted to process
everything serially.
When and how cogs are used is completely determined by the
application and the developer(s) who wrote it.
Exercise 7: Output.spin – More Enhancements
Let’s add some significant enhancements to our Output object. Currently the
method
Toggle
can be called to toggle a pin serially, or the
method can be called to launch the
Start
Toggle
method as a separate process, to run in parallel. But we haven’t provided a way to stop that
process once it is going or even a way to determine if it’s running in the first place. Also, it
would be nice to have the option of toggling the pin endlessly, in addition to the finite count
feature we already have.
Let’s add a
method to stop the active process and an
method to test whether a
Stop
Active
parallel process is currently running. In addition, we’ll enhance our
method as
Toggle
described above.
For objects like this one, it is a common and recommended convention to use the name
“Start” for a method that activates a new cog and the name “Stop” for a method that
deactivates a cog previously started by that object. This way, while scanning an object in
summary or documentation view, other developers can more quickly understand how to use
your object; when they see
and
they can infer that the object activates/deactivates
Start
Stop
another cog.
For objects that don’t activate another cog but still need some kind of
initialization, it is recommended to use the name “Init” for the key method.
This code is loaded with clever changes; be prepared, it will take a lot to explain it but the
knowledge you’ll gain is well worth it.
Here’s the code; modify yours to match:
Propeller Manual v1.0 · Page 117

Related parts for 122-32000