mirror of https://github.com/ArduPilot/ardupilot
fixed text encoding
git-svn-id: https://arducopter.googlecode.com/svn/trunk@352 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
parent
a81fad58b8
commit
a8b995ae1a
|
@ -1,41 +1,41 @@
|
||||||
/*
|
/*
|
||||||
Example of APM_Compass library (HMC5843 sensor).
|
Example of APM_Compass library (HMC5843 sensor).
|
||||||
Code by Jordi Muñoz and Jose Julio. DIYDrones.com
|
Code by Jordi MuÒoz and Jose Julio. DIYDrones.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <APM_Compass.h> // Compass Library
|
#include <APM_Compass.h> // Compass Library
|
||||||
|
|
||||||
#define ToDeg(x) (x*57.2957795131) // *180/pi
|
#define ToDeg(x) (x*57.2957795131) // *180/pi
|
||||||
|
|
||||||
unsigned long timer;
|
unsigned long timer;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
APM_Compass.Init(); // Initialization
|
APM_Compass.Init(); // Initialization
|
||||||
Serial.begin(57600);
|
Serial.begin(38400);
|
||||||
Serial.println("Compass library test (HMC5843)");
|
Serial.println("Compass library test (HMC5843)");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
timer = millis();
|
timer = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
float tmp;
|
float tmp;
|
||||||
|
|
||||||
if((millis()- timer) > 100)
|
if((millis()- timer) > 100)
|
||||||
{
|
{
|
||||||
timer = millis();
|
timer = millis();
|
||||||
APM_Compass.Read();
|
APM_Compass.Read();
|
||||||
APM_Compass.Calculate(0,0); // roll = 0, pitch = 0 for this example
|
APM_Compass.Calculate(0,0); // roll = 0, pitch = 0 for this example
|
||||||
Serial.print("Heading:");
|
Serial.print("Heading:");
|
||||||
Serial.print(ToDeg(APM_Compass.Heading));
|
Serial.print(ToDeg(APM_Compass.Heading));
|
||||||
Serial.print(" (");
|
Serial.print(" (");
|
||||||
Serial.print(APM_Compass.Mag_X);
|
Serial.print(APM_Compass.Mag_X);
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
Serial.print(APM_Compass.Mag_Y);
|
Serial.print(APM_Compass.Mag_Y);
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
Serial.print(APM_Compass.Mag_Z);
|
Serial.print(APM_Compass.Mag_Z);
|
||||||
Serial.println();
|
Serial.println(" )");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue