Skip to content

Commit 6797b02

Browse files
committed
changes made to wave generator UI
1 parent 4e89f60 commit 6797b02

10 files changed

+110
-229
lines changed

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

Lines changed: 55 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ public class WaveGeneratorActivity extends AppCompatActivity {
7979
private final String MODE_SQUARE = "Square";
8080
private final String MODE_PWM = "PWM";
8181
//waveform monitor
82-
@BindView(R.id.wave_mon_wave1)
83-
TextView waveMonWave1;
84-
@BindView(R.id.wave_mon_wave2)
85-
TextView waveMonWave2;
8682
@BindView(R.id.wave_ic_img)
8783
ImageView selectedWaveImg;
8884
@BindView(R.id.wave_mon_select_wave)
@@ -100,14 +96,6 @@ public class WaveGeneratorActivity extends AppCompatActivity {
10096
ImageView pwmSelectedModeImg;
10197
@BindView(R.id.pwm_mon_mode_select)
10298
TextView pwmMonSelectMode;
103-
@BindView(R.id.pwm_mon_sq1)
104-
TextView pwmMonSqr1;
105-
@BindView(R.id.pwm_mon_sq2)
106-
TextView pwmMonSqr2;
107-
@BindView(R.id.pwm_mon_sq3)
108-
TextView pwmMonSqr3;
109-
@BindView(R.id.pwm_mon_sq4)
110-
TextView pwmMonSqr4;
11199
@BindView(R.id.pwm_freq_value)
112100
TextView pwmFreqValue;
113101
@BindView(R.id.pwm_phase_value)
@@ -140,8 +128,10 @@ public class WaveGeneratorActivity extends AppCompatActivity {
140128
Button btnPwmSq3;
141129
@BindView(R.id.pwm_btn_sq4)
142130
Button btnPwmSq4;
143-
@BindView(R.id.pwm_btn_mode)
144-
Button btnPwmMode;
131+
@BindView(R.id.analog_mode_btn)
132+
Button btnAnalogMode;
133+
@BindView(R.id.digital_mode_btn)
134+
Button btnDigitalMode;
145135
@BindView(R.id.pwm_btn_freq)
146136
Button pwmBtnFreq;
147137
@BindView(R.id.pwm_btn_duty)
@@ -179,7 +169,6 @@ public class WaveGeneratorActivity extends AppCompatActivity {
179169
private CSVLogger csvLogger;
180170
private WaveConst waveBtnActive, pwmBtnActive, prop_active, digital_mode;
181171
private TextView activePropTv = null;
182-
private TextView activePwmPinTv = null;
183172
private CoordinatorLayout coordinatorLayout;
184173
private Realm realm;
185174
private GPSLogger gpsLogger;
@@ -248,15 +237,6 @@ public void onClick(View view) {
248237
}
249238
}
250239
});
251-
waveMonWave1.setOnClickListener(new View.OnClickListener() {
252-
@Override
253-
public void onClick(View v) {
254-
if (!waveBtnActive.equals(WaveConst.WAVE1)) {
255-
waveMonSelected = true;
256-
selectBtn(WaveConst.WAVE1);
257-
}
258-
}
259-
});
260240
btnCtrlWave2.setOnClickListener(new View.OnClickListener() {
261241
@Override
262242
public void onClick(View view) {
@@ -266,15 +246,6 @@ public void onClick(View view) {
266246
}
267247
}
268248
});
269-
waveMonWave2.setOnClickListener(new View.OnClickListener() {
270-
@Override
271-
public void onClick(View v) {
272-
if (!waveBtnActive.equals(WaveConst.WAVE2)) {
273-
waveMonSelected = true;
274-
selectBtn(WaveConst.WAVE2);
275-
}
276-
}
277-
});
278249
imgBtnSin.setOnClickListener(new View.OnClickListener() {
279250
@Override
280251
public void onClick(View view) {
@@ -319,31 +290,36 @@ public void onClick(View view) {
319290
}
320291
});
321292

322-
//pwm panel
323-
btnPwmMode.setOnClickListener(new View.OnClickListener() {
293+
btnAnalogMode.setOnClickListener(new View.OnClickListener() {
324294
@Override
325-
public void onClick(View view) {
326-
WaveGeneratorCommon.intializeDigitalValue();
327-
if (digital_mode == WaveConst.SQUARE) {
328-
pwmModeLayout.setVisibility(View.VISIBLE);
329-
pwmModeControls.setVisibility(View.VISIBLE);
330-
squareModeLayout.setVisibility(View.GONE);
331-
squareModeControls.setVisibility(View.GONE);
332-
toggleDigitalMode(WaveConst.PWM);
333-
imgBtnSin.setEnabled(false);
334-
imgBtnTri.setEnabled(false);
335-
pwmBtnActive = WaveConst.SQR1;
336-
selectBtn(WaveConst.SQR1);
337-
Toast.makeText(WaveGeneratorActivity.this, R.string.wave_pin_disable_comment, Toast.LENGTH_SHORT).show();
338-
} else {
339-
pwmModeLayout.setVisibility(View.GONE);
340-
pwmModeControls.setVisibility(View.GONE);
341-
squareModeLayout.setVisibility(View.VISIBLE);
342-
squareModeControls.setVisibility(View.VISIBLE);
343-
imgBtnSin.setEnabled(true);
344-
imgBtnTri.setEnabled(true);
345-
toggleDigitalMode(WaveConst.SQUARE);
346-
}
295+
public void onClick(View v) {
296+
pwmModeLayout.setVisibility(View.GONE);
297+
pwmModeControls.setVisibility(View.GONE);
298+
squareModeLayout.setVisibility(View.VISIBLE);
299+
squareModeControls.setVisibility(View.VISIBLE);
300+
imgBtnSin.setEnabled(true);
301+
imgBtnTri.setEnabled(true);
302+
toggleDigitalMode(WaveConst.SQUARE);
303+
btnDigitalMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
304+
btnAnalogMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
305+
}
306+
});
307+
308+
btnDigitalMode.setOnClickListener(new View.OnClickListener() {
309+
@Override
310+
public void onClick(View v) {
311+
pwmModeLayout.setVisibility(View.VISIBLE);
312+
pwmModeControls.setVisibility(View.VISIBLE);
313+
squareModeLayout.setVisibility(View.GONE);
314+
squareModeControls.setVisibility(View.GONE);
315+
toggleDigitalMode(WaveConst.PWM);
316+
imgBtnSin.setEnabled(false);
317+
imgBtnTri.setEnabled(false);
318+
pwmBtnActive = WaveConst.SQR1;
319+
selectBtn(WaveConst.SQR1);
320+
Toast.makeText(WaveGeneratorActivity.this, R.string.wave_pin_disable_comment, Toast.LENGTH_SHORT).show();
321+
btnDigitalMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
322+
btnAnalogMode.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
347323
}
348324
});
349325

@@ -696,8 +672,8 @@ public void selectBtn(WaveConst btn_selected) {
696672

697673
waveBtnActive = WaveConst.WAVE1;
698674

699-
waveMonWave1.setTextColor(getResources().getColor(R.color.orange));
700-
waveMonWave2.setTextColor(getResources().getColor(R.color.dark_grey));
675+
btnCtrlWave1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
676+
btnCtrlWave2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
701677

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

713689
waveBtnActive = WaveConst.WAVE2;
714690

715-
waveMonWave2.setTextColor(getResources().getColor(R.color.orange));
716-
waveMonWave1.setTextColor(getResources().getColor(R.color.dark_grey));
691+
btnCtrlWave2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
692+
btnCtrlWave1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
717693

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

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

727703
case SQR1:
728-
activePwmPinTv.setEnabled(false);
729704
pwmBtnActive = WaveConst.SQR1;
730-
activePwmPinTv = pwmMonSqr1;
731-
activePwmPinTv.setEnabled(true);
705+
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
706+
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
707+
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
708+
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
732709
pwmBtnPhase.setEnabled(false); //phase disabled for sq1
733710
pwmPhaseValue.setText("--");
734711
fetchPropertyValue(pwmBtnActive, WaveConst.FREQUENCY, getString(R.string.unit_hz), pwmFreqValue);
@@ -737,41 +714,44 @@ public void selectBtn(WaveConst btn_selected) {
737714

738715
case SQR2:
739716

740-
activePwmPinTv.setEnabled(false);
741717
pwmBtnActive = WaveConst.SQR2;
742-
activePwmPinTv = pwmMonSqr2;
743-
activePwmPinTv.setEnabled(true);
718+
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
719+
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
720+
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
721+
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
744722
pwmBtnPhase.setEnabled(true);
745723
fetchPropertyValue(pwmBtnActive, WaveConst.PHASE, getString(R.string.deg_text), pwmPhaseValue);
746724
fetchPropertyValue(pwmBtnActive, WaveConst.DUTY, getString(R.string.unit_percent), pwmDutyValue);
747725
break;
748726

749727
case SQR3:
750728

751-
activePwmPinTv.setEnabled(false);
752729
pwmBtnActive = WaveConst.SQR3;
753-
activePwmPinTv = pwmMonSqr3;
754-
activePwmPinTv.setEnabled(true);
730+
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
731+
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
732+
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
733+
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
755734
pwmBtnPhase.setEnabled(true);
756735
fetchPropertyValue(pwmBtnActive, WaveConst.PHASE, getString(R.string.deg_text), pwmPhaseValue);
757736
fetchPropertyValue(pwmBtnActive, WaveConst.DUTY, getString(R.string.unit_percent), pwmDutyValue);
758737
break;
759738

760739
case SQR4:
761740

762-
activePwmPinTv.setEnabled(false);
763741
pwmBtnActive = WaveConst.SQR4;
764-
activePwmPinTv = pwmMonSqr4;
765-
activePwmPinTv.setEnabled(true);
742+
btnPwmSq1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
743+
btnPwmSq2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
744+
btnPwmSq3.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
745+
btnPwmSq4.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
766746
pwmBtnPhase.setEnabled(true);
767747
fetchPropertyValue(pwmBtnActive, WaveConst.PHASE, getString(R.string.deg_text), pwmPhaseValue);
768748
fetchPropertyValue(pwmBtnActive, WaveConst.DUTY, getString(R.string.unit_percent), pwmDutyValue);
769749
break;
770750

771751
default:
772752
waveBtnActive = WaveConst.WAVE1;
773-
waveMonWave1.setTextColor(getResources().getColor(R.color.orange));
774-
waveMonWave2.setTextColor(getResources().getColor(R.color.dark_grey));
753+
btnCtrlWave1.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded));
754+
btnCtrlWave2.setBackground(getResources().getDrawable(R.drawable.btn_back_rounded_light));
775755
btnCtrlPhase.setEnabled(false); //disable phase for wave
776756
wavePhaseValue.setText("--");
777757
selectWaveform(WaveGeneratorCommon.wave.get(waveBtnActive).get(WaveConst.WAVETYPE));
@@ -829,10 +809,6 @@ private void toggleDigitalMode(WaveConst mode) {
829809
btnPwmSq3.setEnabled(true);
830810
btnPwmSq4.setEnabled(true);
831811
}
832-
pwmMonSqr1.setSelected(false);
833-
pwmMonSqr2.setSelected(false);
834-
pwmMonSqr3.setSelected(false);
835-
pwmMonSqr4.setSelected(false);
836812
WaveGeneratorCommon.mode_selected = mode;
837813
}
838814

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

970946
private void enableInitialState() {
971947
selectBtn(WaveConst.WAVE1);
972-
activePwmPinTv = pwmMonSqr1;
973948
toggleDigitalMode(WaveConst.SQUARE);
974949
}
975950

976951
private void enableInitialStatePWM() {
977952
selectBtn(WaveConst.SQR2);
978-
activePwmPinTv = pwmMonSqr2;
979953
toggleDigitalMode(WaveConst.PWM);
980954
}
981955

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
<solid android:color="@color/theme_red_light" />
5+
<corners android:radius="5dp" />
6+
</shape>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M15.41,16.09l-4.58,-4.59 4.58,-4.59L14,5.5l-6,6 6,6z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24.0" android:viewportWidth="24.0"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="#FF000000" android:pathData="M8.59,16.34l4.58,-4.59 -4.58,-4.59L10,5.75l6,6 -6,6z"/>
5+
</vector>

app/src/main/res/layout/wave_generator_analog_mode_layout.xml

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
android:id="@+id/square_mode_layout"
5-
android:layout_width="@dimen/length_0dp"
6-
android:layout_height="@dimen/length_0dp"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
77
android:layout_marginEnd="@dimen/card_separation_offset"
88
android:background="@color/black">
99

@@ -15,14 +15,6 @@
1515
app:layout_constraintGuide_begin="@dimen/constraint_guide_begin"
1616
app:layout_constraintGuide_percent="0.5" />
1717

18-
<android.support.constraint.Guideline
19-
android:id="@+id/fguideline3"
20-
android:layout_width="wrap_content"
21-
android:layout_height="wrap_content"
22-
android:orientation="horizontal"
23-
app:layout_constraintGuide_begin="@dimen/constraint_guide_begin"
24-
app:layout_constraintGuide_percent="0.20" />
25-
2618
<android.support.constraint.Guideline
2719
android:id="@+id/fguideline9"
2820
android:layout_width="wrap_content"
@@ -37,7 +29,7 @@
3729
android:layout_height="wrap_content"
3830
android:orientation="vertical"
3931
app:layout_constraintGuide_begin="@dimen/constraint_guide_begin"
40-
app:layout_constraintGuide_percent="0.35" />
32+
app:layout_constraintGuide_percent="0.20" />
4133

4234
<ImageView
4335
android:id="@+id/wave_ic_img"
@@ -46,42 +38,11 @@
4638
app:layout_constraintBottom_toTopOf="@+id/wave_mon_select_wave"
4739
app:layout_constraintEnd_toStartOf="@+id/fguideline10"
4840
app:layout_constraintStart_toStartOf="parent"
49-
app:layout_constraintTop_toTopOf="@+id/fguideline3"
41+
app:layout_constraintTop_toTopOf="parent"
5042
app:layout_constraintVertical_bias="0.45"
5143
app:layout_constraintVertical_chainStyle="packed"
5244
app:srcCompat="@drawable/ic_triangular" />
5345

54-
<TextView
55-
android:id="@+id/wave_mon_wave1"
56-
android:layout_width="wrap_content"
57-
android:layout_height="wrap_content"
58-
android:layout_marginEnd="@dimen/mon_title_sep_margin"
59-
android:enabled="false"
60-
android:text="@string/wave1"
61-
android:textColor="@drawable/text_color_selector"
62-
android:textSize="@dimen/text_size_wavegen"
63-
android:textStyle="bold"
64-
app:layout_constraintBottom_toTopOf="@+id/fguideline3"
65-
app:layout_constraintEnd_toStartOf="@+id/fguideline2"
66-
app:layout_constraintStart_toStartOf="parent"
67-
app:layout_constraintTop_toTopOf="parent" />
68-
69-
<TextView
70-
android:id="@+id/wave_mon_wave2"
71-
android:layout_width="wrap_content"
72-
android:layout_height="wrap_content"
73-
android:layout_marginStart="@dimen/mon_title_sep_margin"
74-
android:enabled="false"
75-
android:text="@string/wave2"
76-
android:textColor="@drawable/text_color_selector"
77-
android:textSize="@dimen/text_size_wavegen"
78-
android:textStyle="bold"
79-
app:layout_constraintBottom_toBottomOf="@+id/wave_mon_wave1"
80-
app:layout_constraintEnd_toEndOf="parent"
81-
app:layout_constraintStart_toEndOf="@id/fguideline2"
82-
app:layout_constraintTop_toTopOf="@+id/wave_mon_wave1" />
83-
84-
8546
<TextView
8647
android:id="@+id/wave_mon_select_wave"
8748
android:layout_width="wrap_content"
@@ -108,7 +69,7 @@
10869
android:textStyle="bold"
10970
app:layout_constraintBottom_toTopOf="@+id/wave_phase"
11071
app:layout_constraintStart_toStartOf="@+id/fguideline10"
111-
app:layout_constraintTop_toTopOf="@+id/fguideline3"
72+
app:layout_constraintTop_toTopOf="parent"
11273
app:layout_constraintVertical_chainStyle="packed" />
11374

11475
<TextView
@@ -186,20 +147,9 @@
186147
android:background="@color/dark_grey"
187148
app:layout_constraintBottom_toTopOf="@+id/fguideline9"
188149
app:layout_constraintEnd_toEndOf="parent"
189-
app:layout_constraintHorizontal_bias="0.35"
190-
app:layout_constraintStart_toStartOf="parent"
191-
app:layout_constraintTop_toBottomOf="@+id/fguideline3" />
192-
193-
<View
194-
android:layout_width="@dimen/length_0dp"
195-
android:layout_height="@dimen/divider_width"
196-
android:background="@color/dark_grey"
197-
app:layout_constraintBottom_toBottomOf="parent"
198-
app:layout_constraintEnd_toEndOf="parent"
199150
app:layout_constraintHorizontal_bias="0.20"
200151
app:layout_constraintStart_toStartOf="parent"
201-
app:layout_constraintTop_toTopOf="parent"
202-
app:layout_constraintVertical_bias="0.20" />
152+
app:layout_constraintTop_toTopOf="parent" />
203153

204154
<View
205155
android:layout_width="@dimen/length_0dp"

0 commit comments

Comments
 (0)