diff --git a/app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java b/app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java index eb2fec9e3..991d826c1 100644 --- a/app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java +++ b/app/src/main/java/io/pslab/activity/WaveGeneratorActivity.java @@ -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) @@ -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) @@ -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) @@ -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; @@ -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) { @@ -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) { @@ -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)); } }); @@ -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("--"); @@ -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 @@ -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); @@ -737,10 +714,11 @@ 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); @@ -748,10 +726,11 @@ public void selectBtn(WaveConst btn_selected) { 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); @@ -759,10 +738,11 @@ public void selectBtn(WaveConst btn_selected) { 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); @@ -770,8 +750,8 @@ public void selectBtn(WaveConst btn_selected) { 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)); @@ -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; } @@ -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); } diff --git a/app/src/main/res/drawable/btn_back_rounded.xml b/app/src/main/res/drawable/btn_back_rounded.xml index f3b6377f4..35e099f47 100644 --- a/app/src/main/res/drawable/btn_back_rounded.xml +++ b/app/src/main/res/drawable/btn_back_rounded.xml @@ -4,13 +4,13 @@ - + - + diff --git a/app/src/main/res/drawable/btn_back_rounded_light.xml b/app/src/main/res/drawable/btn_back_rounded_light.xml new file mode 100644 index 000000000..0965b8c5b --- /dev/null +++ b/app/src/main/res/drawable/btn_back_rounded_light.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_arrow_left_24dp.xml b/app/src/main/res/drawable/ic_arrow_left_24dp.xml new file mode 100644 index 000000000..b79d00f6e --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_left_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_right_24dp.xml b/app/src/main/res/drawable/ic_arrow_right_24dp.xml new file mode 100644 index 000000000..ff5a73fff --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_right_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/wave_generator_analog_mode_layout.xml b/app/src/main/res/layout/wave_generator_analog_mode_layout.xml index f30bbc1d1..21cfe7c2e 100644 --- a/app/src/main/res/layout/wave_generator_analog_mode_layout.xml +++ b/app/src/main/res/layout/wave_generator_analog_mode_layout.xml @@ -2,8 +2,8 @@ @@ -15,14 +15,6 @@ app:layout_constraintGuide_begin="@dimen/constraint_guide_begin" app:layout_constraintGuide_percent="0.5" /> - - + app:layout_constraintGuide_percent="0.20" /> - - - - - - - + app:layout_constraintTop_toTopOf="parent" /> - - @@ -73,64 +65,6 @@ app:layout_constraintStart_toStartOf="@+id/pwm_ic_img" app:layout_constraintTop_toBottomOf="@+id/pwm_ic_img" /> - - - - - - - - - - + app:layout_constraintTop_toTopOf="parent" /> + android:textSize="@dimen/wave_gen_control_text_size" />