mirror of https://github.com/ArduPilot/ardupilot
uncrustify libraries/I2C/examples/HMC5883L/HMC5883L.pde
This commit is contained in:
parent
84847da218
commit
e1a905239e
|
@ -1,10 +1,10 @@
|
|||
/*******************************************
|
||||
Sample sketch that configures an HMC5883L 3 axis
|
||||
magnetometer to continuous mode and reads back
|
||||
the three axis of data.
|
||||
Code compiles to a size of 1500 bytes
|
||||
Equivalent Wire Library code compiles to 2032 bytes
|
||||
*******************************************/
|
||||
* Sample sketch that configures an HMC5883L 3 axis
|
||||
* magnetometer to continuous mode and reads back
|
||||
* the three axis of data.
|
||||
* Code compiles to a size of 1500 bytes
|
||||
* Equivalent Wire Library code compiles to 2032 bytes
|
||||
*******************************************/
|
||||
|
||||
#include <I2C.h>
|
||||
|
||||
|
@ -34,37 +34,37 @@ void loop()
|
|||
|
||||
|
||||
/* Wire library equivalent would be this
|
||||
|
||||
//#include <Wire.h>
|
||||
|
||||
#define HMC5883L 0x1E
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin();
|
||||
Wire.beginTransmission(HMC5883L);
|
||||
Wire.send(0x02);
|
||||
Wire.send(0x00);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Wire.beginTransmission(HMC5883L);
|
||||
Wire.send(0x03);
|
||||
Wire.endTransmission();
|
||||
Wire.requestFrom(HMC5883L,6);
|
||||
x = Wire.receive() << 8;
|
||||
x |= Wire.receive();
|
||||
y = Wire.receive() << 8;
|
||||
y |= Wire.receive();
|
||||
z = Wire.receive() << 8;
|
||||
z |= Wire.receive();
|
||||
}
|
||||
|
||||
********************************************/
|
||||
*
|
||||
* //#include <Wire.h>
|
||||
*
|
||||
* #define HMC5883L 0x1E
|
||||
*
|
||||
* int x = 0;
|
||||
* int y = 0;
|
||||
* int z = 0;
|
||||
*
|
||||
*
|
||||
* void setup()
|
||||
* {
|
||||
* Wire.begin();
|
||||
* Wire.beginTransmission(HMC5883L);
|
||||
* Wire.send(0x02);
|
||||
* Wire.send(0x00);
|
||||
* Wire.endTransmission();
|
||||
* }
|
||||
*
|
||||
* void loop()
|
||||
* {
|
||||
* Wire.beginTransmission(HMC5883L);
|
||||
* Wire.send(0x03);
|
||||
* Wire.endTransmission();
|
||||
* Wire.requestFrom(HMC5883L,6);
|
||||
* x = Wire.receive() << 8;
|
||||
* x |= Wire.receive();
|
||||
* y = Wire.receive() << 8;
|
||||
* y |= Wire.receive();
|
||||
* z = Wire.receive() << 8;
|
||||
* z |= Wire.receive();
|
||||
* }
|
||||
*
|
||||
********************************************/
|
||||
|
|
Loading…
Reference in New Issue