[sim] Add WPILib-class-taking constructors (#2538)

When not direct mapped, make index constructors private and add factory
functions for channel and index.

Co-authored-by: GabrielDeml <gabrielddeml@gmail.com>
This commit is contained in:
Peter Johnson
2020-07-04 10:10:43 -07:00
committed by GitHub
parent 80a1fa9ece
commit 3050e935a1
75 changed files with 1281 additions and 126 deletions

View File

@@ -13,12 +13,29 @@
#include <hal/simulation/PWMData.h>
#include "CallbackStore.h"
#include "frc/PWM.h"
namespace frc {
namespace sim {
/**
* Class to control a simulated PWM output.
*/
class PWMSim {
public:
explicit PWMSim(int index) { m_index = index; }
/**
* Constructs from a PWM object.
*
* @param pwm PWM to simulate
*/
explicit PWMSim(const PWM& pwm) : m_index{pwm.GetChannel()} {}
/**
* Constructs from a PWM channel number.
*
* @param channel Channel number
*/
explicit PWMSim(int channel) : m_index{channel} {}
std::unique_ptr<CallbackStore> RegisterInitializedCallback(
NotifyCallback callback, bool initialNotify) {