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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check whether the PWM has been initialized.int
Get the PWM period scale.int
Get the PWM pulse microsecond value.registerInitializedCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM is initialized.registerOutputPeriodCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM period scale changes.registerPulseMicrosecondCallback
(NotifyCallback callback, boolean initialNotify) Register a callback to be run when the PWM raw value changes.void
Reset all simulation data.void
setInitialized
(boolean initialized) Define whether the PWM has been initialized.void
setOutputPeriod
(int period) Set the PWM period scale.void
setPulseMicrosecond
(int microsecondPulseTime) Set the PWM pulse microsecond value.
-
Constructor Details
-
PWMSim
Constructs from a PWM object.- Parameters:
pwm
- PWM 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
-
registerOutputPeriodCallback
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.
-
getOutputPeriod
Get the PWM period scale.- Returns:
- the PWM period scale
-
setOutputPeriod
Set the PWM period scale.- Parameters:
period
- the PWM period scale
-
resetData
Reset all simulation data.
-