X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/81a5f9d72d1b3b5afb72cf460a9464e779c6144b..8bc681c3c82463095455e73e690156bf3a323821:/examples/pi_i2c.py diff --git a/examples/pi_i2c.py b/examples/pi_i2c.py deleted file mode 100644 index 6e8e0ac..0000000 --- a/examples/pi_i2c.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys -import time -sys.path.append('/home/pi/Adafruit_Micropython_Blinka/src') -sys.path.append('/home/pi/Adafruit_Python_GPIO') -sys.path.append('/home/pi/Adafruit_Python_PureIO') - -import board -import digitalio -import busio - -print("hello blinka!") - -i2c = busio.I2C(board.SCL, board.SDA) - -print("I2C devices found: ", [hex(i) for i in i2c.scan()]) - -if not 0x18 in i2c.scan(): - print("Didn't find MCP9808") - exit() - -def temp_c(data): - value = data[0] << 8 | data[1] - temp = (value & 0xFFF) / 16.0 - if value & 0x1000: - temp -= 256.0 - return temp - -while True: - i2c.writeto(0x18, bytes([0x05]), stop=False) - result = bytearray(2) - i2c.readfrom_into(0x18, result) - print(temp_c(result)) - time.sleep(0.5)