summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/CMakeLists.txt5
-rw-r--r--app/ValueSource.qml80
-rw-r--r--app/main.cpp5
3 files changed, 64 insertions, 26 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index e786164..d78eed6 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -69,17 +69,18 @@ add_executable(${PROJECT_NAME}
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
+pkg_check_modules(QTAPPFW_VEHICLE_SIGNALS REQUIRED qtappfw-vehicle-signals)
include_directories(
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
- ${QTAPPFW_INCLUDE_DIRS}
+ ${QTAPPFW_VEHICLE_SIGNALS_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
Qt5::QuickControls2
Qt5::QuickWidgets
- ${QTAPPFW_LIBRARIES}
+ ${QTAPPFW_VEHICLE_SIGNALS_LIBRARIES}
${GLIB_LDFLAGS}
${WAYLAND_CLIENT_LIBRARIES}
)
diff --git a/app/ValueSource.qml b/app/ValueSource.qml
index 80ef95c..24a3a5f 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,78 @@ Item {
return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow;
}
+ Component.onCompleted : {
+ if(!runAnimation) {
+ VehicleSignals.connect()
+ }
+ }
+
Connections {
- target: SignalComposer
+ target: VehicleSignals
+
+ onConnected: {
+ VehicleSignals.authorize()
+ }
- onSignalEvent: {
- if (uid === "event.vehicle.speed") {
- var speed_tmp = parseFloat(value)
- if(units == "mph") {
- speed_tmp *= 1.609
+ onAuthorized: {
+ VehicleSignals.subscribe("Vehicle.Speed")
+ VehicleSignals.subscribe("Vehicle.Powertrain.CombustionEngine.Engine.Speed")
+ VehicleSignals.subscribe("Vehicle.ADAS.CruiseControl.IsActive")
+ VehicleSignals.subscribe("Vehicle.ADAS.CruiseControl.IsSet")
+ VehicleSignals.subscribe("Vehicle.ADAS.LaneDepartureDetection.IsActive")
+ VehicleSignals.subscribe("Vehicle.Cabin.Infotainment.Cluster.Mode")
+ 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") {
+ 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.Engine.Speed") {
if(!runAnimation) {
valueSource.rpm = parseFloat(value) / 1000
}
- }
- else if (uid === "event.cruise.enable" && value === "true") {
+ } else if (path === "Vehicle.ADAS.CruiseControl.IsActive" && 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") {
- if(valueSource.cruiseEnabled) {
- valueSource.cruiseSet = true
+ } else if (path === "Vehicle.ADAS.CruiseControl.IsSet") {
+ if (value === "true") {
+ if(valueSource.cruiseEnabled)
+ valueSource.cruiseSet = true
+ } else {
+ valueSource.cruiseSet = false
}
- }
- else if (uid === "event.cruise.cancel" && value === "true") {
- valueSource.cruiseSet = false
- }
- else if (uid === "event.lane_departure_warning.enable" && value === "true") {
+ } else if (path === "Vehicle.ADAS.LaneDepartureDetection.IsActive" && value === "true") {
valueSource.laneDepartureWarnEnabled = !valueSource.laneDepartureWarnEnabled
- }
- else if (uid === "event.info" && value === "true") {
+ } else if (path === "Vehicle.Cabin.Infotainment.Cluster.Mode" && 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
+ }
}
}
}
diff --git a/app/main.cpp b/app/main.cpp
index 14c2ead..3d02a51 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -35,6 +35,8 @@
#include <wayland-client.h>
#include "agl-shell-client-protocol.h"
+#include <vehiclesignals.h>
+
// Global indicating whether canned animation should run
bool runAnimation = true;
@@ -170,6 +172,9 @@ int main(int argc, char *argv[])
QQmlContext *context = engine.rootContext();
context->setContextProperty("runAnimation", runAnimation);
+ VehicleSignalsConfig vsConfig(myname);
+ context->setContextProperty("VehicleSignals", new VehicleSignals(vsConfig));
+
QQmlComponent bg_comp(&engine, QUrl("qrc:/cluster-gauges.qml"));
qDebug() << bg_comp.errors();
struct wl_surface *bg = create_component(native, &bg_comp, screen, &qobj_bg);