Make DMA pulse width work
The sensors return 1 when there is no ball...
Also fix a move before get to a get before move to fix a segfault
Change-Id: If7ebcda52c18f011eb7583a494eb52a8d038cb1b
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/wpilib/dma_edge_counting.h b/frc971/wpilib/dma_edge_counting.h
index 03ceeb0..d8fe476 100644
--- a/frc971/wpilib/dma_edge_counting.h
+++ b/frc971/wpilib/dma_edge_counting.h
@@ -71,7 +71,7 @@
};
// Takes two digital inputs and times the difference between the first one going
-// high and the second one going high.
+// low and the second one going low.
class DMAPulseSeparationReader : public DMASampleHandlerInterface {
public:
DMAPulseSeparationReader(frc::DigitalInput *input_one,
@@ -94,7 +94,7 @@
dma->Add(input_one_);
dma->SetExternalTrigger(input_one_, true, true);
dma->Add(input_two_);
- dma->SetExternalTrigger(input_two_, true, false);
+ dma->SetExternalTrigger(input_two_, false, true);
}
static constexpr double kSampleTimeoutSeconds = 0.1;
@@ -107,7 +107,7 @@
// Whether or not we actually have anything in prev_sample_.
bool have_prev_sample_ = false;
- // the time when the input one went high.
+ // the time when the input one went low.
std::optional<double> input_one_time_;
int pulses_detected_ = 0;