def __init__(self, channel: int) -> None: """Allocate a PWM given a channel. :param channel: The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port """ super().__init__() SendableBase.__init__(self) SensorUtil.checkPWMChannel(channel) self.channel = channel self._handle = hal.initializePWMPort(hal.getPort(channel)) self.__finalizer = weakref.finalize(self, _freePWM, self._handle) self.setDisabled() hal.setPWMEliminateDeadband(self.handle, False) hal.report(hal.UsageReporting.kResourceType_PWM, channel) self.setName("PWM", channel) self.setSafetyEnabled(False) # Python-specific: Need this to free on unit test wpilib reset Resource._add_global_resource(self)
def __init__(self, channel: int) -> None: """Allocate a PWM given a channel. :param channel: The PWM channel number. 0-9 are on-board, 10-19 are on the MXP port """ super().__init__() SendableBase.__init__(self) SensorUtil.checkPWMChannel(channel) self.channel = channel self.handle = hal.initializePWMPort(hal.getPort(channel)) self.__finalizer = weakref.finalize(self, _freePWM, self.handle) self.setDisabled() hal.setPWMEliminateDeadband(self.handle, False) hal.report(hal.UsageReporting.kResourceType_PWM, channel) self.setName("PWM", channel) self.setSafetyEnabled(False) # Python-specific: Need this to free on unit test wpilib reset Resource._add_global_resource(self)