This question already has an answer here:
I am wondering what the second line of code does:
int16_t GyX; GyX=Wire.read()<<8|Wire.read();
Also, how can I write the GyX value to EEPROM?
From what I understand, int16_t is a two-bytes value. The Wire.read() returns a single byte. The <<8 shifts the bits by one byte to the left in order to read the higher order bits, and the last part writes the next wire read (lower order bits). Basically, reads wire twice and stores those values in the int. Is that correct?
For the writing, would
EEPROM.write(addr, GyX >> 8); EEPROM.write(addr, GyX & 0xff);
do the trick? (First line records the higher order bits, while second records the lower order ones)