Class PWMSim
java.lang.Object
org.wpilib.simulation.PWMSim
Class to control a simulated PWM output.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck whether the PWM has been initialized.intGet the PWM period scale.intGet 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.voidReset all simulation data.voidsetInitialized(boolean initialized) Define whether the PWM has been initialized.voidsetOutputPeriod(int period) Set the PWM period scale.voidsetPulseMicrosecond(int microsecondPulseTime) Set the PWM pulse microsecond value.
-
Constructor Details
-
PWMSim
-
PWMSim
public PWMSim(int channel) 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
CallbackStoreobject associated with this callback.
-
getInitialized
public boolean getInitialized()Check whether the PWM has been initialized.- Returns:
- true if initialized
-
setInitialized
public void setInitialized(boolean initialized) 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
CallbackStoreobject associated with this callback.
-
getPulseMicrosecond
public int getPulseMicrosecond()Get the PWM pulse microsecond value.- Returns:
- the PWM pulse microsecond value
-
setPulseMicrosecond
public void setPulseMicrosecond(int microsecondPulseTime) 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
CallbackStoreobject associated with this callback.
-
getOutputPeriod
public int getOutputPeriod()Get the PWM period scale.- Returns:
- the PWM period scale
-
setOutputPeriod
public void setOutputPeriod(int period) Set the PWM period scale.- Parameters:
period- the PWM period scale
-
resetData
public void resetData()Reset all simulation data.
-