|
@@ -36,42 +36,6 @@ ERROR_TAKES_ARGUMENTS = "{} takes {} {} argument(s): {}"
|
|
|
_pins_for_cleanup = set()
|
|
|
_gpio = None
|
|
|
|
|
|
-def _make_gpio_warpper():
|
|
|
- _gpio = GPIOWrapper()
|
|
|
-
|
|
|
-# class FakeGPIO(object):
|
|
|
-# OUT = "out"
|
|
|
-# IN = "in"
|
|
|
-# BCM = "broadcom"
|
|
|
-# pin_values = {}
|
|
|
-# def cleanup(self,*args):
|
|
|
-# lgpio.debug("cleanup with these args '{}'!".format(args))
|
|
|
-# def setup(self,pins,value):
|
|
|
-# lgpio.debug("pin(s) {} set to {}".format(pins,value))
|
|
|
-# def setmode(self,mode):
|
|
|
-# lgpio.debug("mode set to {}".format(mode))
|
|
|
-# def output(self,pins,value):
|
|
|
-# lgpio.debug("setting pin(s) {} to value {}".format(
|
|
|
-# pins, value
|
|
|
-# ))
|
|
|
-# if type(pins) == int:
|
|
|
-# pins = [pins]
|
|
|
-# for p in pins:
|
|
|
-# self.pin_values[p] = value
|
|
|
-# def read(self,pin):
|
|
|
-# return self.pin_values[pin]
|
|
|
-#
|
|
|
-# try:
|
|
|
-# import RPi.GPIO as gpio
|
|
|
-# except:
|
|
|
-# # print("Using FakeGPIO because RPi.GPIO was not found")
|
|
|
-# gpio = FakeGPIO()
|
|
|
-#
|
|
|
-# def call_gpio_cleanup(*args):
|
|
|
-# log.info(args)
|
|
|
-# gpio.cleanup(_pins_for_cleanup)
|
|
|
-
|
|
|
-
|
|
|
class GPIOWrapper(object):
|
|
|
gpio = None
|
|
|
OUT = "out"
|
|
@@ -153,14 +117,14 @@ class GPIOWrapper(object):
|
|
|
if self.gpio:
|
|
|
self.gpio.setup(pins,value)
|
|
|
|
|
|
+_gpio = GPIOWrapper()
|
|
|
+
|
|
|
class PinBase(object):
|
|
|
"""PinBase is the base class for all classes representing a gpio pin"""
|
|
|
pin_number = None
|
|
|
value = None
|
|
|
def __init__(self,pin_number,mode):
|
|
|
super(PinBase,self).__init__()
|
|
|
- if _gpio == None:
|
|
|
- _make_gpio_warpper()
|
|
|
self.pin_number = pin_number
|
|
|
self.value = self.value_low
|
|
|
_gpio.setup(self.pin_number,_gpio.OUT)
|