From 4e33a076180bbffda09e03bcfba9ad1fa99ca7e7 Mon Sep 17 00:00:00 2001
From: Filiprogrammer <44641787+Filiprogrammer@users.noreply.github.com>
Date: Wed, 18 Jan 2023 23:22:14 +0100
Subject: [PATCH 1/2] clients/android: Improve wheel speed indicators
Distinguish between forward and backward driving when displaying wheel
speeds on the wheel speed bars. Also show the mean speed of the two
wheels instead of an estimate.
---
.../filip/alphabotandroidclient/ControlActivity.java | 12 ++++++++----
.../app/src/main/res/layout/activity_control.xml | 4 ++--
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/clients/AlphabotAndroidClient/app/src/main/java/at/mg6/filip/alphabotandroidclient/ControlActivity.java b/clients/AlphabotAndroidClient/app/src/main/java/at/mg6/filip/alphabotandroidclient/ControlActivity.java
index 18bdf7f0..c0b21641 100644
--- a/clients/AlphabotAndroidClient/app/src/main/java/at/mg6/filip/alphabotandroidclient/ControlActivity.java
+++ b/clients/AlphabotAndroidClient/app/src/main/java/at/mg6/filip/alphabotandroidclient/ControlActivity.java
@@ -18,6 +18,7 @@
import android.widget.Button;
import java.math.BigInteger;
+import java.text.DecimalFormat;
import java.util.Timer;
import java.util.TimerTask;
@@ -380,8 +381,6 @@ public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
- kmphView.setText((Math.round((carSpeed / 40.0) * 10.0) / 10.0) + " km/h");
- mpsView.setText((Math.round((carSpeed / 144.0) * 10.0) / 10.0) + " m/s");
speedBar.setProgress(Math.max(0, Math.abs(carSpeed) - 60));
}
});
@@ -542,8 +541,13 @@ public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
- speedLeftBar.setProgress(Math.max(0, Math.abs(speed_left) - 20));
- speedRightBar.setProgress(Math.max(0, Math.abs(speed_right) - 20));
+ speedLeftBar.setProgress((Math.max(speed_left, 0) * 100) / 127);
+ speedLeftBar.setSecondaryProgress((Math.max(-speed_left, 0) * 100) / 127);
+ speedRightBar.setProgress((Math.max(speed_right, 0) * 100) / 127);
+ speedRightBar.setSecondaryProgress((Math.max(-speed_right, 0) * 100) / 127);
+ DecimalFormat decimalFormat = new DecimalFormat("#.##");
+ kmphView.setText(decimalFormat.format(((speed_left + speed_right) / 2.0) * 0.036) + " km/h");
+ mpsView.setText(decimalFormat.format(((speed_left + speed_right) / 2.0) * 0.01) + " m/s");
}
});
} else if (characteristic.getUuid().compareTo(bleHandler.CHAR_UUID_ERROR) == 0) {
diff --git a/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml b/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml
index c826da31..74229ec0 100644
--- a/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml
+++ b/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml
@@ -204,7 +204,7 @@
android:layout_weight="1"
android:layout_marginBottom="-4dp"
android:layout_marginTop="-4dp"
- android:max="64"
+ android:max="100"
android:progress="0" />
From 0e23977362ce091dc91ceb9097dea2344d5da636 Mon Sep 17 00:00:00 2001
From: Filiprogrammer <44641787+Filiprogrammer@users.noreply.github.com>
Date: Wed, 18 Jan 2023 23:31:58 +0100
Subject: [PATCH 2/2] clients/android: Beautify wheel speed bars
---
.../res/drawable/wheel_speed_progress_bar.xml | 30 +++++++++++++++++++
.../src/main/res/layout/activity_control.xml | 16 +++++-----
2 files changed, 38 insertions(+), 8 deletions(-)
create mode 100644 clients/AlphabotAndroidClient/app/src/main/res/drawable/wheel_speed_progress_bar.xml
diff --git a/clients/AlphabotAndroidClient/app/src/main/res/drawable/wheel_speed_progress_bar.xml b/clients/AlphabotAndroidClient/app/src/main/res/drawable/wheel_speed_progress_bar.xml
new file mode 100644
index 00000000..99abe301
--- /dev/null
+++ b/clients/AlphabotAndroidClient/app/src/main/res/drawable/wheel_speed_progress_bar.xml
@@ -0,0 +1,30 @@
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml b/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml
index 74229ec0..0c914d90 100644
--- a/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml
+++ b/clients/AlphabotAndroidClient/app/src/main/res/layout/activity_control.xml
@@ -200,24 +200,24 @@
android:id="@+id/speedLeftBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="8dp"
android:layout_weight="1"
- android:layout_marginBottom="-4dp"
- android:layout_marginTop="-4dp"
android:max="100"
- android:progress="0" />
+ android:progress="0"
+ android:secondaryProgress="0"
+ android:progressDrawable="@drawable/wheel_speed_progress_bar" />
+ android:secondaryProgress="0"
+ android:rotation="180"
+ android:progressDrawable="@drawable/wheel_speed_progress_bar" />