App 2.23.0: Overview styles Retro and Futuristic; read every 0.2 s

Retro: an 80s vacuum fluorescent cluster with seven-segment digits,
bar graphs and a lit P R N D selector. Futuristic: a hairline HUD with
an animated energy flow between battery and wheel, a turning speed ring
and a power arc. Both show unread values as dashes. The Overview now
reads the car five times a second. Emulator only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
2026-10-24 19:32:07 +02:00
co-authored by Claude Opus 5.5
parent c649ff6e28
commit d9f6e368cf
16 changed files with 779 additions and 10 deletions
@@ -68,6 +68,7 @@ public class MainActivity extends AppCompatActivity {
private View vehiclePane;
private View gaugesPane;
private View cockpitPane;
private View retroPane, futuristicPane;
private View consumptionPane;
private View chargingPane;
/** Display, battery, charging price and Wi-Fi. */
@@ -246,6 +247,8 @@ public class MainActivity extends AppCompatActivity {
vehiclePane = inflatePane(R.layout.pane_vehicle);
gaugesPane = inflatePane(R.layout.pane_gauges);
cockpitPane = inflatePane(R.layout.pane_cockpit);
retroPane = inflatePane(R.layout.pane_retro);
futuristicPane = inflatePane(R.layout.pane_futuristic);
// The Overview page holds both styles; Settings → Overview style picks the one shown.
android.widget.FrameLayout overviewPage = new android.widget.FrameLayout(this);
overviewPage.setLayoutParams(new android.view.ViewGroup.LayoutParams(
@@ -254,6 +257,8 @@ public class MainActivity extends AppCompatActivity {
overviewPage.addView(vehiclePane);
overviewPage.addView(gaugesPane);
overviewPage.addView(cockpitPane);
overviewPage.addView(retroPane);
overviewPage.addView(futuristicPane);
consumptionPane = inflatePane(R.layout.pane_consumption);
chargingPane = inflatePane(R.layout.pane_charging);
settingsPane = inflatePane(R.layout.pane_settings);
@@ -1343,10 +1348,13 @@ public class MainActivity extends AppCompatActivity {
* is not work to repeat every two seconds. A read that throws leaves the cells as they
* were rather than blanking the page — a transient miss is not news worth showing.
*/
// ---------- Overview: read every half second, off the main thread ----------
// ---------- Overview: read five times a second, off the main thread ----------
/** How often the Overview reads the car while it is on screen. */
private static final long OVERVIEW_REFRESH_MS = 500L;
/**
* How often the Overview reads the car while it is on screen: 0.2 s, so needles, rings and
* the speed follow the car closely. A read still running makes the next tick skip.
*/
private static final long OVERVIEW_REFRESH_MS = 200L;
/** One reader thread; a read that is still running makes the next tick skip, not queue. */
private final java.util.concurrent.ExecutorService carReader =
@@ -1434,7 +1442,7 @@ public class MainActivity extends AppCompatActivity {
private Double dashTripKm;
/** The stored values of the Overview styles, in the order of the drop-down. */
private static final String[] OVERVIEW_STYLES = { "TILES", "GAUGES", "COCKPIT" };
private static final String[] OVERVIEW_STYLES = { "TILES", "GAUGES", "COCKPIT", "RETRO", "FUTURISTIC" };
/** The chosen style's index in {@link #OVERVIEW_STYLES}; anything unknown is Tiles. */
private int overviewStyle() {
@@ -1449,12 +1457,15 @@ public class MainActivity extends AppCompatActivity {
vehiclePane.setVisibility(style == 0 ? View.VISIBLE : View.GONE);
gaugesPane.setVisibility(style == 1 ? View.VISIBLE : View.GONE);
cockpitPane.setVisibility(style == 2 ? View.VISIBLE : View.GONE);
retroPane.setVisibility(style == 3 ? View.VISIBLE : View.GONE);
futuristicPane.setVisibility(style == 4 ? View.VISIBLE : View.GONE);
}
/** Tiles (the cards), Gauges (needles) or Cockpit (rings); all are fed on every reading. */
/** Tiles, Gauges, Cockpit, Retro or Futuristic; all are fed on every reading. */
private void bindOverviewStyle() {
String[] labels = { getString(R.string.overview_style_tiles), getString(R.string.overview_style_gauges),
getString(R.string.overview_style_cockpit) };
getString(R.string.overview_style_cockpit), getString(R.string.overview_style_retro),
getString(R.string.overview_style_futuristic) };
bindChoices(settingsPane.findViewById(R.id.overview_style_choices), labels, overviewStyle(),
position -> {
prefs.edit().putString(PREF_OVERVIEW_STYLE, OVERVIEW_STYLES[position]).apply();
@@ -1478,6 +1489,30 @@ public class MainActivity extends AppCompatActivity {
dashBattery.setWarnBelow(20f);
}
// ---------- Retro and Futuristic (Overview styles, each one drawn view) ----------
private final java.text.SimpleDateFormat clockFormat =
new java.text.SimpleDateFormat("HH:mm", java.util.Locale.US);
private void showDrawnStyles(EnergySnapshot s) {
RetroView retro = retroPane.findViewById(R.id.retro_view);
FlowView flow = futuristicPane.findViewById(R.id.flow_view);
ClusterValues v = new ClusterValues();
v.socPercent = s.getSocPercent();
v.rangeKm = s.getRangeKm();
v.powerKw = s.getBatteryPowerKw();
v.speedKmh = s.getSpeedKmh();
v.gear = s.getGearRaw();
v.usage5Min = cockpitAverage == null ? null : cockpitAverage.kwhPer100Km;
v.usageTrip = cockpitTrip == null ? null : cockpitTrip.kwhPer100Km;
v.tripKm = cockpitTrip == null ? null : cockpitTrip.distanceKm;
v.climateCelsius = s.getClimate().getDriverTargetCelsius();
v.odometerKm = s.getOdometerKm();
v.clock = clockFormat.format(new java.util.Date());
retro.setValues(v);
flow.setValues(v);
}
// ---------- Cockpit (Overview style) ----------
/** Power over the last two minutes, a slot per second. */
@@ -1578,6 +1613,7 @@ public class MainActivity extends AppCompatActivity {
vehTireRr.setText(unit.format(s.getTirePressures().getRearRightKpa()));
showGauges(s);
showCockpit(s);
showDrawnStyles(s);
} catch (Throwable ignored) {
// Leave the last good reading on screen.
}