Skip to content

Commit

Permalink
Make debug info line optional
Browse files Browse the repository at this point in the history
  • Loading branch information
vicnevicne committed May 7, 2022
1 parent 1f2a1c8 commit 6c7f17a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,9 @@ public boolean onMenuItemClick(MenuItem item) {
case R.id.change_sensor_type:
changeSensorType();
return true;
case R.id.toggle_debug_info:
inclinometerView.setShowDebug(!inclinometerView.isShowDebug());
return true;
case R.id.factory_reset:
factoryReset9();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class InclinometerView extends View {
private float centerY;
private float radius;
private float tiltCompensationAngle, rollCompensationAngle;
private boolean showDebug = false;

public InclinometerView(Context context) {
this(context, null);
Expand Down Expand Up @@ -122,6 +123,14 @@ public void setConnectionStatus(String connectionStatus) {
invalidate();
}

public boolean isShowDebug() {
return showDebug;
}

public void setShowDebug(boolean showDebug) {
this.showDebug = showDebug;
}

@Override
protected void onConfigurationChanged(Configuration newConfig) {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE || newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Expand Down Expand Up @@ -280,8 +289,10 @@ protected void onDraw(Canvas canvas) {
connectionStatusTextPaint.getTextBounds(connectionStatus, 0, connectionStatus.length(), bounds);
canvas.drawText(connectionStatus, canvas.getWidth() - bounds.width() - 5, canvas.getHeight() - 5, connectionStatusTextPaint);

// 4. Debug
canvas.drawText("" + roll + " ; " + tilt + " ; " + angleArray[2], 0, canvas.getHeight() - 5, debugTextPaint);
if (showDebug) {
// 4. Debug
canvas.drawText("" + roll + " ; " + tilt + " ; " + angleArray[2], 0, canvas.getHeight() - 5, debugTextPaint);
}
}

// double-buffering ?
Expand Down
1 change: 1 addition & 0 deletions Main/src/main/res/menu/option_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<item android:id="@+id/system" android:title="@string/system" app:showAsAction="never">
<menu>
<item android:id="@+id/change_sensor_type" android:title="@string/change_sensor_type" app:showAsAction="never"/>
<item android:id="@+id/toggle_debug_info" android:title="@string/toggle_debug_info" app:showAsAction="never"/>
<item android:id="@+id/factory_reset" android:title="@string/factory_reset" app:showAsAction="never"/>
<item android:id="@+id/sleep" android:title="@string/sleep" app:showAsAction="never"/>
<item android:id="@+id/algorithm" android:title="@string/algorithm" app:showAsAction="never"/>
Expand Down
1 change: 1 addition & 0 deletions Main/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,6 @@
<string name="current">Current</string>

<string name="change_sensor_type">Change sensor type</string>
<string name="toggle_debug_info">Toggle debug info</string>

</resources>

0 comments on commit 6c7f17a

Please sign in to comment.