Esempio n. 1
0
    def updateDutyCycle(self, dutyCycle):
        """Change the duty-cycle that is being generated on the line.

        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 dutyCycle: The duty-cycle to change to. [0..1]
        :type  dutyCycle: float
        """
        if self.pwmGenerator is None:
            return
        hal.setPWMDutyCycle(self.pwmGenerator, dutyCycle)
Esempio n. 2
0
    def updateDutyCycle(self, dutyCycle):
        """Change the duty-cycle that is being generated on the line.

        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 dutyCycle: The duty-cycle to change to. [0..1]
        :type  dutyCycle: float
        """
        if self.pwmGenerator is None:
            return
        hal.setPWMDutyCycle(self.pwmGenerator, dutyCycle)
Esempio n. 3
0
    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.allocatePWM()
        hal.setPWMDutyCycle(self._pwmGenerator, initialDutyCycle)
        hal.setPWMOutputChannel(self._pwmGenerator, self.channel)
        self._pwmGenerator_finalizer = \
                weakref.finalize(self, _freePWMGenerator, self._pwmGenerator)
Esempio n. 4
0
    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.allocatePWM()
        hal.setPWMDutyCycle(self._pwmGenerator, initialDutyCycle)
        hal.setPWMOutputChannel(self._pwmGenerator, self.channel)
        self._pwmGenerator_finalizer = \
                weakref.finalize(self, _freePWMGenerator, self._pwmGenerator)