From 761278b0273bc6199fc95653d707832c8faeba25 Mon Sep 17 00:00:00 2001 From: Giulio De Pasquale Date: Fri, 18 Aug 2017 14:42:34 +0200 Subject: [PATCH] debug mode --- calzelarm.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/calzelarm.py b/calzelarm.py index ad1bc40..e8d7edb 100644 --- a/calzelarm.py +++ b/calzelarm.py @@ -1,16 +1,36 @@ import RPi.GPIO as GPIO from time import sleep +import argparse + CHANNEL = 19 GPIO.setmode(GPIO.BOARD) -GPIO.setup(CHANNEL, GPIO.IN) +def debug(): + standby_for = 30 + while standby_for: + if GPIO.input(CHANNEL): + print('Input was HIGH') + else: + print('Input was LOW') + sleep(1) + standby_for -= 1 + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--debug', action='store_true', + help='Enables the DEBG opcode') + args = parser.parse_args() + + GPIO.setup(CHANNEL, GPIO.IN) + + if args.debug: + debug() + GPIO.cleanup() + +if __name__ == '__main__': + main() + + -while (True): - if GPIO.input(CHANNEL): - print('Input was HIGH') - else: - print('Input was LOW') - sleep(1) -GPIO.cleanup()