Skip to content

Commit

Permalink
changes made to wave generator UI
Browse files Browse the repository at this point in the history
  • Loading branch information
neel1998 committed Aug 23, 2019
1 parent 4e89f60 commit 0711c76
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 231 deletions.
136 changes: 55 additions & 81 deletions app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ public class WaveGeneratorActivity extends AppCompatActivity {
private final String MODE_SQUARE = "Square";
private final String MODE_PWM = "PWM";
//waveform monitor
@BindView(R.id.wave_mon_wave1)
TextView waveMonWave1;
@BindView(R.id.wave_mon_wave2)
TextView waveMonWave2;
@BindView(R.id.wave_ic_img)
ImageView selectedWaveImg;
@BindView(R.id.wave_mon_select_wave)
Expand All @@ -100,14 +96,6 @@ public class WaveGeneratorActivity extends AppCompatActivity {
ImageView pwmSelectedModeImg;
@BindView(R.id.pwm_mon_mode_select)
TextView pwmMonSelectMode;
@BindView(R.id.pwm_mon_sq1)
TextView pwmMonSqr1;
@BindView(R.id.pwm_mon_sq2)
TextView pwmMonSqr2;
@BindView(R.id.pwm_mon_sq3)
TextView pwmMonSqr3;
@BindView(R.id.pwm_mon_sq4)
TextView pwmMonSqr4;
@BindView(R.id.pwm_freq_value)
TextView pwmFreqValue;
@BindView(R.id.pwm_phase_value)
Expand Down Expand Up @@ -140,8 +128,10 @@ public class WaveGeneratorActivity extends AppCompatActivity {
Button btnPwmSq3;
@BindView(R.id.pwm_btn_sq4)
Button btnPwmSq4;
@BindView(R.id.pwm_btn_mode)
Button btnPwmMode;
@BindView(R.id.analog_mode_btn)
Button btnAnalogMode;
@BindView(R.id.digital_mode_btn)
Button btnDigitalMode;
@BindView(R.id.pwm_btn_freq)
Button pwmBtnFreq;
@BindView(R.id.pwm_btn_duty)
Expand Down Expand Up @@ -179,7 +169,6 @@ public class WaveGeneratorActivity extends AppCompatActivity {
private CSVLogger csvLogger;
private WaveConst waveBtnActive, pwmBtnActive, prop_active, digital_mode;
private TextView activePropTv = null;
private TextView activePwmPinTv = null;
private CoordinatorLayout coordinatorLayout;
private Realm realm;
private GPSLogger gpsLogger;
Expand Down Expand Up @@ -248,15 +237,6 @@ public void onClick(View view) {
}
}
});
waveMonWave1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!waveBtnActive.equals(WaveConst.WAVE1)) {
waveMonSelected = true;
selectBtn(WaveConst.WAVE1);
}
}
});
btnCtrlWave2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -266,15 +246,6 @@ public void onClick(View view) {
}
}
});
waveMonWave2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!waveBtnActive.equals(WaveConst.WAVE2)) {
waveMonSelected = true;
selectBtn(WaveConst.WAVE2);
}
}
});
imgBtnSin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -319,31 +290,36 @@ public void onClick(View view) {
}
});

//pwm panel
btnPwmMode.setOnClickListener(new View.OnClickListener() {
btnAnalogMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
WaveGeneratorCommon.intializeDigitalValue();
if (digital_mode == WaveConst.SQUARE) {
pwmModeLayout.setVisibility(View.VISIBLE);
pwmModeControls.setVisibility(View.VISIBLE);
squareModeLayout.setVisibility(View.GONE);
squareModeControls.setVisibility(View.GONE);
toggleDigitalMode(WaveConst.PWM);
imgBtnSin.setEnabled(false);
imgBtnTri.setEnabled(false);
pwmBtnActive = WaveConst.SQR1;
selectBtn(WaveConst.SQR1);
Toast.makeText(WaveGeneratorActivity.this, R.string.wave_pin_disable_comment, Toast.LENGTH_SHORT).show();
} else {
pwmModeLayout.setVisibility(View.GONE);
pwmModeControls.setVisibility(View.GONE);
squareModeLayout.setVisibility(View.VISIBLE);
squareModeControls.setVisibility(View.VISIBLE);
imgBtnSin.setEnabled(true);
imgBtnTri.setEnabled(true);
toggleDigitalMode(WaveConst.SQUARE);
}
public void onClick(View v) {
pwmModeLayout.setVisibility(View.GONE);
pwmModeControls.setVisibility(View.GONE);
squareModeLayout.setVisibility(View.VISIBLE);
squareModeControls.setVisibility(View.VISIBLE);
imgBtnSin.setEnabled(true);
imgBtnTri.setEnabled(true);
toggleDigitalMode(WaveConst.SQUARE);
btnDigitalMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnAnalogMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
}
});

btnDigitalMode.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pwmModeLayout.setVisibility(View.VISIBLE);
pwmModeControls.setVisibility(View.VISIBLE);
squareModeLayout.setVisibility(View.GONE);
squareModeControls.setVisibility(View.GONE);
toggleDigitalMode(WaveConst.PWM);
imgBtnSin.setEnabled(false);
imgBtnTri.setEnabled(false);
pwmBtnActive = WaveConst.SQR1;
selectBtn(WaveConst.SQR1);
Toast.makeText(WaveGeneratorActivity.this, R.string.wave_pin_disable_comment, Toast.LENGTH_SHORT).show();
btnDigitalMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnAnalogMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
}
});

