Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Bug fix #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ public void onSensorChanged(SensorEvent event) {
// Convert the heading (which is relative to magnetic north) to one that is
// relative to true north, using the user's current location to compute this.
float magneticHeading = (float) Math.toDegrees(mOrientation[0]);
mHeading = MathUtils.mod(computeTrueNorth(magneticHeading), 360.0f)
- ARM_DISPLACEMENT_DEGREES;
mHeading = MathUtils.mod(computeTrueNorth(magneticHeading), 360.0f) - ARM_DISPLACEMENT_DEGREES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using this should do the trick instead of the test block below:
mHeading = MathUtils.mod(computeTrueNorht(magneticHeading) - ARM_DISPLACEMENT_DEGREES, 360.0f);

Also, please make sure to follow Android's coding style standard:
https://source.android.com/source/code-style.html

Specifically, use spaces instead of tabs and keep the lines below 100 characters.


// The user was looking ~ due north (0 - 5.999 degrees)
if(mHeading < 0) {
mHeading = 360.0 + mHeading;
}

notifyOrientationChanged();
}
Expand Down