From 6095052818bdee3e467f3674837d9279e0d697d0 Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Fri, 3 Jan 2020 18:13:33 -0500 Subject: Add signal-composer speed and steering wheel event support Changes include: - Pull in signal-composer support from libqtappfw - Add a configuration file that controls whether the existing canned animation behavior should be used, or events from signal-composer should drive speeds and indicators. - Add new icons provided by LF graphics team for cruise control and lane departure warning, and drive their state based on appropriate steering wheel events. - Hide/show the digital vehicle/engine speed values in the gauges based on the steering wheel info event. This is intended to work in sync with changes to tbtnavi to have it display larger speed indicators via an alternate page. Bug-AGL: SPEC-3045, SPEC-3049 Change-Id: I77249f65b80596fe7f2af9fe29b3ed86b63a8a45 Signed-off-by: Scott Murray --- app/CMakeLists.txt | 13 +++- app/DashboardGaugeStyle.qml | 1 + app/TachometerStyle.qml | 1 + app/ValueSource.qml | 54 +++++++++++++++- app/cluster-gauges.qml | 52 +++++++++++++--- app/images/AGL_Icons_CruiseControl.svg | 69 ++++++++++++++++++++ app/images/AGL_Icons_CruiseControl_green.svg | 70 +++++++++++++++++++++ app/images/AGL_Icons_CruiseControl_white.svg | 70 +++++++++++++++++++++ app/images/AGL_Icons_CruiseControl_yellow.svg | 70 +++++++++++++++++++++ app/images/AGL_Icons_LaneDeparture.svg | 89 ++++++++++++++++++++++++++ app/images/AGL_Icons_LaneDeparture_green.svg | 90 +++++++++++++++++++++++++++ app/images/AGL_Icons_LaneDeparture_red.svg | 90 +++++++++++++++++++++++++++ app/images/AGL_Icons_LaneDeparture_white.svg | 90 +++++++++++++++++++++++++++ app/images/AGL_Icons_LaneDeparture_yellow.svg | 90 +++++++++++++++++++++++++++ app/images/images.qrc | 8 +++ app/main.cpp | 43 ++++++++++++- conf.d/wgt/config.xml.in | 1 + 17 files changed, 888 insertions(+), 13 deletions(-) create mode 100644 app/images/AGL_Icons_CruiseControl.svg create mode 100644 app/images/AGL_Icons_CruiseControl_green.svg create mode 100644 app/images/AGL_Icons_CruiseControl_white.svg create mode 100644 app/images/AGL_Icons_CruiseControl_yellow.svg create mode 100644 app/images/AGL_Icons_LaneDeparture.svg create mode 100644 app/images/AGL_Icons_LaneDeparture_green.svg create mode 100644 app/images/AGL_Icons_LaneDeparture_red.svg create mode 100644 app/images/AGL_Icons_LaneDeparture_white.svg create mode 100644 app/images/AGL_Icons_LaneDeparture_yellow.svg diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 9547426..a09fd1d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -23,7 +23,7 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(OE_QMAKE_PATH_EXTERNAL_HOST_BINS $ENV{OE_QMAKE_PATH_HOST_BINS}) -find_package(Qt5 COMPONENTS Core Gui QuickControls2 WebSockets QuickWidgets REQUIRED) +find_package(Qt5 COMPONENTS Core Gui QuickControls2 QuickWidgets REQUIRED) find_package(PkgConfig REQUIRED) qt5_add_resources(RESOURCES cluster-gauges.qrc images/images.qrc) @@ -36,11 +36,18 @@ add_executable(${TARGET_NAME} ) pkg_check_modules(QLIBWINMGR REQUIRED qlibwindowmanager) +pkg_check_modules(QTAPPFW REQUIRED qtappfw) +pkg_check_modules(GLIB REQUIRED glib-2.0) + +include_directories( + ${QTAPPFW_INCLUDE_DIRS} + ${GLIB_INCLUDE_DIRS} +) set_target_properties(${TARGET_NAME} PROPERTIES LABELS "EXECUTABLE" PREFIX "" - COMPILE_FLAGS "${QLIBWINMGR_FLAGS} ${EXTRAS_CFLAGS} -DFOR_AFB_BINDING" + COMPILE_FLAGS "${QLIBWINMGR_FLAGS} ${QTAPPFW_FLAGS} ${GLIB_FLAGS} ${EXTRAS_CFLAGS} -DFOR_AFB_BINDING" LINK_FLAGS "${BINDINGS_LINK_FLAG}" LINK_LIBRARIES "${EXTRAS_LIBRARIES}" OUTPUT_NAME "${TARGET_NAME}" @@ -50,4 +57,6 @@ target_link_libraries(${TARGET_NAME} Qt5::QuickControls2 Qt5::QuickWidgets ${QLIBWINMGR_LIBRARIES} + ${QTAPPFW_LIBRARIES} + ${GLIB_LDFLAGS} ) diff --git a/app/DashboardGaugeStyle.qml b/app/DashboardGaugeStyle.qml index aafe50f..8615790 100644 --- a/app/DashboardGaugeStyle.qml +++ b/app/DashboardGaugeStyle.qml @@ -127,6 +127,7 @@ CircularGaugeStyle { anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.verticalCenter anchors.topMargin: toPixels(0.1) + visible: valueSource.displayNumericSpeeds === true readonly property int kphInt: control.value } diff --git a/app/TachometerStyle.qml b/app/TachometerStyle.qml index a632eab..03dfbd7 100644 --- a/app/TachometerStyle.qml +++ b/app/TachometerStyle.qml @@ -105,6 +105,7 @@ DashboardGaugeStyle { anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.verticalCenter anchors.topMargin: 20 + visible: valueSource.displayNumericSpeeds === true readonly property int rpmInt: valueSource.rpm } diff --git a/app/ValueSource.qml b/app/ValueSource.qml index 48e5cf6..80ef95c 100644 --- a/app/ValueSource.qml +++ b/app/ValueSource.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2018 Konsulko Group +** Copyright (C) 2018, 2019 Konsulko Group ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -54,7 +54,7 @@ Item { id: valueSource property real kph: 0 property bool mphDisplay: true - property real speedScaling: mphDisplay == true ? 0.621 : 1.0 + property real speedScaling: mphDisplay == true ? 0.621504 : 1.0 property real rpm: 1 property real fuel: 0.85 property string gear: { @@ -87,13 +87,61 @@ Item { property int turnSignal: -1 property bool startUp: false property real temperature: 0.6 + property bool cruiseEnabled: false + property bool cruiseSet: false + property bool laneDepartureWarnEnabled: false + property bool displayNumericSpeeds: true function randomDirection() { return Math.random() > 0.5 ? Qt.LeftArrow : Qt.RightArrow; } + Connections { + target: SignalComposer + + onSignalEvent: { + if (uid === "event.vehicle.speed") { + var speed_tmp = parseFloat(value) + if(units == "mph") { + speed_tmp *= 1.609 + } + if(!runAnimation) { + valueSource.kph = speed_tmp + } + } + else if (uid === "event.engine.speed") { + if(!runAnimation) { + valueSource.rpm = parseFloat(value) / 1000 + } + } + else if (uid === "event.cruise.enable" && 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 (uid === "event.cruise.cancel" && value === "true") { + valueSource.cruiseSet = false + } + else if (uid === "event.lane_departure_warning.enable" && value === "true") { + valueSource.laneDepartureWarnEnabled = !valueSource.laneDepartureWarnEnabled + } + else if (uid === "event.info" && value === "true") { + valueSource.displayNumericSpeeds = !valueSource.displayNumericSpeeds + } + } + } + SequentialAnimation { - running: true + running: runAnimation loops: 1 // We want a small pause at the beginning, but we only want it to happen once. diff --git a/app/cluster-gauges.qml b/app/cluster-gauges.qml index 76f5027..e4c299b 100644 --- a/app/cluster-gauges.qml +++ b/app/cluster-gauges.qml @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2018 Konsulko Group +** Copyright (C) 2018, 2019 Konsulko Group ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -81,7 +81,7 @@ ApplicationWindow { id: statusFrame x: (parent.width - width) / 2 y: 40 - width: 1152 + width: 1280 height: 96 radius: height / 5 @@ -92,13 +92,13 @@ ApplicationWindow { Row { width: parent.width height: parent.height * 0.75 - spacing: (parent.width - (12 * parent.height * 0.75)) / 13 + spacing: (parent.width - (14 * parent.height * 0.75)) / 15 anchors.fill: parent anchors.topMargin: (parent.height - height) /2 anchors.bottomMargin: (parent.height - height) /2 - anchors.leftMargin: (parent.width - (12 * parent.height * 0.75)) / 13 - anchors.rightMargin: (parent.width - (12 * parent.height * 0.75)) / 13 + anchors.leftMargin: (parent.width - (14 * parent.height * 0.75)) / 15 + anchors.rightMargin: (parent.width - (14 * parent.height * 0.75)) / 15 Rectangle { width: height @@ -159,6 +159,25 @@ ApplicationWindow { } } + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.startUp ? './images/AGL_Icons_Battery_red.svg' : './images/AGL_Icons_Battery.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + Rectangle { width: height height: parent.height @@ -188,7 +207,7 @@ ApplicationWindow { border.color: "grey" Image { - source: valueSource.startUp ? './images/AGL_Icons_Battery_red.svg' : './images/AGL_Icons_Battery.svg' + source: valueSource.startUp ? './images/AGL_Icons_ParkingBrake_red.svg' : './images/AGL_Icons_ParkingBrake.svg' anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter width: height @@ -307,7 +326,26 @@ ApplicationWindow { border.color: "grey" Image { - source: valueSource.startUp ? './images/AGL_Icons_ParkingBrake_red.svg' : './images/AGL_Icons_ParkingBrake.svg' + source: valueSource.cruiseEnabled ? (valueSource.cruiseSet ? './images/AGL_Icons_CruiseControl_green.svg' : './images/AGL_Icons_CruiseControl_yellow.svg') : './images/AGL_Icons_CruiseControl.svg' + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: height + height: parent.height * 0.75 + fillMode: Image.PreserveAspectFit + } + } + + Rectangle { + width: height + height: parent.height + radius: height / 5 + + color: "black" + border.width: 2 + border.color: "grey" + + Image { + source: valueSource.laneDepartureWarnEnabled ? './images/AGL_Icons_LaneDeparture_green.svg' : './images/AGL_Icons_LaneDeparture.svg' anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter width: height diff --git a/app/images/AGL_Icons_CruiseControl.svg b/app/images/AGL_Icons_CruiseControl.svg new file mode 100644 index 0000000..6621e9e --- /dev/null +++ b/app/images/AGL_Icons_CruiseControl.svg @@ -0,0 +1,69 @@ + + + + + + image/svg+xml + + + + + + + + + AGL-new-icons-2 + + + + diff --git a/app/images/AGL_Icons_CruiseControl_green.svg b/app/images/AGL_Icons_CruiseControl_green.svg new file mode 100644 index 0000000..b229909 --- /dev/null +++ b/app/images/AGL_Icons_CruiseControl_green.svg @@ -0,0 +1,70 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + diff --git a/app/images/AGL_Icons_CruiseControl_white.svg b/app/images/AGL_Icons_CruiseControl_white.svg new file mode 100644 index 0000000..8c2ab25 --- /dev/null +++ b/app/images/AGL_Icons_CruiseControl_white.svg @@ -0,0 +1,70 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + diff --git a/app/images/AGL_Icons_CruiseControl_yellow.svg b/app/images/AGL_Icons_CruiseControl_yellow.svg new file mode 100644 index 0000000..4712a19 --- /dev/null +++ b/app/images/AGL_Icons_CruiseControl_yellow.svg @@ -0,0 +1,70 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + diff --git a/app/images/AGL_Icons_LaneDeparture.svg b/app/images/AGL_Icons_LaneDeparture.svg new file mode 100644 index 0000000..89b51a8 --- /dev/null +++ b/app/images/AGL_Icons_LaneDeparture.svg @@ -0,0 +1,89 @@ + + + + + + image/svg+xml + + + + + + + + + AGL-new-icons-2 + + + + + + + + diff --git a/app/images/AGL_Icons_LaneDeparture_green.svg b/app/images/AGL_Icons_LaneDeparture_green.svg new file mode 100644 index 0000000..fa5d845 --- /dev/null +++ b/app/images/AGL_Icons_LaneDeparture_green.svg @@ -0,0 +1,90 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + + + + + diff --git a/app/images/AGL_Icons_LaneDeparture_red.svg b/app/images/AGL_Icons_LaneDeparture_red.svg new file mode 100644 index 0000000..7ed9204 --- /dev/null +++ b/app/images/AGL_Icons_LaneDeparture_red.svg @@ -0,0 +1,90 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + + + + + diff --git a/app/images/AGL_Icons_LaneDeparture_white.svg b/app/images/AGL_Icons_LaneDeparture_white.svg new file mode 100644 index 0000000..4c94dd6 --- /dev/null +++ b/app/images/AGL_Icons_LaneDeparture_white.svg @@ -0,0 +1,90 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + + + + + diff --git a/app/images/AGL_Icons_LaneDeparture_yellow.svg b/app/images/AGL_Icons_LaneDeparture_yellow.svg new file mode 100644 index 0000000..341083b --- /dev/null +++ b/app/images/AGL_Icons_LaneDeparture_yellow.svg @@ -0,0 +1,90 @@ + + + + + + image/svg+xml + + AGL-new-icons-2 + + + + + + + + AGL-new-icons-2 + + + + + + + + diff --git a/app/images/images.qrc b/app/images/images.qrc index 9a8e2de..6b4f2d2 100644 --- a/app/images/images.qrc +++ b/app/images/images.qrc @@ -10,9 +10,17 @@ AGL_Icons_Battery.svg AGL_Icons_Battery_red.svg AGL_Icons_Battery_yellow.svg + AGL_Icons_CruiseControl.svg + AGL_Icons_CruiseControl_green.svg + AGL_Icons_CruiseControl_white.svg + AGL_Icons_CruiseControl_yellow.svg AGL_Icons_Engine.svg AGL_Icons_Engine_red.svg AGL_Icons_Engine_yellow.svg + AGL_Icons_LaneDeparture.svg + AGL_Icons_LaneDeparture_green.svg + AGL_Icons_LaneDeparture_yellow.svg + AGL_Icons_LaneDeparture_white.svg AGL_Icons_Lights.svg AGL_Icons_Lights_red.svg AGL_Icons_Lights_yellow.svg diff --git a/app/main.cpp b/app/main.cpp index 4f36ef7..a5b9ece 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2016 The Qt Company Ltd. - * Copyright (C) 2018 Konsulko Group + * Copyright (C) 2018, 2019 Konsulko Group * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,45 @@ #include #include #include +#include #include +#include + +// Global indicating whether canned animation should run +bool runAnimation = true; + +void read_config(void) +{ + GKeyFile* conf_file; + gboolean value; + + // Load settings from configuration file if it exists + conf_file = g_key_file_new(); + if(conf_file && + g_key_file_load_from_dirs(conf_file, + "AGL.conf", + (const gchar**) g_get_system_config_dirs(), + NULL, + G_KEY_FILE_KEEP_COMMENTS, + NULL) == TRUE) { + GError *err = NULL; + value = g_key_file_get_boolean(conf_file, + "dashboard", + "animation", + &err); + if(value) { + runAnimation = true; + } else { + if(err == NULL) { + runAnimation = false; + } else { + qWarning("Invalid value for \"animation\" key!"); + } + } + } + +} int main(int argc, char *argv[]) { @@ -78,6 +115,10 @@ int main(int argc, char *argv[]) qwm->endDraw(myname); }); + context->setContextProperty("SignalComposer", new SignalComposer(bindingAddress, context)); + read_config(); + context->setContextProperty("runAnimation", runAnimation); + engine.load(QUrl(QStringLiteral("qrc:/cluster-gauges.qml"))); // Find the instantiated model QObject and connect the signals/slots diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in index aa18bdc..40796be 100644 --- a/conf.d/wgt/config.xml.in +++ b/conf.d/wgt/config.xml.in @@ -8,6 +8,7 @@ @PROJECT_LICENSE@ + -- cgit 1.2.3-korg