Expand Down Expand Up @@ -696,8 +672,8 @@ public void selectBtn(WaveConst btn_selected) {

waveBtnActive = WaveConst.WAVE1;

waveMonWave1.setTextColor(getResources().getColor(R.color.orange));
waveMonWave2.setTextColor(getResources().getColor(R.color.dark_grey));
btnCtrlWave1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnCtrlWave2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));

btnCtrlPhase.setEnabled(false); //disable phase for wave
wavePhaseValue.setText("--");
Expand All @@ -712,8 +688,8 @@ public void selectBtn(WaveConst btn_selected) {

waveBtnActive = WaveConst.WAVE2;

waveMonWave2.setTextColor(getResources().getColor(R.color.orange));
waveMonWave1.setTextColor(getResources().getColor(R.color.dark_grey));
btnCtrlWave2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnCtrlWave1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));

btnCtrlPhase.setEnabled(true); // enable phase for wave2

Expand All @@ -725,10 +701,11 @@ public void selectBtn(WaveConst btn_selected) {
break;

case SQR1:
activePwmPinTv.setEnabled(false);
pwmBtnActive = WaveConst.SQR1;
activePwmPinTv = pwmMonSqr1;
activePwmPinTv.setEnabled(true);
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
pwmBtnPhase.setEnabled(false); //phase disabled for sq1
pwmPhaseValue.setText("--");
fetchPropertyValue(pwmBtnActive, WaveConst.FREQUENCY, getString(R.string.unit_hz), pwmFreqValue);
Expand All @@ -737,41 +714,44 @@ public void selectBtn(WaveConst btn_selected) {

case SQR2:

activePwmPinTv.setEnabled(false);
pwmBtnActive = WaveConst.SQR2;
activePwmPinTv = pwmMonSqr2;
activePwmPinTv.setEnabled(true);
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
pwmBtnPhase.setEnabled(true);
fetchPropertyValue(pwmBtnActive, WaveConst.PHASE, getString(R.string.deg_text), pwmPhaseValue);
fetchPropertyValue(pwmBtnActive, WaveConst.DUTY, getString(R.string.unit_percent), pwmDutyValue);
break;

case SQR3:

activePwmPinTv.setEnabled(false);
pwmBtnActive = WaveConst.SQR3;
activePwmPinTv = pwmMonSqr3;
activePwmPinTv.setEnabled(true);
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
pwmBtnPhase.setEnabled(true);
fetchPropertyValue(pwmBtnActive, WaveConst.PHASE, getString(R.string.deg_text), pwmPhaseValue);
fetchPropertyValue(pwmBtnActive, WaveConst.DUTY, getString(R.string.unit_percent), pwmDutyValue);
break;

case SQR4:

activePwmPinTv.setEnabled(false);
pwmBtnActive = WaveConst.SQR4;
activePwmPinTv = pwmMonSqr4;
activePwmPinTv.setEnabled(true);
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
pwmBtnPhase.setEnabled(true);
fetchPropertyValue(pwmBtnActive, WaveConst.PHASE, getString(R.string.deg_text), pwmPhaseValue);
fetchPropertyValue(pwmBtnActive, WaveConst.DUTY, getString(R.string.unit_percent), pwmDutyValue);
break;

default:
waveBtnActive = WaveConst.WAVE1;
waveMonWave1.setTextColor(getResources().getColor(R.color.orange));
waveMonWave2.setTextColor(getResources().getColor(R.color.dark_grey));
btnCtrlWave1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
btnCtrlWave2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
btnCtrlPhase.setEnabled(false); //disable phase for wave
wavePhaseValue.setText("--");
selectWaveform(WaveGeneratorCommon.wave.get(waveBtnActive).get(WaveConst.WAVETYPE));
Expand Down Expand Up @@ -829,10 +809,6 @@ private void toggleDigitalMode(WaveConst mode) {
btnPwmSq3.setEnabled(true);
btnPwmSq4.setEnabled(true);
}
pwmMonSqr1.setSelected(false);
pwmMonSqr2.setSelected(false);
pwmMonSqr3.setSelected(false);
pwmMonSqr4.setSelected(false);
WaveGeneratorCommon.mode_selected = mode;
}

Expand Down Expand Up @@ -969,13 +945,11 @@ private void toggleSeekBtns(boolean state) {

private void enableInitialState() {
selectBtn(WaveConst.WAVE1);
activePwmPinTv = pwmMonSqr1;
toggleDigitalMode(WaveConst.SQUARE);
}

private void enableInitialStatePWM() {
selectBtn(WaveConst.SQR2);
activePwmPinTv = pwmMonSqr2;
toggleDigitalMode(WaveConst.PWM);
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/drawable/btn_back_rounded.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="@color/theme_red_light" />
<corners android:radius="5dp" />
<corners android:radius="@dimen/button_bg_radius" />
</shape>
</item>
<item android:state_enabled="true">
<shape android:shape="rectangle">
<solid android:color="@color/colorPrimary" />
<corners android:radius="5dp" />
<corners android:radius="@dimen/button_bg_radius" />
</shape>
</item>
</selector>
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/btn_back_rounded_light.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/theme_red_light" />
<corners android:radius="@dimen/button_bg_radius" />
</shape>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_arrow_left_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
</vector>
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/ic_arrow_right_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#FFFFFF"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/>
</vector>
Loading

0 comments on commit 0711c76

Please sign in to comment.