Subject:
|
global output control
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Sun, 18 Jun 2000 16:03:38 GMT
|
Viewed:
|
1826 times
|
| |
| |
The Scout and RCX 2.0 both support what lego calls "global" control of
the outputs. At first I thought the global calls somehow took
precedence over normal calls, so I simply made global versions of all
the output calls in NQC.
However, after playing with it a little bit I think a different API is
warranted.
The global On/Off calls enable/disable the outputs. When disabled,
normal output calls will have no effect. Disabling also has the added
effect of turning the output off.
On(OUT_A); // A is turned on
OffG(OUT_A); // A turned off
On(OUT_A); // call ignored - A is disabled by the global call
OnG(OUT_A); // A enabled, but still off
On(OUT_A); // A turns on again
The global direction calls can invert the direction of the outputs.
Note that it is impossible for the global calls to set a specific
direction.
OnFwd(OUT_A); // A on in forward direction
RevG(OUT_A); // A now going backwards (global invert)
Rev(OUT_A); // A will now go forwards since Rev() inverted is Fwd()
FwdG(OUT_A); // A goes backwards (no more onvert, Rev() taking effect)
For the power level, the global call just sets the maximum power setting.
So, I'm proposing a new set of APIs to replace all the xxxG() calls
currently in NQC 2.2 a2:
// primitives
SetGlobalOutput(const int outs, const int mode);
SetGlobalDirection(const int outs, const int dir);
SetMaxPower(const int outs, const int &power);
// convenience functions
EnableOutput(const int outs); // global on
DisableOutput(const int outs); // global off
InvertOutput(const int outs); // global reverse
RevertOutput(const int outs); // global fwd
Any comments? The only name I'm really unhappy with is "RevertOutput".
Dave Baum
--
reply to: dbaum at enteract dot com
|
|
Message has 2 Replies:
12 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|