Ejemplo n.º 1
0
    def __init__(self, channel: int) -> None:
        """Create an instance of a Digital Input class. Creates a digital
        input given a channel.

        :param channel: the DIO channel for the digital input. 0-9 are on-board, 10-25 are on the MXP
        """

        super().__init__()
        SensorUtil.checkDigitalChannel(channel)
        self.channel = channel

        self.handle = hal.initializeDIOPort(hal.getPort(channel), True)

        hal.report(hal.UsageReporting.kResourceType_DigitalInput, channel)
        self.setName("DigitalInput", channel)
Ejemplo n.º 2
0
    def __init__(self, channel):
        """Create an instance of a digital output.

        :param channel: the DIO channel for the digital output. 0-9 are on-board, 10-25 are on the MXP
        """

        super().__init__()
        self._pwmGenerator = None
        self._pwmGenerator_finalizer = None

        SensorUtil.checkDigitalChannel(channel)
        self.channel = channel

        self.handle = hal.initializeDIOPort(hal.getPort(channel), False)

        hal.report(hal.UsageReporting.kResourceType_DigitalOutput, channel)
        self.setName("DigitalOutput", channel)
Ejemplo n.º 3
0
    def __init__(self, channel: int) -> None:
        """Create an instance of a digital output.

        :param channel: the DIO channel for the digital output. 0-9 are on-board, 10-25 are on the MXP
        """

        super().__init__()
        self.pwmGenerator = None
        self._pwmGenerator_finalizer = None

        SensorUtil.checkDigitalChannel(channel)
        self.channel = channel

        self.handle = hal.initializeDIOPort(hal.getPort(channel), False)

        hal.report(hal.UsageReporting.kResourceType_DigitalOutput, channel)
        self.setName("DigitalOutput", channel)
    def __init__(self, channel, input):
        """
            :param channel: Port for the digital input
            :type  channel: int
            :param input: True if input, False otherwise
            :type  input: int
        """
        super().__init__()

        SensorBase.checkDigitalChannel(channel)
        self.channel = channel
        self._handle = hal.initializeDIOPort(hal.getPort(channel), input)

        try:
            DigitalSource.channels.allocate(self, channel)
        except IndexError as e:
            raise IndexError("Digital input %d is already allocated" % self.channel) from e

        self.__finalizer = weakref.finalize(self, _freeDigitalSource, self._handle)
Ejemplo n.º 5
0
    def __init__(self, channel, input):
        """
            :param channel: Port for the digital input
            :type  channel: int
            :param input: True if input, False otherwise
            :type  input: int
        """
        super().__init__()

        SensorBase.checkDigitalChannel(channel)
        self.channel = channel
        self._handle = hal.initializeDIOPort(hal.getPort(channel), input)

        try:
            DigitalSource.channels.allocate(self, channel)
        except IndexError as e:
            raise IndexError("Digital input %d is already allocated" % self.channel) from e

        self.__finalizer = weakref.finalize(self, _freeDigitalSource, self._handle)