コード例 #1
0
ファイル: DigiPotX9Cxxx.py プロジェクト: elishare/nanpy
 def set(self, value):
     value = constrain(value, 0, DIGIPOT_MAX_AMOUNT)
     if self._currentValue is None:
         self.reset()
     if self._currentValue > value:
         self.change(-1, self._currentValue - value)
     elif self._currentValue < value:
         self.change(1, value - self._currentValue)
コード例 #2
0
ファイル: DigiPotX9Cxxx.py プロジェクト: zoloft/nanpy
 def set(self, value):
     value = constrain(value, 0, DIGIPOT_MAX_AMOUNT)
     if self._currentValue is None:
         self.reset()
     if self._currentValue > value:
         self.change(-1, self._currentValue - value)
     elif self._currentValue < value:
         self.change(1, value - self._currentValue)
コード例 #3
0
ファイル: DigiPotX9Cxxx.py プロジェクト: zoloft/nanpy
    def change(self, direction, amount):
        if direction == 1:
            ud = HIGH
        elif direction == -1:
            ud = LOW
        else:
            raise ValueError('invalid direction: %s', direction)

        amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT)
        if amount == 0:
            return

        if self._udLastValue != ud:
            self._udPin.write_digital_value(ud)

        for _ in range(amount):
            self._incPin.write_digital_value(LOW)
            self._incPin.write_digital_value(HIGH)
            if self._currentValue is not None:
                self._currentValue += direction
                self._currentValue = constrain(self._currentValue, 0,
                                               DIGIPOT_MAX_AMOUNT)
コード例 #4
0
ファイル: DigiPotX9Cxxx.py プロジェクト: elishare/nanpy
    def change(self, direction, amount):
        if direction == 1:
            ud = HIGH
        elif direction == -1:
            ud = LOW
        else:
            raise ValueError('invalid direction: %s', direction)

        amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT)
        if amount == 0:
            return

        if self._udLastValue != ud:
            self._udPin.write_digital_value(ud)

        for _ in range(amount):
            self._incPin.write_digital_value(LOW)
            self._incPin.write_digital_value(HIGH)
            if self._currentValue is not None:
                self._currentValue += direction
                self._currentValue = constrain(
                    self._currentValue,
                    0,
                    DIGIPOT_MAX_AMOUNT)
コード例 #5
0
ファイル: DigiPotX9Cxxx.py プロジェクト: elishare/nanpy
 def decrease(self, amount):
     amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT)
     self.change(-1, amount)
コード例 #6
0
ファイル: DigiPotX9Cxxx.py プロジェクト: zoloft/nanpy
 def decrease(self, amount):
     amount = constrain(amount, 0, DIGIPOT_MAX_AMOUNT)
     self.change(-1, amount)