Convert y2014 over to use the new SensorReader class
Another step in converting to event loops.
Change-Id: I1faa643596128b53e1ab166abcf74c8d72fe039b
diff --git a/frc971/wpilib/sensor_reader.h b/frc971/wpilib/sensor_reader.h
index 0ce203c..47ca95c 100644
--- a/frc971/wpilib/sensor_reader.h
+++ b/frc971/wpilib/sensor_reader.h
@@ -20,6 +20,7 @@
class SensorReader {
public:
SensorReader();
+ virtual ~SensorReader() {}
// Updates the fast and medium encoder filter frequencies.
void UpdateFastEncoderFilterHz(int hz);
@@ -34,6 +35,10 @@
// Sets the dma.
void set_dma(::std::unique_ptr<DMA> dma);
+ void AddToDMA(DMASampleHandlerInterface *handler) {
+ dma_synchronizer_->Add(handler);
+ }
+
// Sets the pwm trigger.
void set_pwm_trigger(::std::unique_ptr<frc::DigitalInput> pwm_trigger);
@@ -41,6 +46,7 @@
void Quit() { run_ = false; }
virtual void RunIteration() = 0;
+ virtual void RunDmaIteration() {}
void operator()();
@@ -51,6 +57,9 @@
drivetrain_right_encoder_;
private:
+ // Gets called right before the DMA synchronizer is up and running.
+ virtual void Start() {}
+
// Uses the pwm trigger to find the pwm cycle width and offset for that
// iteration.
void RunPWMDetecter();