# read_word and read_word_2c from http://blog.bitify.co.uk/2013/11/reading-data-from-mpu-6050-on-raspberry.html defread_word(adr): high = bus.read_byte_data(ADDR, adr) low = bus.read_byte_data(ADDR, adr+1) val = (high << 8) + low return val
defread_word_2c(adr): val = read_word(adr) if (val >= 0x8000): return -((65535 - val) + 1) else: return val