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
2 changes: 1 addition & 1 deletion app/src/main/java/io/pslab/activity/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) {
case PSLabSensor.GYROSCOPE_CONFIGURATIONS:
fragment = new GyroscopeSettingsFragment();
break;
case PSLabSensor.ACCELEROMETER:
case PSLabSensor.ACCELEROMETER_CONFIGURATIONS:
fragment = new AccelerometerSettingsFragment();
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
holder.sensor.setText(context.getResources().getString(R.string.compass));
holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_compass_log));
break;
case PSLabSensor.ACCELEROMETER:
case PSLabSensor.ACCELEROMETER_CONFIGURATIONS:
holder.sensor.setText(context.getResources().getString(R.string.accelerometer));
holder.tileIcon.setImageDrawable(context.getResources().getDrawable(R.drawable.tile_icon_accelerometer));
break;
Expand Down Expand Up @@ -166,7 +166,7 @@ public void onClick(DialogInterface dialog, int whichButton) {
LocalDataLog.with().clearBlockOfBaroRecords(block.getBlock());
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.COMPASS)) {
LocalDataLog.with().clearBlockOfCompassRecords(block.getBlock());
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.ACCELEROMETER)) {
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.ACCELEROMETER_CONFIGURATIONS)) {
LocalDataLog.with().clearBlockOfAccelerometerRecords(block.getBlock());
}
LocalDataLog.with().clearSensorBlock(block.getBlock());
Expand Down Expand Up @@ -255,7 +255,7 @@ private void populateMapData(SensorDataBlock block) {
}
}
setMapDataToIntent(array);
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.ACCELEROMETER)) {
} else if (block.getSensorType().equalsIgnoreCase(PSLabSensor.ACCELEROMETER_CONFIGURATIONS)) {
RealmResults<AccelerometerData> data = LocalDataLog.with().getBlockOfAccelerometerRecords(block.getBlock());
JSONArray array = new JSONArray();
for (AccelerometerData d : data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,20 +833,17 @@ private void initiateAccelerometerSensor(int type) {
ScienceLab scienceLab;
switch (s) {
case INBUILT_SENSOR:
//z_accel_max_text.setText(getResources().getStringArray(R.array.lux_sensors)[0]);
sensorManager = (SensorManager) getContext().getSystemService(SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
if (sensor == null) {
Toast.makeText(getContext(), getResources().getString(R.string.no_accelerometer_sensor), Toast.LENGTH_LONG).show();
} else {
float max = sensor.getMaximumRange();
//z_tv_label_left_yaxis_hmc.setMaxSpeed(max);
sensorManager.registerListener(accelerometerSensorEventListener,
sensor, SensorManager.SENSOR_DELAY_FASTEST);
}
break;
case BH1750_SENSOR:
//z_accel_max_text.setText(getResources().getStringArray(R.array.lux_sensors)[1]);
scienceLab = ScienceLabCommon.scienceLab;
if (scienceLab.isConnected()) {
ArrayList<Integer> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
public class AccelerometerSettingsFragment 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_ACCELEROMETER_SENSOR_TYPE = "setting_lux_sensor_type";
public static final String KEY_ACCELEROMETER_SENSOR_GAIN = "setting_lux_sensor_gain";
public static final String KEY_UPDATE_PERIOD = "setting_accelerometer_update_period";
public static final String KEY_HIGH_LIMIT = "setting_accelerometer_high_limit";
public static final String KEY_ACCELEROMETER_SENSOR_TYPE = "setting_accelerometer_sensor_type";
public static final String KEY_ACCELEROMETER_SENSOR_GAIN = "setting_accelerometer_sensor_gain";

private PSLabPermission psLabPermission;

Expand All @@ -34,7 +34,7 @@ public class AccelerometerSettingsFragment extends PreferenceFragmentCompat impl

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.lux_meter_settings, rootKey);
setPreferencesFromResource(R.xml.accelerometer_settings, rootKey);
updatePeriodPref = (EditTextPreference) getPreferenceScreen().findPreference(KEY_UPDATE_PERIOD);
higLimitPref = (EditTextPreference) getPreferenceScreen().findPreference(KEY_HIGH_LIMIT);
sensorGainPref = (EditTextPreference) getPreferenceScreen().findPreference(KEY_ACCELEROMETER_SENSOR_GAIN);
Expand All @@ -55,7 +55,7 @@ public void onResume() {
super.onResume();
locationPreference.setChecked(sharedPref.getBoolean(KEY_INCLUDE_LOCATION, true));
updatePeriodPref.setSummary(updatePeriodPref.getText() + " ms");
higLimitPref.setSummary(higLimitPref.getText() + " Lx");
higLimitPref.setSummary(higLimitPref.getText() + " m/s²");
sensorTypePreference.setSummary(sensorTypePreference.getEntry());
sensorGainPref.setSummary(sensorGainPref.getText());
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/io/pslab/models/PSLabSensor.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public abstract class PSLabSensor extends AppCompatActivity {
public static final String GYROSCOPE_CONFIGURATIONS = "Gyroscope Configurations";
public static final String COMPASS = "Compass";
public static final String COMPASS_CONFIGURATIONS = "Compass Configurations";
public static final String ACCELEROMETER = "Accelerometer";
public static final String ACCELEROMETER_CONFIGURATIONS = "Accelerometer Configurations";
public static final String ACCELEROMETER_DATA_FORMAT = "%.2f";

@BindView(R.id.sensor_toolbar)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_accelerometer_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
android:id="@+id/first_chart"
android:layout_width="match_parent"
android:layout_height="@dimen/accel_card_height"
android:layout_below="@+id/top_app_bar_layout"
android:layout_marginEnd="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/data_log_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
android:icon="@drawable/menu_icon_map"
android:title="@string/view_map"
app:showAsAction="never" />
<item
android:id="@+id/save_graph"
android:icon="@drawable/menu_icon_save"
android:orderInCategory="4"
android:title="@string/save_graph"
app:showAsAction="ifRoom" />
<item
android:id="@+id/settings"
android:title="@string/accelerometer_configurations"
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -582,24 +582,31 @@
<string name="no_lux_sensor">Device does not have a Lux sensor</string>
<string name="active_sensor">Active Sensor</string>
<string name="setting_baro">setting_baro_sensor_type</string>
<string name="setting_accelerometer">setting_accelerometer_sensor_type</string>
<string name="include_location">Include the location data in the logged file</string>
<string name="location_sensor">include_location_sensor_data</string>
<string name="include_cap">Include Location Data</string>
<string name="time_string_accelerometer">Please provide time interval at which data will be updated</string>
<string name="time_string_lux">Please provide time interval at which data will be updated (100 ms to 1000 ms)</string>
<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_accelerometer_update">setting_accelerometer_update_period</string>
<string name="default_value_baro">1.10</string>
<string name="default_value_lux">1</string>
<string name="default_value_acceleration">10</string>
<string name="dialogue_msg_acceleration">Please provide maximum limit of acceleration value to be recorded</string>
<string name="dialogue_msg_atm">Please provide maximum limit of atm value to be recorded</string>
<string name="dialogue_msg_lux">Please provide maximum limit of Lux value to be recorded (10 Lx to 10000 Lx)</string>
<string name="update_period_msg">Entered Update Period is not within the limits!</string>
<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_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_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>
<string-array name="lux_sensors">
Expand Down Expand Up @@ -719,6 +726,15 @@
<item>0</item>
<item>1</item>
</string-array>
<string-array name="accelerometer_sensors">
<item>Built-In</item>
<item>MPU6050</item>
</string-array>
<string-array name="accelerometer_sensor_list_values">
<item>0</item>
<item>1</item>
</string-array>

<string name="delete_all">Delete All Data</string>
<string name="delete_all_message">Are You Sure?</string>
<string name="baro_meter">Barometer</string>
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/res/xml/accelerometer_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<EditTextPreference
android:defaultValue="@string/lux_default_1000"
android:dialogMessage="@string/time_string_accelerometer"
android:dialogTitle="@string/update_period"
android:inputType="numberDecimal"
android:key="@string/setting_accelerometer_update"
android:summary="@string/lux_summary"
android:title="@string/update_period"
app:iconSpaceReserved="false" />

<EditTextPreference
android:defaultValue="@string/default_value_acceleration"
android:dialogMessage="@string/dialogue_msg_acceleration"
android:dialogTitle="@string/high_limit"
android:inputType="numberDecimal"
android:key="@string/high_limit_acceleration"
android:summary="@string/default_value_acceleration"
android:title="@string/high_limit"
app:iconSpaceReserved="false" />

<ListPreference
android:defaultValue="@string/lux_default_0"
android:entries="@array/accelerometer_sensors"
android:entryValues="@array/accelerometer_sensor_list_values"
android:key="@string/setting_accelerometer"
android:title="@string/active_sensor"
app:iconSpaceReserved="false" />

<EditTextPreference
android:defaultValue="@string/default_value_lux"
android:dialogMessage="@string/set_gain_sensor"
android:dialogTitle="@string/sensor_gain"
android:inputType="numberDecimal"
android:key="@string/setting_accelerometer_sensor_gain"
android:summary="@string/default_value_lux"
android:title="@string/sensor_gain"
app:iconSpaceReserved="false" />

<CheckBoxPreference
android:defaultValue="true"
android:key="@string/location_sensor"
android:summary="@string/include_location"
android:title="@string/include_cap"
app:iconSpaceReserved="false" />
</PreferenceScreen>