Skip to content

Commit f623086

Browse files
neel1998CloudyPadmal
authored andcommitted
no need to press view every time to set wave (#1949)
1 parent 08c8c3e commit f623086

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ public void setReceivedData() {
587587
}
588588
}
589589

590-
private void viewWave() {
590+
private void setWave() {
591591
double freq1 = (double) (WaveGeneratorCommon.wave.get(WaveConst.WAVE1).get(WaveConst.FREQUENCY));
592592
double freq2 = (double) WaveGeneratorCommon.wave.get(WaveConst.WAVE2).get(WaveConst.FREQUENCY);
593593
double phase = (double) WaveGeneratorCommon.wave.get(WaveConst.WAVE2).get(WaveConst.PHASE);
@@ -616,17 +616,17 @@ private void viewWave() {
616616
scienceLab.sqrPWM(freqSqr1, dutySqr1, phaseSqr2, dutySqr2, phaseSqr3, dutySqr3, phaseSqr4, dutySqr4, false);
617617
}
618618

619-
waveDialog.show();
620-
Window window = waveDialog.getWindow();
621-
window.setLayout(dpToPx(350), dpToPx(300));
622-
waveDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
623-
.setTextColor(ContextCompat.getColor(WaveGeneratorActivity.this, R.color.colorPrimary));
624-
625-
} else {
626-
Toast.makeText(WaveGeneratorActivity.this, R.string.device_not_connected, Toast.LENGTH_SHORT).show();
627619
}
628620
}
629621

622+
private void viewWaveDialog() {
623+
waveDialog.show();
624+
Window window = waveDialog.getWindow();
625+
window.setLayout(dpToPx(350), dpToPx(300));
626+
waveDialog.getButton(DialogInterface.BUTTON_NEGATIVE)
627+
.setTextColor(ContextCompat.getColor(WaveGeneratorActivity.this, R.color.colorPrimary));
628+
}
629+
630630
@Override
631631
public boolean onCreateOptionsMenu(Menu menu) {
632632
getMenuInflater().inflate(R.menu.wave_generator_menu, menu);
@@ -643,7 +643,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
643643
saveWaveConfig();
644644
break;
645645
case R.id.play_data:
646-
viewWave();
646+
setWave();
647+
if (scienceLab.isConnected()) {
648+
viewWaveDialog();
649+
} else {
650+
Toast.makeText(WaveGeneratorActivity.this, R.string.device_not_connected, Toast.LENGTH_SHORT).show();
651+
}
647652
break;
648653
case R.id.show_guide:
649654
bottomSheetBehavior.setState(bottomSheetBehavior.getState() == BottomSheetBehavior.STATE_HIDDEN ?
@@ -925,7 +930,7 @@ private void setValue() {
925930
} else {
926931
WaveGeneratorCommon.wave.get(waveBtnActive).put(prop_active, value);
927932
}
928-
933+
setWave();
929934
Double dValue = (double) value;
930935
String valueText = DataFormatter.formatDouble(dValue, DataFormatter.MEDIUM_PRECISION_FORMAT) + " " + unit;
931936
activePropTv.setText(valueText);

0 commit comments

Comments
 (0)