# Add the parent directory to the module search path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from interface_board_pins.py import GPIO_DIGITAL_INPUTS # map of which GPIO pins are associated with which input terminal (1-8)

import RPi.GPIO as GPIO



# Initialize GPIO
GPIO.setmode(GPIO.BCM)
for pin in DIGITAL_INPUTS.values():
    GPIO.setup(pin, GPIO.IN)



# Repeatedly read GPIOs
print("Reading digital inputs:")
try:
    while True:
        for label, pin in DIGITAL_INPUTS.items():
            state = GPIO.input(pin)
            print(f"Input {label} (GPIO {pin}): {'HIGH' if state else 'LOW'}")
        print("-" * 40)

except KeyboardInterrupt:
    print("Exiting...")

finally:
    GPIO.cleanup()
