dcafc04cbc
Link on the left (with the menu on the Dash), then hot temperature, CAN, OBD while connected, GNSS fix and satellites, LTE, WiFi, UPS, and the dark/bright button. The Dash's own top line is gone into it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
163 lines
6.5 KiB
Dart
163 lines
6.5 KiB
Dart
// The software dash: smart-serow's HUD layout and widgets, fed from the boundary.
|
|
// A grid of boxes (lib/widgets/stat_box.dart): the instruments and the big numbers
|
|
// in the main row, smaller readouts and telltales below. Every value names its
|
|
// signal from contracts' signals.json and nothing else (app guideline 1).
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import '../link/boundary.dart';
|
|
import '../link/reading.dart';
|
|
import '../theme/palette.dart';
|
|
import '../widgets/accel_graph.dart';
|
|
import '../widgets/gps_compass.dart';
|
|
import '../widgets/stat_box.dart';
|
|
import '../widgets/telltale.dart';
|
|
import '../widgets/whiskey_mark.dart';
|
|
|
|
class DashPage extends StatelessWidget {
|
|
const DashPage({super.key, required this.boundary});
|
|
final Boundary boundary;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListenableBuilder(
|
|
listenable: boundary,
|
|
builder: (context, _) {
|
|
final p = AppTheme.of(context);
|
|
final b = boundary;
|
|
Reading r(String n) => Reading.of(b, n);
|
|
final rpm = r('engine_rpm');
|
|
// CAN for display (project-yukart decision 30); GNSS beside it, to show their difference.
|
|
final speed = r('vehicle_speed_kph');
|
|
final gnss = r('gnss_speed_kph');
|
|
final pedal = r('accel_pedal_pct');
|
|
final coolant = r('coolant_temp_c');
|
|
final lat = r('imu_accel_lat_g');
|
|
final lon = r('imu_accel_lon_g');
|
|
// The compass's states, from gnss_fix: none → acquiring, 2d/3d → fix, missing → none known.
|
|
final fix = r('gnss_fix');
|
|
final gpsState = fix.value == null
|
|
? null
|
|
: fix.value == 'none'
|
|
? 'acquiring'
|
|
: 'fix';
|
|
|
|
return Scaffold(
|
|
backgroundColor: p.background,
|
|
body: SafeArea(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
|
child: Column(
|
|
children: [
|
|
// Main area: instruments and the big numbers.
|
|
Expanded(
|
|
flex: 7,
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: WhiskeyMark(
|
|
roll: r('imu_roll_deg').number,
|
|
pitch: r('imu_pitch_deg').number,
|
|
),
|
|
),
|
|
Expanded(
|
|
child: AccelGraph(
|
|
ax: lat.number,
|
|
ay: lon.number,
|
|
maxG: 0.8,
|
|
ghostTrackPeriod: const Duration(seconds: 4),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Column(
|
|
children: [
|
|
StatBoxMain(
|
|
value: rpm.fixed(),
|
|
label: 'RPM',
|
|
dim: rpm.dim,
|
|
isWarning: () => (rpm.number ?? 0) > 6000,
|
|
),
|
|
StatBoxMain(
|
|
value: speed.fixed(),
|
|
unit: 'km/h',
|
|
label: 'SPEED · GNSS ${gnss.fixed()}',
|
|
dim: speed.dim,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Bottom row: smaller readouts and telltales.
|
|
Expanded(
|
|
flex: 2,
|
|
child: Row(
|
|
children: [
|
|
StatBox(
|
|
value: pedal.fixed(),
|
|
unit: '%',
|
|
label: 'PEDAL',
|
|
dim: pedal.dim,
|
|
),
|
|
StatBox(
|
|
value: coolant.fixed(),
|
|
unit: '°C',
|
|
label: 'COOLANT',
|
|
dim: coolant.dim,
|
|
isWarning: () => (coolant.number ?? 0) > 105,
|
|
),
|
|
Expanded(
|
|
child: GpsCompass(
|
|
heading: r('gnss_heading_deg').number,
|
|
gpsState: gpsState,
|
|
),
|
|
),
|
|
Telltale(
|
|
label: 'LEFT',
|
|
icon: Icons.arrow_left,
|
|
reading: r('indicator_left'),
|
|
),
|
|
Telltale(
|
|
label: 'RIGHT',
|
|
icon: Icons.arrow_right,
|
|
reading: r('indicator_right'),
|
|
),
|
|
Telltale(
|
|
label: 'BRAKE',
|
|
reading: r('brake_pedal'),
|
|
),
|
|
Telltale(
|
|
label: 'PARK',
|
|
reading: r('handbrake'),
|
|
warn: true,
|
|
),
|
|
Telltale(
|
|
label: 'LIGHTS',
|
|
reading: r('side_lights'),
|
|
),
|
|
Telltale(
|
|
label: 'DOOR',
|
|
reading: r('door_open'),
|
|
warn: true,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|