From 40ee611f33b32de226687bdec17989a1c138f7e9 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Thu, 23 Apr 2015 10:28:04 -0400 Subject: [PATCH] Use GPIO.HIGH and GPIO.LOW for ON and OFF It's even more obvious than 1 and 0! Signed-off-by: Anna Schumaker --- doors.py | 5 ++--- simulator/RPi/GPIO.py | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doors.py b/doors.py index 012f6fb..da4aba5 100755 --- a/doors.py +++ b/doors.py @@ -49,9 +49,8 @@ GPIO.setup(GREEN_LED, GPIO.OUT) GPIO.setup(YELLOW_LED, GPIO.OUT) -#Be explicit with what we want -OFF = 0 # Low voltage, ground -ON = 1 # High voltage +OFF = GPIO.LOW +ON = GPIO.HIGH def unlock_door(): diff --git a/simulator/RPi/GPIO.py b/simulator/RPi/GPIO.py index de9026b..90b57cc 100644 --- a/simulator/RPi/GPIO.py +++ b/simulator/RPi/GPIO.py @@ -3,12 +3,14 @@ print("Using fake GPIO driver.") BOARD = "board" IN = "input" OUT = "output" +HIGH = 1 +LOW = 0 def cleanup(): print("> GPIO: cleaning up!") def output(pin, voltage): - state = "on" if (voltage == 1) else "off" + state = "ON" if (voltage == HIGH) else "OFF" print("> GPIO setting pin %s to %s." % (pin, state)) def setmode(mode):