from __future__ import print_function
import qwiic_gpio
import time
import sys
def runExample():
print("\nSparkFun Qwiic GPIO Example 2\n")
myGPIO = qwiic_gpio.QwiicGPIO()
if myGPIO.isConnected() == False:
print("The Qwiic GPIO isn't connected to the system. Please check your connection",
file=sys.stderr)
return
myGPIO.begin()
myGPIO.mode_0 = myGPIO.GPIO_IN
myGPIO.mode_1 = myGPIO.GPIO_IN
myGPIO.mode_2 = myGPIO.GPIO_IN
myGPIO.mode_3 = myGPIO.GPIO_IN
myGPIO.mode_4 = myGPIO.GPIO_IN
myGPIO.mode_5 = myGPIO.GPIO_IN
myGPIO.mode_6 = myGPIO.GPIO_IN
myGPIO.mode_7 = myGPIO.GPIO_IN
myGPIO.setMode()
while True:
myGPIO.getGPIO() #This function updates each in_status_x variable
print("GPIO 0:", end=" ")
print(myGPIO.in_status_0, end=" ")
print("GPIO 1:", end=" ")
print(myGPIO.in_status_1, end=" ")
print("GPIO 2:", end=" ")
print(myGPIO.in_status_2, end=" ")
print("GPIO 3:", end=" ")
print(myGPIO.in_status_3, end=" ")
print("GPIO 4:", end=" ")
print(myGPIO.in_status_4, end=" ")
print("GPIO 5:", end=" ")
print(myGPIO.in_status_5, end=" ")
print("GPIO 6:", end=" ")
print(myGPIO.in_status_6, end=" ")
print("GPIO 7:", end=" ")
print(myGPIO.in_status_7)
time.sleep(.25)
if __name__ == '__main__':
try:
runExample()
except (KeyboardInterrupt, SystemExit) as exErr:
print("\nEnding Example 1")
sys.exit(0)