from __future__ import print_function
import qwiic_gpio
import time
import sys
def runExample():
print("\nSparkFun Qwiic GPIO Example 3\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()
myGPIO.inversion_0 = myGPIO.INVERT
myGPIO.inversion_1 = myGPIO.NO_INVERT
myGPIO.inversion_2 = myGPIO.INVERT
myGPIO.inversion_3 = myGPIO.NO_INVERT
myGPIO.inversion_4 = myGPIO.INVERT
myGPIO.inversion_5 = myGPIO.NO_INVERT
myGPIO.inversion_6 = myGPIO.INVERT
myGPIO.inversion_7 = myGPIO.NO_INVERT
myGPIO.setInversion()
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=" ")