DutyCycleEncoder: Fix simulation support (#2387)

The DutyCycleEncoder class initializes AnalogTrigger, which is not supported in simulation.

To avoid this, do not use AnalogTrigger (or Counter) in simulation mode.

Fixes #2367

Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
Joshua Shannon
2020-03-20 16:32:52 -05:00
committed by GitHub
parent 56fbb1fc33
commit 272eaf184f
3 changed files with 38 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2019 FIRST. All Rights Reserved. */
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
@@ -160,8 +160,8 @@ class DutyCycleEncoder : public ErrorBase,
void Init();
std::shared_ptr<DutyCycle> m_dutyCycle;
AnalogTrigger m_analogTrigger;
Counter m_counter;
std::unique_ptr<AnalogTrigger> m_analogTrigger;
std::unique_ptr<Counter> m_counter;
int m_frequencyThreshold = 100;
double m_positionOffset = 0;
double m_distancePerRotation = 1.0;