INNER CODE UNIT · Python

_run

theyosh/TerrariumPI · hardware/button/__init__.py:87

    def _run(self) -> None:
        self._checker["running"] = 1
        while self._checker["running"]:
            new_state = self._get_state()
            if new_state != self._device["state"]:
                self._device["state"] = new_state
                if self.callback is not None:
                    self.callback(self.id, self.state)

            sleep(0.1)

    def _get_state(self):
        if isinstance(self._device["device"], terrariumIOExpander):
            # IO Expander in use
            state = self._device["device"].state
            if state is None:
                # Device in error...
                return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…