Skip to content

Commit

Permalink
Merge pull request #1382 from fossasia/development
Browse files Browse the repository at this point in the history
chore: merge dev into master upgrading v2.0.3
  • Loading branch information
CloudyPadmal authored Aug 22, 2018
2 parents f6fc82e + 89f02c8 commit 22557e6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
4 changes: 2 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 3
versionName "2.0.2"
versionCode 4
versionName "2.0.3"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand Down
45 changes: 30 additions & 15 deletions app/src/main/java/io/pslab/activity/MultimeterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected void onCreate(final Bundle savedInstanceState) {
tvShadow.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(bottomSheetBehavior.getState()==BottomSheetBehavior.STATE_EXPANDED)
if (bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_EXPANDED)
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
tvShadow.setVisibility(View.GONE);
}
Expand Down Expand Up @@ -184,6 +184,7 @@ public void onClick(View v) {
switch (knobState) {
case 3:
if (scienceLab.isConnected()) {
v.setEnabled(false);
DecimalFormat resistanceFormat = new DecimalFormat("#.##");
Double resistance;
Double avgResistance = 0.0;
Expand Down Expand Up @@ -225,33 +226,41 @@ public void onClick(View v) {
saveAndSetData(Resistance, resistanceUnit);
if (recordData)
record("Resistance", Resistance + recordUnit);
v.setEnabled(true);
}
break;
case 4:
if (scienceLab.isConnected()) {
v.setEnabled(false);
Double capacitance = scienceLab.getCapacitance();
DecimalFormat capacitanceFormat = new DecimalFormat("#.##");
String Capacitance;
String capacitanceUnit;
if (capacitance < 1e-9) {
Capacitance = capacitanceFormat.format((capacitance / 1e-12));
capacitanceUnit = "pF";
} else if (capacitance < 1e-6) {
Capacitance = capacitanceFormat.format((capacitance / 1e-9));
capacitanceUnit = "nF";
} else if (capacitance < 1e-3) {
Capacitance = capacitanceFormat.format((capacitance / 1e-6));
capacitanceUnit = "\u00B5" + "F";
} else if (capacitance < 1e-1) {
Capacitance = capacitanceFormat.format((capacitance / 1e-3));
capacitanceUnit = "mF";
if (capacitance == null) {
Capacitance = "Cannot measure!";
capacitanceUnit = "";
} else {
Capacitance = capacitanceFormat.format(capacitance);
capacitanceUnit = getString(R.string.capacitance_unit);
if (capacitance < 1e-9) {
Capacitance = capacitanceFormat.format((capacitance / 1e-12));
capacitanceUnit = "pF";
} else if (capacitance < 1e-6) {
Capacitance = capacitanceFormat.format((capacitance / 1e-9));
capacitanceUnit = "nF";
} else if (capacitance < 1e-3) {
Capacitance = capacitanceFormat.format((capacitance / 1e-6));
capacitanceUnit = "\u00B5" + "F";
} else if (capacitance < 1e-1) {
Capacitance = capacitanceFormat.format((capacitance / 1e-3));
capacitanceUnit = "mF";
} else {
Capacitance = capacitanceFormat.format(capacitance);
capacitanceUnit = getString(R.string.capacitance_unit);
}
}
saveAndSetData(Capacitance, capacitanceUnit);
if (recordData)
record("Capacitance", Capacitance + capacitanceUnit);
v.setEnabled(true);
}
break;
case 5:
Expand All @@ -260,26 +269,32 @@ public void onClick(View v) {
case 8:
if (!switchIsChecked) {
if (scienceLab.isConnected()) {
v.setEnabled(false);
Double frequency = scienceLab.getFrequency(knobMarker[knobState], null);
saveAndSetData(String.valueOf(frequency), getString(R.string.frequency_unit));
if (recordData)
record(knobMarker[knobState], String.valueOf(frequency) + getString(R.string.frequency_unit));
v.setEnabled(true);
}
} else {
if (scienceLab.isConnected()) {
v.setEnabled(false);
scienceLab.countPulses(knobMarker[knobState]);
double pulseCount = scienceLab.readPulseCount();
saveAndSetData(String.valueOf(pulseCount), "");
if (recordData)
record(knobMarker[knobState], String.valueOf(pulseCount));
v.setEnabled(true);
}
}
break;
default:
if (scienceLab.isConnected()) {
v.setEnabled(false);
saveAndSetData(String.valueOf(String.format(Locale.ENGLISH, "%.2f", scienceLab.getVoltage(knobMarker[knobState], 1))), getString(R.string.multimeter_voltage_unit));
if (recordData)
record(knobMarker[knobState], String.valueOf(String.format(Locale.ENGLISH, "%.2f", scienceLab.getVoltage(knobMarker[knobState], 1))) + getString(R.string.multimeter_voltage_unit));
v.setEnabled(true);
}
break;
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/io/pslab/communication/ScienceLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -2247,8 +2247,9 @@ public double[] getCapacitance(int currentRange, double trim, int chargeTime) {
mPacketHandler.sendInt(chargeTime);
Thread.sleep((long) (chargeTime * 1e-6 + .02));
int VCode;
int i = 0;
do VCode = mPacketHandler.getVoltageSummation();
while (VCode == -1);
while (VCode == -1 & i++ < 10);
double v = 3.3 * VCode / 4095;
mPacketHandler.getAcknowledgement();
double chargeCurrent = this.currents[currentRange] * (100 + trim) / 100.0;
Expand Down

0 comments on commit 22557e6

Please sign in to comment.