from time import sleep_ms
def getData(i2c , addr=96):
  i2c.writeto_mem(addr, 18, b'\x00')
  sleep_ms(10)
  data = i2c.readfrom_mem(addr, 4, 8)   
  A0 = (data[0] * 256 + data[1]) / 8.0
  B1 = (data[2] * 256 + data[3])
  if B1 > 32767 :
    B1 -= 65536
  B1 = B1 / 8192.0
  B2 = (data[4] * 256 + data[5])
  if B2 > 32767 :
    B2 -= 65535
  B2 = B2 / 16384.0
  C12 = ((data[6] * 256 + data[7]) / 4) / 4194304.0

  # pres MSB, pres LSB, temp MSB, temp LSB
  data2 = i2c.readfrom_mem(addr, 0, 4)

  pres = ((data2[0] * 256) + (data2[1] & 0xC0)) / 64
  temp = ((data2[2] * 256) + (data2[3] & 0xC0)) / 64
  presComp = A0 + (B1 + C12 * temp) * pres + B2 * temp

  # Convert the data
  pressure = (65.0 / 1023.0) * presComp + 50
  cTemp = (temp - 498) / (-5.35) + 25
  return  pressure,cTemp;
  
print ("Command use: MPL115A2.getData(i2c,addr=96)")
print ("Returns ( P_kpa , T_*C )")