def _disable_event_detect(self): if self._callback is not None: self._callback.cancel() self._callback = None lgpio.gpio_claim_input( self.factory._handle, self.number, lgpio.gpio_get_mode(self.factory._handle, self.number) & self.GPIO_LINE_FLAGS_MASK)
def __init__(self, factory, number): super().__init__(factory, number) self._pwm = None self._bounce = None self._callback = None self._edges = lgpio.BOTH_EDGES lgpio.gpio_claim_input(self.factory._handle, self.number, lgpio.SET_BIAS_DISABLE)
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(repr(self)): raise PinFixedPull('%r has a physical pull-up resistor' % self) try: flags = { 'up': lgpio.SET_BIAS_PULL_UP, 'down': lgpio.SET_BIAS_PULL_DOWN, 'floating': lgpio.SET_BIAS_DISABLE, }[value] except KeyError: raise PinInvalidPull('invalid pull "%s" for pin %r' % (value, self)) else: # Simply calling gpio_claim_input is insufficient to change the # line flags on a pin; it needs to be freed and re-claimed lgpio.gpio_free(self.factory._handle, self.number) lgpio.gpio_claim_input(self.factory._handle, self.number, flags)
def close(self): if self.factory._handle is not None: # Closing is really just "resetting" the function of the pin; # we let the factory close deal with actually freeing stuff lgpio.gpio_claim_input(self.factory._handle, self.number, lgpio.SET_BIAS_DISABLE)
status = sbc.gpio_set_debounce_micros(9999, 8888, 6000000) check("gpio_set_debounce_micros 1", sbc.BAD_DEBOUNCE_MICS, status) status = sbc.gpio_set_debounce_micros(9999, 8888, 600) check("gpio_set_debounce_micros 2", sbc.BAD_HANDLE, status) status = sbc.gpio_set_watchdog_micros(9999, 8888, 400000000) check("gpio_set_watchdog_micros 1", sbc.BAD_WATCHDOG_MICS, status) status = sbc.gpio_set_watchdog_micros(9999, 8888, 4000) check("gpio_set_watchdog_micros 2", sbc.BAD_HANDLE, status) status = sbc.gpio_claim_alert(9999, 8888, 7777, 6666, 5555) check("gpio_claim_alert 1", sbc.BAD_HANDLE, status) status = sbc.gpio_claim_input(9999, 8888) check("gpio_claim_input 1", sbc.BAD_HANDLE, status) status = sbc.group_claim_input(9999, [8888, 7777, 6666]) check("group_claim_input 1", sbc.BAD_HANDLE, status) status = sbc.gpio_claim_output(9999, 8888, 7777) check("gpio_claim_output 1", sbc.BAD_HANDLE, status) status = sbc.group_claim_output(9999, [8888, 7777, 6666]) check("group_claim_output 1", sbc.BAD_HANDLE, status) status = sbc.gpio_write(9999, 8888, 7777) check("gpio_write 1", sbc.BAD_HANDLE, status) err = sbc.error_text(0)