Reset DMA pulse width reader state when stale
We should always be updating at a regular interval.
Signed-off-by: milind-u <milind.upadhyay@gmail.com>
Change-Id: Ibf3071831eb42123697b4f47f1b8056557ea42ee
diff --git a/frc971/wpilib/dma_edge_counting.h b/frc971/wpilib/dma_edge_counting.h
index a945909..4d1246c 100644
--- a/frc971/wpilib/dma_edge_counting.h
+++ b/frc971/wpilib/dma_edge_counting.h
@@ -50,7 +50,7 @@
private:
void UpdateFromSample(const DMASample & /*sample*/) override;
- void UpdatePolledValue() override {}
+ void UpdatePolledValue() override;
void PollFromSample(const DMASample & /*sample*/) override {}
void AddToDMA(DMA *dma) override {
@@ -66,6 +66,8 @@
bool have_prev_sample_ = false;
// Last time the reading switched to high
uint64_t high_time_ = 0;
+ // Number of times we've been polled without an update
+ size_t poll_count_ = 0;
double last_width_ = ::std::numeric_limits<double>::quiet_NaN();