gpio: only setmode if it hasn't been set yet

This commit is contained in:
2023-10-29 20:56:03 -03:00
parent 11b2c845ac
commit 7df3639923
4 changed files with 17 additions and 14 deletions

View File

@@ -11,7 +11,8 @@ class Encoder:
_curr_steps: int = 0
def setup(self):
gpio.setmode(gpio.BCM)
if not gpio.getmode():
gpio.setmode(gpio.BCM)
gpio.setup(self.pin_a, gpio.IN)
gpio.setup(self.pin_b, gpio.IN)