One thing to keep in mind is that the playground web page mentions several different
i2c libraries. The main two are SoftI2CMaster and i2cMaster. They are not the same
and work very differently.
Neither is API compatible with the Wire library.
SoftI2CMaster is very fast but only supports s/w i2c.
i2cMaster supports both s/w and h/w i2c.
The example and API documentation on the playground page are for SoftI2CMaster.
Lewis1708:
I cannot understand what's being used to differentiate between xval and yval (as they both use "false"), and I don't get why he uses false for those two, and true for zval.
You are going to have to look at the actual code and read the API documentation for the library.
In that example code readOneVal(last) is not returning 1 byte but rather one 16 bit value
which is two 8 bit bytes which requires reading two bytes from the i2c bus:
int readOneVal(boolean last)
{
uint8_t msb, lsb;
lsb = i2c_read(false);
msb = i2c_read(last);
return (int)((msb<<8)|lsb)/64;
}
Then go read the API documentation (it is above the example code on that playground page)
i2c_read(last) takes a parameter which tells the library if the read is the last
read before the bus is to be released.
The other library:
i2cMaster, while not as fast for s/w i2c, is a bit more c++ like and supports both s/w and h/w i2c.
one advantage of i2cMaster is the API for h/w and the s/w i2c will be the same when using this library
since it supports both.
--- bill