Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of mag_sensor by
Revision 2:8ba36609face, committed 2018-08-12
- Comitter:
- ponpoko1939
- Date:
- Sun Aug 12 08:28:02 2018 +0000
- Parent:
- 1:21ba826811d6
- Commit message:
- ver?
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Aug 12 06:34:00 2018 +0000
+++ b/main.cpp Sun Aug 12 08:28:02 2018 +0000
@@ -76,8 +76,11 @@
pc.printf("%f,%f\n\r", magX, magY);
//ID = IDcheck();
//pc.printf("%f\n\r", ID);
- rad = atan2(magZ * sin(roll) - magY * cos(roll), magX * cos(pitch) + magY * sin(pitch) * sin(roll) + magZ * sin(pitch) * cos(roll));
- degree = -((int)(rad * 180.0 / 3.141592 + 270.0 - 7.5) % 360 - 360.0);
+ double y_houi = magZ * sin(roll) - magY * cos(roll);
+ double x_houi = magX * cos(pitch) + magY * sin(pitch) * sin(roll) + magZ * sin(pitch) * cos(roll);
+ double num = y_houi / x_houi;
+ rad = atan(num);
+ degree = -((int)(rad * 360.0 / 3.141592 + 270.0 - 7.5) % 360 - 360.0);
/*
if(degree < 0){
degree += 360;
