power: improves GPIO initial_state handling

Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
This commit is contained in:
Pedro Lamas 2021-11-12 00:04:20 +00:00 committed by Eric Callahan
parent 7ff126a56e
commit a3ba4b4169
1 changed files with 4 additions and 2 deletions

View File

@ -478,10 +478,12 @@ class GpioDevice(PowerDevice):
if invert:
self.line.request(
consumer="moonraker", type=gpiod.LINE_REQ_DIR_OUT,
flags=gpiod.LINE_REQ_FLAG_ACTIVE_LOW)
flags=gpiod.LINE_REQ_FLAG_ACTIVE_LOW,
default_val=int(self.initial_state))
else:
self.line.request(
consumer="moonraker", type=gpiod.LINE_REQ_DIR_OUT)
consumer="moonraker", type=gpiod.LINE_REQ_DIR_OUT,
default_val=int(self.initial_state))
except Exception:
self.state = "error"
logging.exception(