2016-10-22 20:38:24 +00:00
|
|
|
#include <Wire.h>
|
|
|
|
#include <LSM303.h>
|
|
|
|
|
|
|
|
LSM303 compass;
|
|
|
|
|
|
|
|
void setupCompass()
|
|
|
|
{
|
|
|
|
Wire.begin();
|
|
|
|
compass.init();
|
|
|
|
compass.enableDefault();
|
|
|
|
}
|
|
|
|
|
2016-10-24 19:43:59 +00:00
|
|
|
String getCompass()
|
2016-10-22 20:38:24 +00:00
|
|
|
{
|
2016-10-24 19:43:59 +00:00
|
|
|
String tmps;
|
|
|
|
compass.read();
|
2016-10-22 20:38:24 +00:00
|
|
|
|
2016-10-24 19:43:59 +00:00
|
|
|
tmps = String("compass.a.x=" ) + compass.a.x +
|
|
|
|
String(" compass.a.y=" ) + compass.a.y +
|
|
|
|
String(" compass.a.z=" ) + compass.a.z +
|
|
|
|
String(" compass.m.x=" ) + compass.m.x +
|
2016-10-27 16:14:29 +00:00
|
|
|
String(" compass.m.y=" ) + compass.m.y +
|
2016-10-24 19:43:59 +00:00
|
|
|
String(" compass.m.z=" ) + compass.m.z;
|
|
|
|
|
|
|
|
debugSerial.println(tmps);
|
|
|
|
|
2016-10-27 16:14:29 +00:00
|
|
|
return tmps;
|
2016-10-22 20:38:24 +00:00
|
|
|
}
|