-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Problem - The mission() function documentation isn't clear
The documentation for ENES100.mission() looks like this:
ENES100ArduinoLibrary/README.md
Lines 98 to 102 in cec8cdc
| Valid calls for **DATA**: | |
| * `Enes100.mission(CYCLE, x);` *x is the duty cycle percent (ex. 10, 30, 50, 70, 90)* | |
| * `Enes100.mission(MAGNETISM, MAGNETIC);` | |
| * `Enes100.mission(MAGNETISM, NOT_MAGNETIC);` |
What's not clear is how many arguments (and of what type) each function takes. Does Enes100.mission(CYCLE, x); take one argument x, whose meaning is the duty cycle? Or does it take two arguments? And if it takes two, what types are the arguments?
Also, why should students use the mission() function instead of just printing to the serial monitor directly?
As I show below, confusion over what arguments (and what types) the mission() function takes matters, because the arguments determine which version of mission() gets dispatched
The ENES100.mission() function actually seems to use polymorphic dispatch
Here's one version of the function that takes two ints as arguments:
ENES100ArduinoLibrary/src/VisionSystemClient.cpp
Lines 57 to 65 in cec8cdc
| bool VisionSystemClient::mission(int type, int message) { | |
| mSerial->write(OP_MISSION); | |
| mSerial->write(type); | |
| mSerial->print(message); | |
| mSerial->write(FLUSH_SEQUENCE, 4); | |
| mSerial->flush(); | |
| return receive(NULL); | |
| } |
And here's another that takes an int and a char:
ENES100ArduinoLibrary/src/VisionSystemClient.cpp
Lines 76 to 84 in cec8cdc
| bool VisionSystemClient::mission(int type, char message) { | |
| mSerial->write(OP_MISSION); | |
| mSerial->write(type); | |
| mSerial->print(message); | |
| mSerial->write(FLUSH_SEQUENCE, 4); | |
| mSerial->flush(); | |
| return receive(NULL); | |
| } |
A user shouldn't have to know which version of the function gets dispatched , but students are getting very confused about how many arguments they're supposed to provide to mission() and what types those arguments should be.
Proposed Solution
We should at least be using syntax-colored fenced code blocks to document function calls.
So,
```ino
ENES100.mission(int type, char message)
```
becomes
ENES100.mission(int type, char message);Questions
- Why do we have multiple versions of
ENES100.mission()? - Why don't students just use a basic print command to print to the serial monitor?
- Can we implement fenced code blocks in the README to make documentation clearer?
/cc @itsecgary