Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PFD improvements #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 16 additions & 2 deletions app/src/main/java/com/ds/avare/PfdActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@
import android.location.Location;
import android.os.Bundle;
import android.os.IBinder;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;

import com.ds.avare.adsb.Traffic;
import com.ds.avare.gps.GpsInterface;
import com.ds.avare.orientation.OrientationInterface;
import com.ds.avare.storage.Preferences;
import com.ds.avare.utils.Helper;
import com.ds.avare.views.PfdView;

import static com.ds.avare.place.Destination.GPS;

/**
* @author zkhan
*/
Expand Down Expand Up @@ -73,6 +77,7 @@ public void locationCallback(Location location) {
double bearing = 0;
double cdi = 0;
double vdi = 0;
String dst = "", distance = "";

if(mService.getVNAV() != null) {
vdi = mService.getVNAV().getGlideSlope();
Expand All @@ -85,8 +90,15 @@ public void locationCallback(Location location) {
}
if(mService.getDestination() != null) {
bearing = mService.getDestination().getBearing();
dst = mService.getDestination().getDbType()==GPS ? "GPS" : mService.getDestination().getID();
distance = Math.round(mService.getDestination().getDistance()*10.0) / 10.0 + mPref.distanceConversionUnit;
}
mPfdView.setParams(mService.getGpsParams(), mService.getExtendedGpsParams(), bearing, cdi, vdi, dst, distance);

if(mService.getTrafficCache() != null) {
SparseArray<Traffic> traffic = mService.getTrafficCache().getTraffic();
mPfdView.setTraffic(traffic);
}
mPfdView.setParams(mService.getGpsParams(), mService.getExtendedGpsParams(), bearing, cdi, vdi);
mPfdView.postInvalidate();
}

Expand All @@ -106,7 +118,9 @@ public void enabledCallback(boolean enabled) {
public void onSensorChanged(double yaw, double pitch, double roll, double acceleration) {
mPfdView.setPitch(-(float)pitch);
mPfdView.setRoll(-(float)roll);
mPfdView.setYaw((float)yaw);
if (mPref.isPfdUsingPhoneMagneticHeading()) {
mPfdView.setYaw((float) yaw);
}
mPfdView.setAcceleration(acceleration);
mPfdView.postInvalidate();
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/ds/avare/storage/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,8 @@ public boolean isVerticalPfd() {
return mPref.getBoolean(mContext.getString(R.string.VerticalPfd), false);
}

public boolean isPfdUsingPhoneMagneticHeading() { return mPref.getBoolean(mContext.getString(R.string.PfdUsesPhoneMagneticHeading), false); }

public int getWindsAloftCeiling() {
try {
return Integer.parseInt(mPref.getString(mContext.getString(R.string.WindsAloftCeiling), "39"));
Expand Down
Loading