|
@@ -40,27 +40,12 @@ class FakeGPIO(object):
|
|
|
try:
|
|
|
import RPi.GPIO as gpio
|
|
|
except:
|
|
|
- print(traceback.format_exc())
|
|
|
+ # print("Using FakeGPIO because RPi.GPIO was not found")
|
|
|
gpio = FakeGPIO()
|
|
|
|
|
|
log = logging.getLogger(__name__+"")
|
|
|
lpin = logging.getLogger(__name__+".pin")
|
|
|
|
|
|
-#
|
|
|
-# class PinBase(object):
|
|
|
-# """docstring for PinBase."""
|
|
|
-# # lockdir = "/var/lock/pins/"
|
|
|
-# lockdir = "lock/pins/"
|
|
|
-# pin_number = None
|
|
|
-# lockfile = lockdir + str(pin_number)
|
|
|
-# value_high = True
|
|
|
-# value_low = False
|
|
|
-# value = value_low
|
|
|
-# def __init__(self,pin_number):
|
|
|
-# super(PinBase,self).__init__()
|
|
|
-# self.pin_number = pin_number
|
|
|
-# self.lockfile = self.lockdir + str(self.pin_number)
|
|
|
-
|
|
|
class PinBase(object):
|
|
|
"""PinBase is the base class for all classes representing a gpio pin"""
|
|
|
pin_number = None
|
|
@@ -112,15 +97,6 @@ class PinControllerBase(object):
|
|
|
return DigitalPin(*args)
|
|
|
def make_analog_pin(self,*args):
|
|
|
return AnalogPin(*args)
|
|
|
- # def get_text_to_func(self):
|
|
|
- # """
|
|
|
- # ***description***
|
|
|
- # this function returns a dict {string:function,}. It is good practice that string is "<__module__><__name__><name of the api function>". This prevents duplicate names. The purpose of this dict is to provide access to the object's api methods.
|
|
|
- #
|
|
|
- # ***object.api_func vs text_to_func["api_func"]***
|
|
|
- # if a class or a function translates text commands to function calls, it is easier to use `text_to_func["api_func"]()`. However, if a class or function calls the api functions, it is better to use `api_object.api_function()`.
|
|
|
- # """
|
|
|
- # return {}
|
|
|
|
|
|
class PinAPIBase(object):
|
|
|
"""docstring for PinAPI.
|
|
@@ -158,31 +134,6 @@ class PCEngine(PinControllerBase):
|
|
|
# self.set_speed(speed)
|
|
|
self.pin_on_off.output(1)
|
|
|
self.is_on = state
|
|
|
- # async def turn(self,direction,*args,respond_method):
|
|
|
- # lpin.debug(args)
|
|
|
- # lpin.debug(threading.current_thread())
|
|
|
- # # with self ad
|
|
|
- # lpin.info("turning {}".format(direction))
|
|
|
- # right_state = self.engine_right.is_on
|
|
|
- # right_speed = self.engine_right.speed
|
|
|
- # left_state = self.engine_left.is_on
|
|
|
- # left_speed = self.engine_left.speed
|
|
|
- # if direction == "right":
|
|
|
- # self.engine_right.set_state(False)
|
|
|
- # self.engine_left.set_state(True)
|
|
|
- # self.engine_left.set_speed(1)
|
|
|
- # elif direction == "left":
|
|
|
- # self.engine_right.set_state(True)
|
|
|
- # self.engine_right.set_speed(1)
|
|
|
- # self.engine_left.set_state(False)
|
|
|
- # await curio.sleep(2)
|
|
|
- # # time.sleep(2)
|
|
|
- # self.engine_right.set_state(right_state)
|
|
|
- # self.engine_right.set_speed(right_speed)
|
|
|
- # self.engine_left.set_state(left_state)
|
|
|
- # self.engine_left.set_speed(left_speed)
|
|
|
- # lpin.info("done turning {}".format(direction))
|
|
|
- # # set engines to previous values
|
|
|
|
|
|
class EnginesController(PinAPIBase):
|
|
|
engine_left = None
|