Skip to content

Comments

Third Design Review for new DFW API #9

Merged
madhephaestus merged 25 commits intomasterfrom
development
Mar 31, 2017
Merged

Third Design Review for new DFW API #9
madhephaestus merged 25 commits intomasterfrom
development

Conversation

@madhephaestus
Copy link
Contributor

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = ");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably remove this comment

DFW.cpp Outdated
while (Serial1.available() > 0) {
char clearing = Serial1.read();
}
if ( packet[0] == 'A' &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an extra tab on this line?

DFW.cpp Outdated
startB = 0;
}
return (startB);
return ((byteBu[1] & 0b00000010) == 0) ;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment needed? Seems very obvious.

@@ -0,0 +1,6 @@
#include <DFW.h> // DFW include

void autonomous( long time,DFW & dfw) { // function definition
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment needed? Seems very obvious.

}

void loop() {
dfw.run();// Called to update the controllers output. Do not call faster than every 15ms.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can now be called that fast

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it can





Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra new lines

@madhephaestus madhephaestus merged commit 311b629 into master Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants