Auto dark/bright follows the sun at the tablet's own location
/ crosscheck (push) Successful in 1s
CI / Analyze & Test (push) Successful in 22s
CI / Debug APK (push) Successful in 39s

Without a light sensor an app may read (the Redmi Pad SE has none), auto is dark while
the sun is more than 4° below the horizon (lib/theme/sun.dart), at Android's coarse
location, polled and kept across restarts. The tablet's own, not the Orin's GNSS: the
tablet has its own GNSS and cellular. Android's dark theme is the last fallback.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 22:33:43 +09:00
parent 317de3425a
commit 31a844bb94
9 changed files with 164 additions and 19 deletions
+12 -9
View File
@@ -1,16 +1,18 @@
// Yukart display: the tablet app. Starts the link to the Orin and hands the screen to
// the shell (lib/shell.dart). Code layout: lib/README.md.
import 'dart:async';
import 'package:flutter/material.dart';
import 'link/boundary.dart';
import 'link/net.dart';
import 'link/reading.dart';
import 'pages/link_test.dart';
import 'shell.dart';
import 'shell_scope.dart';
import 'theme/light.dart';
import 'theme/palette.dart';
import 'theme/sun.dart';
/// Override for development, e.g. `--dart-define=YUKART_GW=ws://halogen.local:7700/`.
const defaultUrl = String.fromEnvironment(
@@ -25,14 +27,15 @@ Future<void> main() async {
final usb = UsbLink();
await usb.bindFor(Uri.parse(defaultUrl));
final boundary = Boundary(defaultUrl)..start();
// The sun, for auto dark/bright: the car's position while GNSS has one.
boundary.addListener(() {
final lat = Reading.of(boundary, 'gnss_lat');
final lon = Reading.of(boundary, 'gnss_lon');
if (!lat.dim && !lon.dim && lat.number != null && lon.number != null) {
themes.setPosition(lat.number!, lon.number!);
}
});
// The sun, for auto dark/bright: the tablet's own location, every minute until there
// is one (the first ask brings up the permission), then every ten.
Future<void> locate() async {
final p = await androidLocation();
if (p != null) themes.setPosition(p.$1, p.$2);
Timer(Duration(minutes: p == null ? 1 : 10), locate);
}
locate();
final linkTest = LinkTest(usb);
// Development hook: `am start ... --es linktest [dl:|bi:]<label>[@<host>]` runs the test
// (`dl:` the download series, `bi:` burst latency against idle gaps), on the gateway's host unless one is given.