Exemple #1
0
    def disablePWM(self):
        """Change this line from a PWM output back to a static Digital Output
        line.

        Free up one of the 6 DO PWM generator resources that were in use.
        """
        if self.pwmGenerator is not self.invalidPwmGenerator:
            return
        hal.setDigitalPWMOutputChannel(self._pwmGenerator, SensorUtil.kDigitalChannels)
        hal.freeDigitalPWM(self._pwmGenerator)
        self._pwmGenerator_finalizer()
    def disablePWM(self) -> None:
        """Change this line from a PWM output back to a static Digital Output
        line.

        Free up one of the 6 DO PWM generator resources that were in use.
        """
        if self.pwmGenerator is not self.invalidPwmGenerator:
            return
        hal.setDigitalPWMOutputChannel(self.pwmGenerator, SensorUtil.kDigitalChannels)
        hal.freeDigitalPWM(self.pwmGenerator)
        self._pwmGenerator_finalizer()
Exemple #3
0
    def enablePWM(self, initialDutyCycle: float) -> None:
        """Enable a PWM Output on this line.

        Allocate one of the 6 DO PWM generator resources.

        Supply the initial duty-cycle to output so as to avoid a glitch when
        first starting.

        The resolution of the duty cycle is 8-bit for low frequencies (1kHz or
        less) but is reduced the higher the frequency of the PWM signal is.

        :param initialDutyCycle: The duty-cycle to start generating. [0..1]
        """
        if self.pwmGenerator is not self.invalidPwmGenerator:
            return
        self._pwmGenerator = hal.allocateDigitalPWM()
        hal.setDigitalPWMDutyCycle(self._pwmGenerator, initialDutyCycle)
        hal.setDigitalPWMOutputChannel(self._pwmGenerator, self.channel)
        self._pwmGenerator_finalizer = weakref.finalize(
            self, _freePWMGenerator, self._pwmGenerator)
    def enablePWM(self, initialDutyCycle):
        """Enable a PWM Output on this line.

        Allocate one of the 6 DO PWM generator resources.

        Supply the initial duty-cycle to output so as to avoid a glitch when
        first starting.

        The resolution of the duty cycle is 8-bit for low frequencies (1kHz or
        less) but is reduced the higher the frequency of the PWM signal is.

        :param initialDutyCycle: The duty-cycle to start generating. [0..1]
        :type  initialDutyCycle: float
        """
        if self.pwmGenerator is not None:
            return
        self._pwmGenerator = hal.allocateDigitalPWM()
        hal.setDigitalPWMDutyCycle(self._pwmGenerator, initialDutyCycle)
        hal.setDigitalPWMOutputChannel(self._pwmGenerator, self.channel)
        self._pwmGenerator_finalizer = \
                weakref.finalize(self, _freePWMGenerator, self._pwmGenerator)
Exemple #5
0
def _freePWMGenerator(pwmGenerator):
    # Disable the output by routing to a dead bit.
    hal.setDigitalPWMOutputChannel(pwmGenerator, SensorUtil.kDigitalChannels)
    hal.freeDigitalPWM(pwmGenerator)
def _freePWMGenerator(pwmGenerator):
    # Disable the output by routing to a dead bit.
    hal.setDigitalPWMOutputChannel(pwmGenerator, SensorBase.kDigitalChannels)
    hal.freeDigitalPWM(pwmGenerator)