X-Git-Url: https://git.linta.de/?p=~helmut%2Fonoff.git;a=blobdiff_plain;f=onoff%2Fgpio.py;h=954c6ffc2704eed29507d3daa3bc43a0035ca8a4;hp=bea9708f65cec1bbba73324db0c991f4dec375bc;hb=873cb2015c559466d35bda40f0fba8abbb4c8cb5;hpb=95d0112d57965feef06173c868cb4e72c2240ca8;ds=sidebyside diff --git a/onoff/gpio.py b/onoff/gpio.py index bea9708..954c6ff 100644 --- a/onoff/gpio.py +++ b/onoff/gpio.py @@ -1,6 +1,6 @@ import os.path -from .common import OnoffDevice, ST_ACTIVE +from .common import OnoffDevice, OnoffState def _write_file_value(path, content): with open(path, "w") as f: @@ -17,7 +17,7 @@ class OnoffGPIO(OnoffDevice): @param active_low: whether the GPIO should be inverted """ OnoffDevice.__init__(self) - self.current_state = 0 + self.current_state = OnoffState.inactive basedir = "/sys/class/gpio" self.gpiodir = "%s/gpio%d" % (basedir, gpionumber) if not os.path.isdir(self.gpiodir): @@ -28,7 +28,7 @@ class OnoffGPIO(OnoffDevice): def _set_state(self, state): self.current_state = state _write_file_value("%s/value" % self.gpiodir, - "1" if self.current_state == ST_ACTIVE else "0") + "1" if state == OnoffState.active else "0") self.changestate(self.current_state) @property @@ -36,7 +36,7 @@ class OnoffGPIO(OnoffDevice): return self.current_state def activate(self): - self._set_state(ST_ACTIVE) + self._set_state(OnoffState.active) def deactivate(self): - self._set_state(0) + self._set_state(OnoffState.inactive)