Skip to content
Merged
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
44 changes: 23 additions & 21 deletions app/src/main/java/io/pslab/fragment/GyroscopeDataFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,10 @@ public void onResume() {
resetInstrumentData();
playRecordedData();
} else if (gyroSensor.viewingData) {
if (sensorManager != null) {
recordedGyroArray = new ArrayList<>();
resetInstrumentData();
plotAllRecordedData();
}
else {
gyroscopeViewFragments.clear();
rootView.findViewById(R.id.gyroscope_x_axis_fragment).setVisibility(View.INVISIBLE);
rootView.findViewById(R.id.gyroscope_y_axis_fragment).setVisibility(View.INVISIBLE);
rootView.findViewById(R.id.gyroscope_z_axis_fragment).setVisibility(View.INVISIBLE);
noSensorText.setText(getResources().getString(R.string.no_data_recorded_gyro));
noSensorText.setAllCaps(true);
gyroLinearLayout.addView(noSensorText);
}
recordedGyroArray = new ArrayList<>();
resetInstrumentData();
plotAllRecordedData();

} else if (!gyroSensor.isRecording) {
updateGraphs();
initiateGyroSensor();
Expand All @@ -150,8 +140,7 @@ public void onDestroyView() {
}
if (sensorManager != null) {
sensorManager.unregisterListener(gyroScopeSensorEventListener);
}
else {
} else {
gyroLinearLayout.removeView(noSensorText);
}
}
Expand Down Expand Up @@ -484,13 +473,26 @@ private void resetInstrumentData() {
private void initiateGyroSensor() {
resetInstrumentData();
sensorManager = (SensorManager) getContext().getSystemService(SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
if (sensor == null) {
Toast.makeText(getContext(), getResources().getString(R.string.no_gyroscope_sensor), Toast.LENGTH_LONG).show();
if (sensorManager == null) {
noSensorLayoutUpdate();
} else {
sensorManager.registerListener(gyroScopeSensorEventListener,
sensor, SensorManager.SENSOR_DELAY_FASTEST);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
if (sensor == null) {
Toast.makeText(getContext(), getResources().getString(R.string.no_gyroscope_sensor), Toast.LENGTH_LONG).show();
} else {
sensorManager.registerListener(gyroScopeSensorEventListener,
sensor, SensorManager.SENSOR_DELAY_FASTEST);
}
}
}

private void noSensorLayoutUpdate() {
gyroscopeViewFragments.clear();
rootView.findViewById(R.id.gyroscope_x_axis_fragment).setVisibility(View.GONE);
rootView.findViewById(R.id.gyroscope_y_axis_fragment).setVisibility(View.GONE);
rootView.findViewById(R.id.gyroscope_z_axis_fragment).setVisibility(View.GONE);
noSensorText.setText(getResources().getString(R.string.no_data_recorded_gyro));
noSensorText.setAllCaps(true);
gyroLinearLayout.addView(noSensorText);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
public class GyroscopeSettingsFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener {

public static final String KEY_INCLUDE_LOCATION = "include_location_sensor_data";
public static final String KEY_UPDATE_PERIOD = "setting_lux_update_period";
public static final String KEY_HIGH_LIMIT = "setting_lux_high_limit";
public static final String KEY_GYROSCOPE_SENSOR_GAIN = "setting_lux_sensor_gain";
public static final String KEY_UPDATE_PERIOD = "setting_gyro_update_period";
public static final String KEY_HIGH_LIMIT = "setting_gyro_high_limit";
public static final String KEY_GYROSCOPE_SENSOR_GAIN = "setting_gyro_sensor_gain";

private PSLabPermission psLabPermission;

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@
<string name="time_string_baro">Please provide time interval at which data will be updated (100 ms to 2000 ms)</string>
<string name="setting_baro_update">setting_baro_update_period</string>
<string name="setting_lux_update">setting_lux_update_period</string>
<string name="setting_gyro_update">setting_gyro_update_period</string>
<string name="setting_accelerometer_update">setting_accelerometer_update_period</string>
<string name="default_value_baro">1.10</string>
<string name="default_value_lux">1</string>
Expand All @@ -619,10 +620,12 @@
<string name="high_limit_msg">Entered High Limit is not within the limits!</string>
<string name="high_limit_baro">setting_baro_high_limit</string>
<string name="high_limit_lux">setting_lux_high_limit</string>
<string name="high_limit_gyro">setting_gyro_high_limit</string>
<string name="high_limit_acceleration">setting_accelerometer_high_limit</string>
<string name="setting_lux_type">setting_lux_sensor_type</string>
<string name="no_file_selected">No file was selected</string>
<string name="setting_lux_sensor_gain">setting_lux_sensor_gain</string>
<string name="setting_gyro_sensor_gain">setting_gyro_sensor_gain</string>
<string name="setting_accelerometer_sensor_gain">setting_accelerometer_sensor_gain</string>
<string name="set_gain_sensor">Please set gain of the sensor</string>
<string name="sensor_gain">Sensor Gain</string>
Expand Down