summaryrefslogtreecommitdiffstats
path: root/app/ValueSource.qml
diff options
context:
space:
mode:
Diffstat (limited to 'app/ValueSource.qml')
-rw-r--r--app/ValueSource.qml77
1 files changed, 56 insertions, 21 deletions
diff --git a/app/ValueSource.qml b/app/ValueSource.qml
index 80ef95c..511a2a1 100644
--- a/app/ValueSource.qml
+++ b/app/ValueSource.qml
@@ -53,7 +53,7 @@ import QtQuick 2.2
Item {
id: valueSource
property real kph: 0
- property bool mphDisplay: true
+ property bool mphDisplay: false
property real speedScaling: mphDisplay == true ? 0.621504 : 1.0
property real rpm: 1
property real fuel: 0.85
@@ -96,46 +96,81 @@ Item {
return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow;
}
+ Component.onCompleted : {
+ if(!runAnimation) {
+ VehicleSignals.connect()
+ }
+ }
+
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
+
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Speed")
+ VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.CruiseEnable")
+ VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.CruiseSet")
+ VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.CruiseResume")
+ VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.CruiseCancel")
+ VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.LaneDepartureWarning")
+ VehicleSignals.subscribe("Vehicle.Cabin.SteeringWheel.Switches.Info")
+ VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ }
- onSignalEvent: {
- if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "mph") {
- speed_tmp *= 1.609
+ onGetSuccessResponse: {
+ //console.log("response path = " + path + ", value = " + value)
+ if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ valueSource.mphDisplay = false
+ } else if (value === "mi") {
+ valueSource.mphDisplay = true
}
+ }
+ }
+
+ onSignalNotification: {
+ //console.log("signal path = " + path + ", value = " + value)
+ if (path === "Vehicle.Speed") {
+ // units are always km/h
+ // Checking Vehicle.Cabin.Infotainment.HMI.DistanceUnit for the
+ // display unit would likely be a worthwhile enhancement.
if(!runAnimation) {
- valueSource.kph = speed_tmp
+ valueSource.kph = parseFloat(value)
}
- }
- else if (uid === "event.engine.speed") {
+ } else if (path === "Vehicle.Powertrain.CombustionEngine.Speed") {
if(!runAnimation) {
valueSource.rpm = parseFloat(value) / 1000
}
- }
- else if (uid === "event.cruise.enable" && value === "true") {
+ } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.CruiseEnable" && value === "true") {
if(valueSource.cruiseEnabled) {
valueSource.cruiseEnabled = false
valueSource.cruiseSet = false
} else {
valueSource.cruiseEnabled = true
}
- }
- else if ((uid === "event.cruise.set" || uid === "event.cruise.resume") &&
- value === "true") {
+ } else if ((path === "Vehicle.Cabin.SteeringWheel.Switches.CruiseSet" ||
+ path === "Vehicle.Cabin.SteeringWheel.Switches.CruiseResume") &&
+ value == "true") {
if(valueSource.cruiseEnabled) {
valueSource.cruiseSet = true
}
- }
- else if (uid === "event.cruise.cancel" && value === "true") {
+ } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.CruiseCancel" && value === "true") {
valueSource.cruiseSet = false
- }
- else if (uid === "event.lane_departure_warning.enable" && value === "true") {
+ } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.LaneDepartureWarning" && value === "true") {
valueSource.laneDepartureWarnEnabled = !valueSource.laneDepartureWarnEnabled
- }
- else if (uid === "event.info" && value === "true") {
+ } else if (path === "Vehicle.Cabin.SteeringWheel.Switches.Info" && value === "true") {
valueSource.displayNumericSpeeds = !valueSource.displayNumericSpeeds
+ } else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ valueSource.mphDisplay = false
+ } else if (value === "mi") {
+ valueSource.mphDisplay = true
+ }
}
}
}