One settings table in CameraBridge watches every camera value into the telemetry tick and backs a generic setCameraValue, so the tabbed camera menu (Exposure / Photo / Video / Other) is built from row specs and the camera's own capability ranges. Writes show at once and fall back to what the camera reports. Adds the quick exposure panel (Auto/A/S/M, ISO slider, shutter and aperture wheels, EV strip, metered EV in M), a new camera column with record timer and interval/pano progress, a zoom column for zoom cameras, tap-to-focus / tap-to-meter, and a live histogram. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
92 lines
3.0 KiB
Dart
92 lines
3.0 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
/// The video overlay grid (camera menu → Other, and the rail's GRID button).
|
|
enum GridStyle {
|
|
off('Off'),
|
|
thirds('Grid'),
|
|
diagonals('Grid + diagonals');
|
|
|
|
const GridStyle(this.label);
|
|
final String label;
|
|
}
|
|
|
|
/// What a long press on the live view does (GO 4's "Long Press" setting); a
|
|
/// single tap always focuses, or meters on fixed-focus cameras.
|
|
enum LongPressAction {
|
|
meter('Spot meter'),
|
|
focus('Focus'),
|
|
off('Nothing');
|
|
|
|
const LongPressAction(this.label);
|
|
final String label;
|
|
}
|
|
|
|
/// Device-local switches for the flight screen, persisted across launches.
|
|
abstract final class FlyPrefs {
|
|
static const String _classicKey = 'fly.classicHud';
|
|
static const String _perfKey = 'fly.perfOverlay';
|
|
static const String _gridKey = 'fly.grid';
|
|
static const String _centerKey = 'fly.centerPoint';
|
|
static const String _longPressKey = 'fly.longPress';
|
|
|
|
/// Open the pre-P2 `FlightControlPage` instead of the HUD v2 — kept
|
|
/// reachable until P3's safety flows pass their simulator run (plan P2/P3).
|
|
static final ValueNotifier<bool> classicHud = ValueNotifier<bool>(false);
|
|
|
|
/// Flutter's performance overlay on the flight screen, for the P2 "no jank at
|
|
/// 10 Hz" check.
|
|
static final ValueNotifier<bool> perfOverlay = ValueNotifier<bool>(false);
|
|
|
|
static final ValueNotifier<GridStyle> grid = ValueNotifier<GridStyle>(GridStyle.off);
|
|
static final ValueNotifier<bool> centerPoint = ValueNotifier<bool>(true);
|
|
static final ValueNotifier<LongPressAction> longPress = ValueNotifier<LongPressAction>(LongPressAction.meter);
|
|
|
|
static SharedPreferences? _prefs;
|
|
|
|
static Future<void> load() async {
|
|
try {
|
|
_prefs = await SharedPreferences.getInstance();
|
|
classicHud.value = _prefs!.getBool(_classicKey) ?? false;
|
|
perfOverlay.value = _prefs!.getBool(_perfKey) ?? false;
|
|
grid.value = _byName(GridStyle.values, _prefs!.getString(_gridKey)) ?? GridStyle.off;
|
|
centerPoint.value = _prefs!.getBool(_centerKey) ?? true;
|
|
longPress.value = _byName(LongPressAction.values, _prefs!.getString(_longPressKey)) ?? LongPressAction.meter;
|
|
} catch (_) {
|
|
// Storage unavailable: run on the defaults.
|
|
}
|
|
}
|
|
|
|
static Future<void> setClassicHud(bool on) async {
|
|
classicHud.value = on;
|
|
await _prefs?.setBool(_classicKey, on);
|
|
}
|
|
|
|
static Future<void> setPerfOverlay(bool on) async {
|
|
perfOverlay.value = on;
|
|
await _prefs?.setBool(_perfKey, on);
|
|
}
|
|
|
|
static Future<void> setGrid(GridStyle g) async {
|
|
grid.value = g;
|
|
await _prefs?.setString(_gridKey, g.name);
|
|
}
|
|
|
|
static Future<void> setCenterPoint(bool on) async {
|
|
centerPoint.value = on;
|
|
await _prefs?.setBool(_centerKey, on);
|
|
}
|
|
|
|
static Future<void> setLongPress(LongPressAction a) async {
|
|
longPress.value = a;
|
|
await _prefs?.setString(_longPressKey, a.name);
|
|
}
|
|
|
|
static T? _byName<T extends Enum>(List<T> values, String? name) {
|
|
for (final T v in values) {
|
|
if (v.name == name) return v;
|
|
}
|
|
return null;
|
|
}
|
|
}
|