From: Michael Gernoth Date: Sun, 21 Aug 2011 14:06:45 +0000 (+0200) Subject: integrate hw debounce into gui X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/2bb83a0e6c37053577c741fd25eeeeeb3364fd66 integrate hw debounce into gui --- diff --git a/MS2Debounce/res/layout/main.xml b/MS2Debounce/res/layout/main.xml index a1f41a8..b9d55b8 100644 --- a/MS2Debounce/res/layout/main.xml +++ b/MS2Debounce/res/layout/main.xml @@ -63,6 +63,14 @@ android:text="0" android:enabled="false" android:background="@android:drawable/editbox_background"/> + - + + + android:onClick="toggle_hw_debounce" + android:text="Enabled" /> 0) { + module.setSavedHwDebounceTime(Integer.parseInt(hw_debounce_time.toString())); + } + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + }); + updateUI(); } @@ -107,13 +127,16 @@ public class MS2Debounce extends Activity debounce_delay = module.getDelay(); settle_time = module.getSettle(); poll_time = module.getPoll(); + hw_debounce_en = module.getHwDebounce(); + hw_debounce_time = module.getHwDebounceTime(); TextView text = (TextView)findViewById(R.id.text); text.setText("Module loaded: " + loaded + "\n" + "debounce_delay: " + debounce_delay + "ms\n" + "settle_time: " + settle_time + "us\n" + "poll_time: " + poll_time + "ms\n" + - "safe_to_load: " + safe_to_load + " (module loaded by this app)"); + "safe_to_load: " + safe_to_load + " (module loaded by this app)\n" + + "hw_debounce: " + (hw_debounce_en?"enabled":"disabled") + ", " + ((hw_debounce_time+1)*31) + "us (" + hw_debounce_time + ")"); EditText textDelay = (EditText)findViewById(R.id.debounce_delay); textDelay.setText(Integer.toString(module.getSavedDelay())); @@ -127,6 +150,10 @@ public class MS2Debounce extends Activity textPoll.setText(Integer.toString(module.getSavedPoll())); textPoll.setEnabled(true); + EditText textHwDebounceTime = (EditText)findViewById(R.id.hw_debounce_time); + textHwDebounceTime.setText(Integer.toString(module.getSavedHwDebounceTime())); + textHwDebounceTime.setEnabled(true); + Button set = (Button)findViewById(R.id.set); if (loaded) { set.setEnabled(true); @@ -155,6 +182,10 @@ public class MS2Debounce extends Activity } else { on_boot.setEnabled(false); } + + CheckBox hw_debounce = (CheckBox)findViewById(R.id.hw_debounce); + hw_debounce.setChecked(module.getSavedHwDebounce()); + hw_debounce.setEnabled(true); } private void disableUI() { @@ -167,6 +198,9 @@ public class MS2Debounce extends Activity EditText textPoll = (EditText)findViewById(R.id.poll_time); textPoll.setEnabled(false); + EditText textHwDebounceTime = (EditText)findViewById(R.id.hw_debounce_time); + textHwDebounceTime.setEnabled(false); + Button set = (Button)findViewById(R.id.set); set.setEnabled(false); @@ -178,6 +212,9 @@ public class MS2Debounce extends Activity CheckBox on_boot = (CheckBox)findViewById(R.id.on_boot); on_boot.setEnabled(false); + + CheckBox hw_debounce = (CheckBox)findViewById(R.id.hw_debounce); + hw_debounce.setEnabled(false); } public void loadModule(View view) { @@ -211,6 +248,12 @@ public class MS2Debounce extends Activity module.set_on_boot(on_boot.isChecked()); } + public void toggle_hw_debounce(View view) { + CheckBox hw_debounce = (CheckBox)view; + + module.setSavedHwDebounce(hw_debounce.isChecked()); + } + @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater();