uncrustify libraries/I2C/examples/HMC5883L/HMC5883L.pde

This commit is contained in:
uncrustify 2012-08-16 23:22:38 -07:00 committed by Pat Hickey
parent 84847da218
commit e1a905239e
1 changed files with 51 additions and 51 deletions

View File

@ -1,14 +1,14 @@
/******************************************* /*******************************************
Sample sketch that configures an HMC5883L 3 axis * Sample sketch that configures an HMC5883L 3 axis
magnetometer to continuous mode and reads back * magnetometer to continuous mode and reads back
the three axis of data. * the three axis of data.
Code compiles to a size of 1500 bytes * Code compiles to a size of 1500 bytes
Equivalent Wire Library code compiles to 2032 bytes * Equivalent Wire Library code compiles to 2032 bytes
*******************************************/ *******************************************/
#include <I2C.h> #include <I2C.h>
#define HMC5883L 0x1E #define HMC5883L 0x1E
int x = 0; int x = 0;
int y = 0; int y = 0;
@ -17,54 +17,54 @@ int z = 0;
void setup() void setup()
{ {
I2c.begin(); I2c.begin();
I2c.write(HMC5883L,0x02,0x00); //configure device for continuous mode I2c.write(HMC5883L,0x02,0x00); //configure device for continuous mode
} }
void loop() void loop()
{ {
I2c.read(HMC5883L,0x03,6); //read 6 bytes (x,y,z) from the device I2c.read(HMC5883L,0x03,6); //read 6 bytes (x,y,z) from the device
x = I2c.receive() << 8; x = I2c.receive() << 8;
x |= I2c.receive(); x |= I2c.receive();
y = I2c.receive() << 8; y = I2c.receive() << 8;
y |= I2c.receive(); y |= I2c.receive();
z = I2c.receive() << 8; z = I2c.receive() << 8;
z |= I2c.receive(); z |= I2c.receive();
} }
/* Wire library equivalent would be this /* Wire library equivalent would be this
*
//#include <Wire.h> * //#include <Wire.h>
*
#define HMC5883L 0x1E * #define HMC5883L 0x1E
*
int x = 0; * int x = 0;
int y = 0; * int y = 0;
int z = 0; * int z = 0;
*
*
void setup() * void setup()
{ * {
Wire.begin(); * Wire.begin();
Wire.beginTransmission(HMC5883L); * Wire.beginTransmission(HMC5883L);
Wire.send(0x02); * Wire.send(0x02);
Wire.send(0x00); * Wire.send(0x00);
Wire.endTransmission(); * Wire.endTransmission();
} * }
*
void loop() * void loop()
{ * {
Wire.beginTransmission(HMC5883L); * Wire.beginTransmission(HMC5883L);
Wire.send(0x03); * Wire.send(0x03);
Wire.endTransmission(); * Wire.endTransmission();
Wire.requestFrom(HMC5883L,6); * Wire.requestFrom(HMC5883L,6);
x = Wire.receive() << 8; * x = Wire.receive() << 8;
x |= Wire.receive(); * x |= Wire.receive();
y = Wire.receive() << 8; * y = Wire.receive() << 8;
y |= Wire.receive(); * y |= Wire.receive();
z = Wire.receive() << 8; * z = Wire.receive() << 8;
z |= Wire.receive(); * z |= Wire.receive();
} * }
*
********************************************/ ********************************************/