Skip to content

Commit

Permalink
Merge pull request #1778 from fossasia/development
Browse files Browse the repository at this point in the history
chore: merge dev to master
  • Loading branch information
CloudyPadmal authored Jun 7, 2019
2 parents 17e383f + c7cee95 commit 5033c86
Show file tree
Hide file tree
Showing 38 changed files with 2,488 additions and 544 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ Please join us on the following channels:
<table>
<tr>
<td><img src="/docs/images/instrument_accelerometer_view.png" width = "500"></td>
<td><img src="/docs/images/instrument_gyro_view.png" width = "500"></td>
<td><img src="/docs/images/instrument_compass_view.png" width = "500"></td>
<td><img src="/docs/images/instrument_thermo_view.png" width = "500"></td>
</tr>
</table>
<table>
<tr>
<td><img src="/docs/images/instrument_robotic_arm_view.png" width = "500"></td>
</tr>
</table>

Expand All @@ -100,9 +107,11 @@ Please join us on the following channels:
| AcceleroMeter | Measures the acceleration of the device ||
| Gyro Meter | Measures the rate of rotation ||
| Compass | Measures the absolute rotation relative to earth magnetic poles ||
| Thermometer | Measures the ambient temperature | |
| Robotic Arm Controller | Allows to control 4 servo motors of the robotic arm | |
## How to set up the Android app in your development environment

Minimum Android version 4.1 (API Level 16)
Minimum Android version 5.0 (API Level 21)

Maximum Android version 8.1 (API Level 27)

Expand Down
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "io.pslab"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 14
versionName "2.0.13"
versionCode 15
versionName "2.0.14"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -71,6 +71,7 @@ dependencies {

implementation "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"

// Map libraries
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
android:roundIcon="@drawable/app_icon_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.ThermometerActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"></activity>
<activity android:name=".activity.RoboticArmActivity"
android:screenOrientation="landscape"/>
<activity
Expand Down
77 changes: 77 additions & 0 deletions app/src/main/java/io/pslab/activity/DataLoggerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -40,6 +41,8 @@
import io.pslab.models.GyroData;
import io.pslab.models.LuxData;
import io.pslab.models.SensorDataBlock;
import io.pslab.models.ServoData;
import io.pslab.models.ThermometerData;
import io.pslab.others.CSVLogger;
import io.pslab.others.LocalDataLog;
import io.realm.Realm;
Expand Down Expand Up @@ -101,6 +104,11 @@ protected void onCreate(Bundle savedInstanceState) {
case "Compass":
categoryData = LocalDataLog.with().getTypeOfSensorBlocks(getString(R.string.compass));
break;
case "Thermometer":
categoryData = LocalDataLog.with().getTypeOfSensorBlocks(getString(R.string.thermometer));
break;
case "Robotic Arm":
categoryData = LocalDataLog.with().getTypeOfSensorBlocks(getString(R.string.robotic_arm));
default:
categoryData = LocalDataLog.with().getAllSensorBlocks();
getSupportActionBar().setTitle(getString(R.string.logged_data));
Expand Down Expand Up @@ -412,6 +420,75 @@ private void getFileData(File file) {
} catch (IOException e) {
e.printStackTrace();
}
} else if (selectedDevice != null && selectedDevice.equals(getResources().getString(R.string.thermometer))) {
try {
FileInputStream is = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = reader.readLine();
int i = 0;
long block = 0, time = 0;
while (line != null) {
if (i != 0) {
String[] data = line.split(",");
try {
time += 1000;
ThermometerData thermometerData = new ThermometerData(time, block, Float.valueOf(data[2]), Double.valueOf(data[5]), Double.valueOf(data[6]));
realm.beginTransaction();
realm.copyToRealm(thermometerData);
realm.commitTransaction();
} catch (Exception e) {
Toast.makeText(this, getResources().getString(R.string.incorrect_import_format), Toast.LENGTH_SHORT).show();
}
} else {
block = System.currentTimeMillis();
time = block;
realm.beginTransaction();
realm.copyToRealm(new SensorDataBlock(block, getResources().getString(R.string.thermometer)));
realm.commitTransaction();
}
i++;
line = reader.readLine();
}
fillData();
DataLoggerActivity.this.toolbar.getMenu().findItem(R.id.delete_all).setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
} else if (selectedDevice != null && selectedDevice.equals(getResources().getString(R.string.robotic_arm))) {
try {
FileInputStream is = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = reader.readLine();
int i = 0;
long block = 0, time = 0;
while (line != null) {
if (i != 0) {
String[] data = line.split(",");
try {
time += 1000;
ServoData servoData = new ServoData(time, block, data[2], data[3], data[4], data[5], Float.valueOf(data[6]), Float.valueOf(data[7]));
realm.beginTransaction();
realm.copyToRealm(servoData);
realm.commitTransaction();
} catch (Exception e) {
Log.d("exception", i + " " + e.getMessage());
Toast.makeText(this, getResources().getString(R.string.incorrect_import_format), Toast.LENGTH_SHORT).show();
}
} else {
block = System.currentTimeMillis();
time = block;
realm.beginTransaction();
realm.copyToRealm(new SensorDataBlock(block, getResources().getString(R.string.robotic_arm)));
realm.commitTransaction();
}
i++;
line = reader.readLine();
}
fillData();
DataLoggerActivity.this.toolbar.getMenu().findItem(R.id.delete_all).setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Loading

0 comments on commit 5033c86

Please sign in to comment.