mirror of
https://github.com/barbeau/gpstest.git
synced 2025-12-05 18:46:30 -06:00
Initial work towards output on serial port
This commit is contained in:
@@ -117,6 +117,9 @@ dependencies {
|
||||
// Graphs for sliding drawer
|
||||
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
|
||||
|
||||
// Serial-over-USB output
|
||||
implementation 'com.github.felHR85:UsbSerial:6.0.6'
|
||||
|
||||
// Map (Google flavor only)
|
||||
googleImplementation 'com.google.android.gms:play-services-maps:16.1.0'
|
||||
// Calculating offset for camera target in map view (Google flavor only)
|
||||
|
||||
@@ -35,6 +35,8 @@ import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbDeviceConnection;
|
||||
import android.location.GnssMeasurement;
|
||||
import android.location.GnssMeasurementsEvent;
|
||||
import android.location.GnssNavigationMessage;
|
||||
@@ -80,6 +82,7 @@ import com.android.gpstest.util.MathUtils;
|
||||
import com.android.gpstest.util.PermissionUtils;
|
||||
import com.android.gpstest.util.PreferenceUtils;
|
||||
import com.android.gpstest.util.UIUtils;
|
||||
import com.felhr.usbserial.UsbSerialDevice;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -223,6 +226,10 @@ public class GpsTestActivity extends AppCompatActivity
|
||||
|
||||
private String mInitialLanguage;
|
||||
|
||||
UsbDevice mUsbDevice;
|
||||
UsbDeviceConnection mUsbConnection;
|
||||
UsbSerialDevice mSerial;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -293,6 +300,13 @@ public class GpsTestActivity extends AppCompatActivity
|
||||
(DrawerLayout) findViewById(R.id.nav_drawer_left_pane));
|
||||
}
|
||||
|
||||
private void setupSerialOverUsb() {
|
||||
mSerial = UsbSerialDevice.createUsbSerialDevice(mUsbDevice, mUsbConnection);
|
||||
if (mSerial != null) {
|
||||
mSerial.open();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
// Save current GPS started state
|
||||
@@ -320,6 +334,8 @@ public class GpsTestActivity extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
mBenchmarkController.onResume();
|
||||
|
||||
setupSerialOverUsb();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -441,6 +457,10 @@ public class GpsTestActivity extends AppCompatActivity
|
||||
gpsStop();
|
||||
}
|
||||
|
||||
if (mSerial != null) {
|
||||
mSerial.close();
|
||||
}
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@@ -1047,6 +1067,7 @@ public class GpsTestActivity extends AppCompatActivity
|
||||
if (mLogNmea) {
|
||||
writeNmeaToLog(message,
|
||||
mWriteNmeaTimestampToLog ? timestamp : Long.MIN_VALUE);
|
||||
mSerial.write(message.getBytes());
|
||||
}
|
||||
PreferenceUtils.saveInt(Application.get().getString(R.string.capability_key_nmea), PreferenceUtils.CAPABILITY_SUPPORTED);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,10 @@ buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url 'https://maven.google.com/'
|
||||
name 'Google'
|
||||
}
|
||||
maven { url "https://jitpack.io" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user