# Set the interrupt polarity to be active high and mirroring enabled, so
# pin 1 will trigger both INT A and INT B when a pin is grounded
io.set_interrupt_polarity(1)
io.mirror_interrupts(1)

# Set the interrupts default value to 0
io.set_interrupt_defaults(0, 0x00)
io.set_interrupt_defaults(1, 0x00)

# Set the interrupt type to be 1 for ports A and B so an interrupt is
# fired when a state change occurs
io.set_interrupt_type(0, 0x00)
io.set_interrupt_type(1, 0x00)

# Enable interrupts for pin 1
io.set_interrupt_on_port(0, 0x01)
io.set_interrupt_on_port(1, 0x00)

t = threading.Thread(target=background_thread)
t.daemon = True  # set thread to daemon ('ok' won't be printed in this case)
t.start()

while 1:
    """
        Do something in the main program loop while the interrupt checking is carried out in the background    
    """

    # wait 1 seconds
    time.sleep(1)
# Set the interrupt polarity to be active high and mirroring enabled, so
# pin 1 will trigger both INT A and INT B when a pin is grounded
io.set_interrupt_polarity(1)
io.mirror_interrupts(1)

# Set the interrupts default value to 0
io.set_interrupt_defaults(0, 0x00)
io.set_interrupt_defaults(1, 0x00)

# Set the interrupt type to be 1 for ports A and B so an interrupt is
# fired when a state change occurs
io.set_interrupt_type(0, 0x00)
io.set_interrupt_type(1, 0x00)

# Enable interrupts for pin 1
io.set_interrupt_on_port(0, 0x01)
io.set_interrupt_on_port(1, 0x00)


t=threading.Thread(target=background_thread)
t.daemon = True  # set thread to daemon ('ok' won't be printed in this case)
t.start()


while 1:
    """
        Do something in the main program loop while the interrupt checking is carried out in the background    
    """
    
    # wait 1 seconds
    time.sleep(1)