Package edu.wpi.first.wpilibj.simulation
Class PWMSim
java.lang.Object
edu.wpi.first.wpilibj.simulation.PWMSim
Class to control a simulated PWM output.
-
Constructor Summary
ConstructorDescriptionPWMSim
(int channel) Constructs from a PWM channel number.PWMSim
(PWMMotorController motorctrl) Constructs from a PWMMotorController object.Constructs from a PWM object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check whether the PWM has been initialized.int
Get the PWM period scale.double
Get the PWM position.int
Get the PWM pulse microsecond value.double
getSpeed()
Get the PWM speed.boolean
Check whether the PWM is zero latched.registerInitializedCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM is initialized.registerPeriodScaleCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM period scale changes.registerPositionCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM position changes.registerPulseMicrosecondCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM raw value changes.registerSpeedCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM speed changes.registerZeroLatchCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM zero latch state changes.void
Reset all simulation data.void
setInitialized
(boolean initialized) Define whether the PWM has been initialized.void
setPeriodScale
(int periodScale) Set the PWM period scale.void
setPosition
(double position) Set the PWM position.void
setPulseMicrosecond
(int microsecondPulseTime) Set the PWM pulse microsecond value.void
setSpeed
(double speed) Set the PWM speed.void
setZeroLatch
(boolean zeroLatch) Define whether the PWM has been zero latched.
-
Constructor Details
-
PWMSim
Constructs from a PWM object.- Parameters:
pwm
- PWM to simulate
-
PWMSim
Constructs from a PWMMotorController object.- Parameters:
motorctrl
- PWMMotorController to simulate
-
PWMSim
Constructs from a PWM channel number.- Parameters:
channel
- Channel number
-
-
Method Details
-
registerInitializedCallback
Register a callback to be run when the PWM is initialized.- Parameters:
callback
- the callbackinitialNotify
- whether to run the callback with the initial state- Returns:
- the
CallbackStore
object associated with this callback.
-
getInitialized
Check whether the PWM has been initialized.- Returns:
- true if initialized
-
setInitialized
Define whether the PWM has been initialized.- Parameters:
initialized
- whether this object is initialized
-
registerPulseMicrosecondCallback
public CallbackStore registerPulseMicrosecondCallback(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM raw value changes.- Parameters:
callback
- the callbackinitialNotify
- whether to run the callback with the initial value- Returns:
- the
CallbackStore
object associated with this callback.
-
getPulseMicrosecond
Get the PWM pulse microsecond value.- Returns:
- the PWM pulse microsecond value
-
setPulseMicrosecond
Set the PWM pulse microsecond value.- Parameters:
microsecondPulseTime
- the PWM pulse microsecond value
-
registerSpeedCallback
Register a callback to be run when the PWM speed changes.- Parameters:
callback
- the callbackinitialNotify
- whether to run the callback with the initial value- Returns:
- the
CallbackStore
object associated with this callback.
-
getSpeed
Get the PWM speed.- Returns:
- the PWM speed (-1.0 to 1.0)
-
setSpeed
Set the PWM speed.- Parameters:
speed
- the PWM speed (-1.0 to 1.0)
-
registerPositionCallback
Register a callback to be run when the PWM position changes.- Parameters:
callback
- the callbackinitialNotify
- whether to run the callback with the initial value- Returns:
- the
CallbackStore
object associated with this callback.
-
getPosition
Get the PWM position.- Returns:
- the PWM position (0.0 to 1.0)
-
setPosition
Set the PWM position.- Parameters:
position
- the PWM position (0.0 to 1.0)
-
registerPeriodScaleCallback
Register a callback to be run when the PWM period scale changes.- Parameters:
callback
- the callbackinitialNotify
- whether to run the callback with the initial value- Returns:
- the
CallbackStore
object associated with this callback.
-
getPeriodScale
Get the PWM period scale.- Returns:
- the PWM period scale
-
setPeriodScale
Set the PWM period scale.- Parameters:
periodScale
- the PWM period scale
-
registerZeroLatchCallback
Register a callback to be run when the PWM zero latch state changes.- Parameters:
callback
- the callbackinitialNotify
- whether to run the callback with the initial state- Returns:
- the
CallbackStore
object associated with this callback.
-
getZeroLatch
Check whether the PWM is zero latched.- Returns:
- true if zero latched
-
setZeroLatch
Define whether the PWM has been zero latched.- Parameters:
zeroLatch
- true to indicate zero latched
-
resetData
Reset all simulation data.
-