diff --git a/pingo/parts/button.py b/pingo/parts/button.py index ddc362c..642baaa 100644 --- a/pingo/parts/button.py +++ b/pingo/parts/button.py @@ -1,3 +1,5 @@ +import pingo + import time import threading @@ -10,7 +12,7 @@ def __init__(self, pin): :param pin: A instance of DigitalPin """ self.pin = pin - self.pin.mode = 'IN' + self.pin.mode = pingo.IN self.polling_task = None self._up_callback = lambda: None self._down_callback = lambda: None @@ -56,10 +58,10 @@ def run(self): while self.active: current_state = self.switch.pin.state if current_state != last_state: - if current_state == 'HIGH': + if current_state == pingo.HIGH: last_state = current_state self.switch._up_callback() - elif current_state == 'LOW': + elif current_state == pingo.LOW: last_state = current_state self.switch._down_callback() time.sleep(0.05) diff --git a/pingo/parts/test/test_switch.py b/pingo/parts/test/test_switch.py index 085e433..f369a29 100644 --- a/pingo/parts/test/test_switch.py +++ b/pingo/parts/test/test_switch.py @@ -1,3 +1,4 @@ +import pingo import time import unittest @@ -6,8 +7,8 @@ class FakeDigitalPin(object): def __init__(self): - self.mode = 'IN' - self.state = 'LOW' + self.mode = pingo.IN + self.state = pingo.LOW class TestSwitch(unittest.TestCase): @@ -23,11 +24,11 @@ def callback_down(): self.my_switch.start() time.sleep(.1) - self.pin.state = 'HIGH' + self.pin.state = pingo.HIGH time.sleep(.1) - self.pin.state = 'LOW' + self.pin.state = pingo.LOW time.sleep(.1) - self.pin.state = 'HIGH' + self.pin.state = pingo.HIGH time.sleep(.1) self.my_switch.stop() @@ -45,11 +46,11 @@ def callback_up(): self.my_switch.start() time.sleep(.1) - self.pin.state = 'HIGH' + self.pin.state = pingo.HIGH time.sleep(.1) - self.pin.state = 'LOW' + self.pin.state = pingo.LOW time.sleep(.1) - self.pin.state = 'HIGH' + self.pin.state = pingo.HIGH time.sleep(.1) self.my_switch.stop()