DigitalPWMSim
- class wpilib.simulation.DigitalPWMSim(digital_output: wpilib._wpilib.DigitalOutput)
Bases:
pybind11_objectClass to control a simulated digital PWM output.
This is for duty cycle PWM outputs on a DigitalOutput, not for the servo style PWM outputs on a PWM channel.
Constructs from a DigitalOutput object.
- Parameters:
digital_output – DigitalOutput to simulate
- static create_for_channel(channel: SupportsInt | SupportsIndex) wpilib.simulation._simulation.DigitalPWMSim
Creates an DigitalPWMSim for a digital I/O channel.
- Parameters:
channel – DIO channel
- Returns:
Simulated object @throws std::out_of_range if no Digital PWM is configured for that channel
- static create_for_index(index: SupportsInt | SupportsIndex) wpilib.simulation._simulation.DigitalPWMSim
Creates an DigitalPWMSim for a simulated index. The index is incremented for each simulated DigitalPWM.
- Parameters:
index – simulator index
- Returns:
Simulated object
- get_duty_cycle() float
Read the duty cycle value.
- Returns:
the duty cycle value of this PWM output
- get_initialized() bool
Check whether this PWM output has been initialized.
- Returns:
true if initialized
- get_pin() int
Check the pin number.
- Returns:
the pin number
- register_duty_cycle_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore
Register a callback to be run whenever the duty cycle value changes.
- Parameters:
callback – the callback
initial_notify – whether to call the callback with the initial state
- Returns:
the CallbackStore object associated with this callback
- register_initialized_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore
Register a callback to be run when this PWM output is initialized.
- Parameters:
callback – the callback
initial_notify – whether to run the callback with the initial state
- Returns:
the CallbackStore object associated with this callback
- register_pin_callback(callback: collections.abc.Callable[[str, hal._wpi_hal.Value], None], initial_notify: bool) wpilib.simulation._simulation.CallbackStore
Register a callback to be run whenever the pin changes.
- Parameters:
callback – the callback
initial_notify – whether to call the callback with the initial state
- Returns:
the CallbackStore object associated with this callback
- reset_data() None
Reset all simulation data.
- set_duty_cycle(duty_cycle: SupportsFloat | SupportsIndex) None
Set the duty cycle value of this PWM output.
- Parameters:
duty_cycle – the new value
- set_initialized(initialized: bool) None
Define whether this PWM output has been initialized.
- Parameters:
initialized – whether this object is initialized
- set_pin(pin: SupportsInt | SupportsIndex) None
Change the pin number.
- Parameters:
pin – the new pin number