Due: Wire.write(int) throws away information
I noticed this when browsing the Wire.h source for the Arduino Due:
inline size_t write(unsigned long n) { return write((uint8_t)n); }
inline size_t write(long n) { return write((uint8_t)n); }
inline size_t write(unsigned int n) { return write((uint8_t)n); }
inline size_t write(int n) { return write((uint8_t)n); }
Isn't this blind casting throwing away important parts of the number? Seems to me that this could be very confusing to people when their code isn't sending their I2C device the numbers they feed it. I'm guessing these are in there to make it easy for beginners, but it's not going to make it easy, just make it harder to debug.
I propose removing them, so people have to purposefully cast and throw away the extra bytes, or implementing versions that send all the bytes separately. Of course, with the latter, then you have to worry about Endianness and I'm not sure we should be making that decision for the user.
This issue also applies to AVR: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/Wire/Wire.h#L75