aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers/val_client.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers/val_client.dart')
-rw-r--r--lib/data/data_providers/val_client.dart28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/data/data_providers/val_client.dart b/lib/data/data_providers/val_client.dart
index 173dbfb..8436012 100644
--- a/lib/data/data_providers/val_client.dart
+++ b/lib/data/data_providers/val_client.dart
@@ -35,6 +35,13 @@ class ValClient {
metadata = {'authorization': "Bearer ${config.authorization}"};
}
+ // Push out persisted user preferences so databroker defaults
+ // will not overwrite them.
+ var units = ref.read(unitStateProvider);
+ setDistanceUnit(units.distanceUnit);
+ setTemperatureUnit(units.temperatureUnit);
+ setPressureUnit(units.pressureUnit);
+
// Initialize signal states
for (int i = 0; i < signals.length; i++) {
get(signals[i]);
@@ -145,4 +152,25 @@ class ValClient {
handleSignalUpdate(entry);
}
}
+
+ void setDistanceUnit(DistanceUnit unit) async {
+ setString(VSSPath.vehicleHmiDistanceUnit,
+ unit == DistanceUnit.kilometers ? "KILOMETERS" : "MILES",
+ true,
+ );
+ }
+
+ void setTemperatureUnit(TemperatureUnit unit) async {
+ setString(VSSPath.vehicleHmiTemperatureUnit,
+ unit == TemperatureUnit.celsius ? "C" : "F",
+ true,
+ );
+ }
+
+ void setPressureUnit(PressureUnit unit) async {
+ setString(VSSPath.vehicleHmiPressureUnit,
+ unit == PressureUnit.kilopascals ? "KPA" : "PSI",
+ true,
+ );
+ }
}