#!/usr/bin/env python3
#-*- coding: utf-8 -*-

import threading

import gpiozero
    
GPIO_BUTTON = 12

def my_callback():
    print('This is a edge event callback function!')
    print('This is run in a different thread to your main program')

# default Button, pull_up=True
button = gpiozero.Button(GPIO_BUTTON)

if button.is_pressed:
    print("pressed")
else:
    print("not pressed")

# add rising edge detection on a channel
button.when_pressed = my_callback

# keep the program running until ctrl-c is pressed
wait = threading.Event()
try:
    wait.wait()
except KeyboardInterrupt:
    pass

    
print("finished")
