summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2022-06-07 15:25:07 -0400
committerScott Murray <scott.murray@konsulko.com>2022-07-04 21:15:58 +0000
commit4efe67714e60e2ab86acf1edee500373f6820954 (patch)
treed4e9327f1481452abac7d821200e5e0fa9d5789f
parent3fc84a0a674fa532f6aded100cf2beb3d0cf1f83 (diff)
Add VIS vehicle signal supportneedlefish_13.93.0needlefish/13.93.013.93.0
Use the new VehicleSignals API from libqtappfw to replace the previous signal-composer usage. Additionally, the default units for the vehicle speed and odometer have been switched to kilometers with switching driven by the appropriate VSS schema value. The units in the translated text labels have been left alone for now, if the Qt demo lifetime is extended this may be revisited. Bug-AGL: SPEC-4409 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ie04dc429b02adb7d763d2e5a3bfea0a5a1932b92 (cherry picked from commit f694b1f1222a58bdb3d1990fda9184fe51754af7)
-rw-r--r--app/Dashboard.qml59
-rw-r--r--app/app.pro2
-rw-r--r--app/main.cpp5
3 files changed, 53 insertions, 13 deletions
diff --git a/app/Dashboard.qml b/app/Dashboard.qml
index 1b61d4c..4af8a26 100644
--- a/app/Dashboard.qml
+++ b/app/Dashboard.qml
@@ -34,25 +34,58 @@ ApplicationWindow {
property double vehicleSpeed: 0
property double engineSpeed: 0
-/*
+ property bool mphDisplay: false
+
+ Component.onCompleted : {
+ VehicleSignals.connect()
+ }
+
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
- onSignalEvent: {
- if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "km/h") {
- speed_tmp /= 1.609
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Engine.Speed")
+ VehicleSignals.get("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.HMI.DistanceUnit")
+ }
+
+ 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
}
- vehicleSpeed = speed_tmp
}
- else if (uid === "event.engine.speed") {
+ }
+
+ 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)
tachometer.value = engineSpeed / 7000
+ } else if (path === "Vehicle.Cabin.Infotainment.HMI.DistanceUnit") {
+ if (value === "km") {
+ mphDisplay = false
+ } else if (value === "mi") {
+ mphDisplay = true
+ }
}
}
}
-*/
+
Item {
id: container
anchors.centerIn: parent
@@ -64,20 +97,20 @@ ApplicationWindow {
anchors.left: parent.left
anchors.top: parent.top
anchors.margins: 20
- text: vehicleSpeed.toFixed(0) /* MPH */
+ text: vehicleSpeed.toFixed(0)
font.pixelSize: 256
}
Label {
id: unit
anchors.left: speed.right
anchors.baseline: speed.baseline
- text: 'MPH'
+ text: root.mphDisplay ? 'MPH' : "KPH"
font.pixelSize: 64
}
Label {
anchors.left: unit.left
anchors.top: unit.bottom
- text: '10,000.5 miles'
+ text: root.mphDisplay ? '10,000.5 miles' : "10,000.5 km"
font.pixelSize: 32
opacity: 0.5
}
diff --git a/app/app.pro b/app/app.pro
index daf4a4c..3fa2880 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -3,6 +3,8 @@ TARGET = dashboard
QT = qml quick
CONFIG += c++11 link_pkgconfig
+PKGCONFIG += qtappfw-vehicle-signals
+
HEADERS += \
translator.h
diff --git a/app/main.cpp b/app/main.cpp
index ec7b4a1..2327b05 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -17,6 +17,8 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
+#include <QQmlContext>
+#include <vehiclesignals.h>
#include "translator.h"
@@ -28,6 +30,9 @@ int main(int argc, char *argv[])
app.setDesktopFileName("dashboard");
QQmlApplicationEngine engine;
+ QQmlContext *context = engine.rootContext();
+ VehicleSignalsConfig vsConfig("dashboard");
+ context->setContextProperty("VehicleSignals", new VehicleSignals(vsConfig));
qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
engine.load(QUrl(QStringLiteral("qrc:/Dashboard.qml")));