#!/usr/bin/python3 -u

# https://roboticsbackend.com/raspberry-pi-gpio-interrupts-tutorial/

import signal
import sys
import RPi.GPIO as GPIO

if len(sys.argv) < 2:
    print("Usage: gpiomon PIN\nWhere PIN is a BCM pin number.")
    sys.exit()

BUTTON_GPIO = int(sys.argv[1])

def signal_handler(sig, frame):
    GPIO.cleanup()
    sys.exit(0)

def button_pressed_callback(channel):
    print("")

if __name__ == '__main__':
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(BUTTON_GPIO, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.add_event_detect(BUTTON_GPIO, GPIO.BOTH, 
            callback=button_pressed_callback, bouncetime=100)
    
    signal.signal(signal.SIGINT, signal_handler)
    signal.pause()
