summaryrefslogtreecommitdiffstats
path: root/app/qml/Main.qml
diff options
context:
space:
mode:
Diffstat (limited to 'app/qml/Main.qml')
-rw-r--r--app/qml/Main.qml57
1 files changed, 46 insertions, 11 deletions
diff --git a/app/qml/Main.qml b/app/qml/Main.qml
index 188fa86..471d160 100644
--- a/app/qml/Main.qml
+++ b/app/qml/Main.qml
@@ -11,17 +11,54 @@ ApplicationWindow {
title: "Turn By Turn Navigation Demo"
height: Window.height
width: Window.width
+ flags: Qt.FramelessWindowHint
visible: true
property double vehicleSpeed: 0
property double engineSpeed: 0
+ property bool mphDisplay: false
+
+ Component.onCompleted : {
+ VehicleSignals.connect()
+ }
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
+
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Engine.Speed")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Cluster.Mode")
+ VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ }
- onSignalEvent: {
- //console.log ("Received uid = " + uid + ", value = " + value)
- if (uid === "event.info" && value === "true") {
+ onGetSuccessResponse: {
+ //console.log("response path = " + path + ", value = " + value)
+ if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ mphDisplay = false
+ } else if (value === "mi") {
+ mphDisplay = true
+ }
+ }
+ }
+
+ onSignalNotification: {
+ //console.log("signal path = " + path + ", value = " + value)
+ if (path === "Vehicle.Speed") {
+ // value units are always km/h
+ if (mphDisplay)
+ vehicleSpeed = parseFloat(value) * 0.621504
+ else
+ vehicleSpeed = parseFloat(value)
+ } else if (path === "Vehicle.Powertrain.CombustionEngine.Engine.Speed") {
+ engineSpeed = parseFloat(value)
+ } else if (path === "Vehicle.Cabin.Infotainment.Cluster.Mode" && value === "true") {
console.log ("Switching views!")
console.log ("currentIndex = " + container.currentIndex)
if (container.currentIndex === 0) {
@@ -31,14 +68,12 @@ ApplicationWindow {
console.log ("Switching to map")
container.currentIndex = 0
}
- } else if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "km/h") {
- speed_tmp /= 1.609
+ } else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ mphDisplay = false
+ } else if (value === "mi") {
+ mphDisplay = true
}
- vehicleSpeed = speed_tmp
- } else if (uid === "event.engine.speed") {
- engineSpeed = parseFloat(value)
}
}
}