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:
@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):
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
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)