From cb4a591c8fc18c91fbc4910fce4c18da264bbfbf Mon Sep 17 00:00:00 2001 From: scls19fr Date: Wed, 20 Jan 2016 14:31:05 +0100 Subject: [PATCH 1/2] Update button.py Remove string for IN HIGH LOW --- pingo/parts/button.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) From f900442ef510530f5bb34865d5492f5af32ab635 Mon Sep 17 00:00:00 2001 From: scls19fr Date: Wed, 20 Jan 2016 14:41:29 +0100 Subject: [PATCH 2/2] Update test_switch.py Change 'HIGH' 'LOW' 'IN' to pingo.HIGH pingo.LOW pingo.IN --- pingo/parts/test/test_switch.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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()