|
@@ -85,6 +85,10 @@ class PinControllerBase(object):
|
|
|
pins = []
|
|
|
def __init__(self):
|
|
|
super(PinControllerBase, self).__init__()
|
|
|
+ def make_digital_pin(self,*args):
|
|
|
+ return DigitalPin(*args)
|
|
|
+ def make_analog_pin(self,*args):
|
|
|
+ return AnalogPin(*args)
|
|
|
|
|
|
class PCEngine(PinControllerBase):
|
|
|
"""Test Class"""
|
|
@@ -94,12 +98,10 @@ class PCEngine(PinControllerBase):
|
|
|
is_on = False
|
|
|
def __init__(self,pin_on_off,pin_analog):
|
|
|
super(PCEngine, self).__init__()
|
|
|
- self.pin_on_off = self.make_pin(pin_on_off)
|
|
|
- self.pin_analog = self.make_pin(pin_analog)
|
|
|
+ self.pin_on_off = self.make_digital_pin(pin_on_off)
|
|
|
+ self.pin_analog = self.make_digital_pin(pin_analog)
|
|
|
self.pins.append(self.pin_on_off)
|
|
|
self.pins.append(self.pin_analog)
|
|
|
- def make_pin(self,*args):
|
|
|
- return DigitalPin(*args)
|
|
|
def set_speed(self,speed):
|
|
|
self.pin_analog.output(speed)
|
|
|
self.speed = speed
|
|
@@ -107,7 +109,7 @@ class PCEngine(PinControllerBase):
|
|
|
"""state is boolean and specifies if the engine should be turned on (True) or turned off (False) """
|
|
|
if state == self.is_on:
|
|
|
return
|
|
|
- self.set_speed(speed)
|
|
|
+
|
|
|
self.pin_on_off.output(1)
|
|
|
self.is_on = state
|
|
|
|
|
@@ -120,6 +122,14 @@ class PinAPIBase(object):
|
|
|
def __init__(self):
|
|
|
super(PinAPIBase, self).__init__()
|
|
|
|
|
|
+class LED(DigitalPin):
|
|
|
+ def __init__(self,pin_number):
|
|
|
+ super(DigitalPin,self).__init__(pin_number)
|
|
|
+ def on(self):
|
|
|
+ self.output(True)
|
|
|
+ def off(self):
|
|
|
+ self.output(False)
|
|
|
+
|
|
|
|
|
|
|
|
|
|