+ return Pin._check_result(lgpio.gpio_read(CHIP, self.id))
+
+ @staticmethod
+ def _check_result(result):
+ """
+ convert any result other than zero to a text message and pass it back
+ as a runtime exception. Typical usage: use the lgpio call as the
+ argument.
+ """
+ if result < 0:
+ raise RuntimeError(lgpio.error_text(result))
+ return result
+
+ def _set_gpio_mode_in(self, lflags=0):
+ """
+ claim a gpio as input, or modify the flags (PULL_UP, PULL_DOWN, ... )
+ """
+ # This gpio_free may seem redundant, but is required when
+ # changing the line-flags of an already acquired input line
+ try:
+ lgpio.gpio_free(CHIP, self.id)
+ except lgpio.error:
+ pass
+ Pin._check_result(lgpio.gpio_claim_input(CHIP, self.id, lFlags=lflags))