From b53c55799ff50fb51bec1bf75bac477fa4165336 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Tue, 7 Jun 2022 15:39:51 -0400 Subject: Updates to restore to a functional state Changes: - Add setenv of QT_QUICK_CONTROLS_STYLE and setting of the frameless window hint to match the previous behavior before the removal of the previous application framework. - Use the new VehicleSignals API from libqtappfw to replace the previous signal-composer usage. - Update the use of the Navigation API from libqtappfw for its rework to use VIS signals instead of the previous signal-composer usage. - The default unit for the vehicle speed has been switched to kilometers with switching driven by the appropriate VSS schema value. Bug-AGL: SPEC-4409, SPEC-4426 Signed-off-by: Scott Murray Change-Id: I69b60a1e3207a54c34aaf114a1e89fce2cf0059f --- app/qml/InfoWindow.qml | 2 +- app/qml/Main.qml | 57 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 12 deletions(-) (limited to 'app/qml') diff --git a/app/qml/InfoWindow.qml b/app/qml/InfoWindow.qml index 4acba5d..7183040 100644 --- a/app/qml/InfoWindow.qml +++ b/app/qml/InfoWindow.qml @@ -53,7 +53,7 @@ Rectangle { Layout.fillWidth: true Layout.alignment: Qt.AlignHCenter - text: "MPH" + text: tbtnavi.mphDisplay ? "MPH" : "KPH" color: "white" font.pixelSize: 32 font.bold: true 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) } } } -- cgit 1.2.3-korg