def __init__(self, channel): """Constructor for an analog trigger given a channel number or analog input. :param channel: the port index or :class:`.AnalogInput` to use for the analog trigger. Treated as an AnalogInput if the provided object has a getChannel function. """ super().__init__() if not hasattr(channel, "getChannel"): self.analogInput = AnalogInput(channel) self.ownsAnalog = True self.addChild(self.analogInput) else: self.analogInput = channel self._port, self.index = hal.initializeAnalogTrigger( self.analogInput.port) self.__finalizer = \ weakref.finalize(self, _freeAnalogTrigger, self._port) # Need this to free on unit test wpilib reset Resource._add_global_resource(self) hal.report(hal.UsageReporting.kResourceType_AnalogTrigger, channel) self.setName("AnalogTrigger", self.analogInput.getChannel())
def __init__(self, channel): """Constructor for an analog trigger given a channel number or analog input. :param channel: the port index or :class:`.AnalogInput` to use for the analog trigger. Treated as an AnalogInput if the provided object has a getChannel function. """ if hasattr(channel, "getChannel"): channel = channel.getChannel() port = hal.getPort(channel) self._port, self.index = hal.initializeAnalogTrigger(port) self.__finalizer = \ weakref.finalize(self, _freeAnalogTrigger, self._port) # Need this to free on unit test wpilib reset Resource._add_global_resource(self) hal.HALReport(hal.HALUsageReporting.kResourceType_AnalogTrigger, channel)