Third Design Review for new DFW API #9
Conversation
The Constructor takes the serial port number, but in the comments it notes that Serial1 is the only valid one. THis has been changed to only access Serial1 and removed the parameter.
The competition code is being switched over to a function pointer model.
The functions that the user defines, now include the passing of the DFW object from the fundtion call to the user function. THe lets the user functions to be in isolated files and avoids code clutter. It also provides an example to the users of how to pass objects around between sections of code.
The packet parsing is done in line rather than depending on the find functions.
The start button needs to be hit a second time to kick the framework into teleop mode.
The debug led will now flash when communication is working, and stay solid on if it fails.
The buttons now return the result of the mask check directly. In addition all of the initialization code loads using 9600 only.
| if (start()) { | ||
| state = Autonomous; | ||
| autoStartTime = millis(); // sets start time of autonomous | ||
| // fall through when a state changes |
There was a problem hiding this comment.
Do we want to fall through or wait for the next loop?
| timeDiff = millis() - autoStartTime; | ||
| if (timeDiff > autoTime) { | ||
| state = waitForTeleop; | ||
| // fall through when a state changes |
There was a problem hiding this comment.
Do we want to fall through or wait for the next loop?
DFW.cpp
Outdated
| if (start()) { | ||
| state = Teleop; | ||
| teleopStartTime = millis(); // sets start time of autonomous | ||
| // fall through when a state changes |
There was a problem hiding this comment.
Do we want to fall through or wait for the next loop?
DFW.cpp
Outdated
| if (Serial1.peek() == 'A' && Serial1.available() >= packetSize) { | ||
| packet[0] = Serial1.read(); | ||
| if (Serial1.peek() == 'c' && Serial1.available() >= (packetSize - 1)) { | ||
| //Serial.print("\r\nPacket start = "); |
There was a problem hiding this comment.
We should probably remove this comment
DFW.cpp
Outdated
| while (Serial1.available() > 0) { | ||
| char clearing = Serial1.read(); | ||
| } | ||
| if ( packet[0] == 'A' && |
There was a problem hiding this comment.
Is there an extra tab on this line?
DFW.cpp
Outdated
| startB = 0; | ||
| } | ||
| return (startB); | ||
| return ((byteBu[1] & 0b00000010) == 0) ; |
There was a problem hiding this comment.
For all of these functions:
- remove space before
; - remove extra parenthesis around the expression
| * by the framework. The framework will pass your code a reference to the DFW | ||
| * object as well as the amount of MS remaining. | ||
| */ | ||
| #include <DFW.h> // DFW include |
There was a problem hiding this comment.
Is this comment needed? Seems very obvious.
| @@ -0,0 +1,6 @@ | |||
| #include <DFW.h> // DFW include | |||
|
|
|||
| void autonomous( long time,DFW & dfw) { // function definition | |||
There was a problem hiding this comment.
Is this comment needed? Seems very obvious.
| } | ||
|
|
||
| void loop() { | ||
| dfw.run();// Called to update the controllers output. Do not call faster than every 15ms. |
There was a problem hiding this comment.
It can now be called that fast
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Remove extra new lines
This update makes the button functions a flat one-liner. The comments on the competion has beed re-written. The begin function does not take a parameter since it can only be 9600.