mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-12-08 20:39:01 +00:00
Clean up repeated string substitutions
This commit is contained in:
@@ -84,7 +84,7 @@ class RPiGPIOPin(LocalPiPin):
|
||||
|
||||
def __init__(self, factory, number):
|
||||
super(RPiGPIOPin, self).__init__(factory, number)
|
||||
self._pull = 'up' if factory.pi_info.pulled_up('GPIO%d' % number) else 'floating'
|
||||
self._pull = 'up' if factory.pi_info.pulled_up(self.address[-1]) else 'floating'
|
||||
self._pwm = None
|
||||
self._frequency = None
|
||||
self._duty_cycle = None
|
||||
@@ -103,7 +103,7 @@ class RPiGPIOPin(LocalPiPin):
|
||||
GPIO.setup(self.number, GPIO.OUT, initial=state)
|
||||
|
||||
def input_with_pull(self, pull):
|
||||
if pull != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number):
|
||||
if pull != 'up' and self.factory.pi_info.pulled_up(self.address[-1]):
|
||||
raise PinFixedPull('%r has a physical pull-up resistor' % self)
|
||||
try:
|
||||
GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[pull])
|
||||
@@ -149,7 +149,7 @@ class RPiGPIOPin(LocalPiPin):
|
||||
def _set_pull(self, value):
|
||||
if self.function != 'input':
|
||||
raise PinFixedPull('cannot set pull on non-input pin %r' % self)
|
||||
if value != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number):
|
||||
if value != 'up' and self.factory.pi_info.pulled_up(self.address[-1]):
|
||||
raise PinFixedPull('%r has a physical pull-up resistor' % self)
|
||||
try:
|
||||
GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[value])
|
||||
|
||||
Reference in New Issue
Block a user