diff --git a/Arduino b/Arduino deleted file mode 160000 index 9979666..0000000 --- a/Arduino +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 99796662b861fb00b3e617685f4a8a9d7a1af412 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2651e9c..9f5c2c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,26 +8,27 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(zenohc_DIR "/usr/local/lib/cmake/zenohc") set(zenohcxx_DIR "/usr/local/lib/cmake/zenohcxx") -find_package(Qt6 COMPONENTS Core Quick DBus SerialBus REQUIRED) +find_package(Qt6 COMPONENTS Core Quick DBus REQUIRED) find_package(zenohc REQUIRED) find_package(zenohcxx REQUIRED) -set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wl,-rpath-link, ${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}") -# Enable automatic MOC, UIC, and RCC processing +# Enable Qt's Automatic MOC, UIC, and RCC set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -qt_add_resources(QT_RESOURCES ./src/resources.qrc) +# Add Resource File (QML and Other Resources) +qt_add_resources(QT_RESOURCES ./ui/resources.qrc) -add_executable(speedometer ${QT_RESOURCES} - ./src/main.cpp - ./src/CANBusHandler.cpp - ./include/CANBusHandler.hpp +# Define Executable Target +add_executable(speedometer + ${QT_RESOURCES} # Add Resource File + ./src/main.cpp # Main C++ File + ./src/CANBusHandler.cpp # CANBusHandler Implementation + ./include/CANBusHandler.hpp # CANBusHandler Header ) -target_link_libraries(speedometer zenohcxx::zenohc -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick Qt6::SerialBus) +target_link_libraries(speedometer zenohcxx::zenohc -lm -ldl Qt6::Core Qt6::DBus Qt6::Quick) add_executable(zenoh ./middelWare/src/main.cpp diff --git a/assets/icons/back_fog_on.png b/assets/icons/back_fog_on.png new file mode 100644 index 0000000..3b0f4f6 Binary files /dev/null and b/assets/icons/back_fog_on.png differ diff --git a/assets/icons/front_fog_on.png b/assets/icons/front_fog_on.png new file mode 100644 index 0000000..1d3e35a Binary files /dev/null and b/assets/icons/front_fog_on.png differ diff --git a/assets/icons/green-battery.png b/assets/icons/green-battery.png new file mode 100644 index 0000000..be1d5a3 Binary files /dev/null and b/assets/icons/green-battery.png differ diff --git a/assets/icons/high_beam_on.png b/assets/icons/high_beam_on.png new file mode 100644 index 0000000..2cbf1ae Binary files /dev/null and b/assets/icons/high_beam_on.png differ diff --git a/assets/icons/low_beam_on.png b/assets/icons/low_beam_on.png new file mode 100644 index 0000000..a486d46 Binary files /dev/null and b/assets/icons/low_beam_on.png differ diff --git a/assets/icons/parking_lights_on.png b/assets/icons/parking_lights_on.png new file mode 100644 index 0000000..2c68afb Binary files /dev/null and b/assets/icons/parking_lights_on.png differ diff --git a/assets/icons/turn_left_on.png b/assets/icons/turn_left_on.png new file mode 100644 index 0000000..9b1bea2 Binary files /dev/null and b/assets/icons/turn_left_on.png differ diff --git a/assets/icons/turn_right_on.png b/assets/icons/turn_right_on.png new file mode 100644 index 0000000..f633119 Binary files /dev/null and b/assets/icons/turn_right_on.png differ diff --git a/src/Main.qml b/src/Main.qml deleted file mode 100644 index 53f97fa..0000000 --- a/src/Main.qml +++ /dev/null @@ -1,74 +0,0 @@ -import QtQuick 2.15 -import QtQuick.Controls 2.15 - -ApplicationWindow { - visible: true - width: Screen.width - height: Screen.height - flags: Qt.FramelessWindowHint - - Rectangle { - anchors.fill: parent - - // Background Gradient - Canvas { - anchors.fill: parent - onPaint: { - var ctx = getContext("2d"); - var gradient = ctx.createLinearGradient(0, 0, 0, height); - gradient.addColorStop(0, "#001848"); // Top dark blue - gradient.addColorStop(1, "#000022"); // Bottom darker blue - ctx.fillStyle = gradient; - ctx.fillRect(0, 0, width, height); - } - } - - // Top Highlight Bar - Canvas { - height: 50 - width: parent.width - anchors.top: parent.top - onPaint: { - var ctx = getContext("2d"); - var gradient = ctx.createLinearGradient(0, 0, 0, height); - gradient.addColorStop(0, "rgba(255, 255, 255, 0.1)"); - gradient.addColorStop(1, "transparent"); - ctx.fillStyle = gradient; - ctx.fillRect(0, 0, width, height); - } - } - - // Bottom Shadow Bar - Canvas { - height: 50 - width: parent.width - anchors.bottom: parent.bottom - onPaint: { - var ctx = getContext("2d"); - var gradient = ctx.createLinearGradient(0, 0, 0, height); - gradient.addColorStop(0, "transparent"); - gradient.addColorStop(1, "rgba(0, 0, 0, 0.5)"); - ctx.fillStyle = gradient; - ctx.fillRect(0, 0, width, height); - } - } - - Text { - text: canBusHandler.speed - font.pixelSize: 50 - color: "white" - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: 300 - } - - Text { - text: canBusHandler.battery - font.pixelSize: 50 - color: "white" - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: 300 - } - } -} diff --git a/src/resources.qrc b/src/resources.qrc deleted file mode 100644 index f907b18..0000000 --- a/src/resources.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - Main.qml - - diff --git a/ui/FootbarInfo.qml b/ui/FootbarInfo.qml new file mode 100644 index 0000000..5274c05 --- /dev/null +++ b/ui/FootbarInfo.qml @@ -0,0 +1,65 @@ +import QtQuick 2.15 + +Row { + width: parent.width + height: 50 + spacing: 30 + padding: 10 + + Column { + + Row { + spacing: 5 + Text { + font.family: "Open Sans" + text: canBusHandler.battery + font.pixelSize: app.letterSize + color: "white" + } + Text { + font.family: "Open Sans" + text: "%" + font.pixelSize: app.letterSize + color: "gray" + } + } + } + + Column { + + Row { + spacing: 5 + Text { + font.family: "Open Sans" + text: "256" + font.pixelSize: app.letterSize + color: "white" + } + Text { + font.family: "Open Sans" + text: "mi" + font.pixelSize: app.letterSize + color: "gray" + } + } + } + Column { + + Row { + spacing: 5 + Text { + font.family: "Open Sans" + text: "22°" + font.pixelSize: app.letterSize + color: "white" + } + Text { + font.family: "Open Sans" + text: "G" + font.pixelSize: app.letterSize + color: "gray" + } + } + } + +} diff --git a/ui/GearShiftInfo.qml b/ui/GearShiftInfo.qml new file mode 100644 index 0000000..ef5bbce --- /dev/null +++ b/ui/GearShiftInfo.qml @@ -0,0 +1,29 @@ +import QtQuick 2.15 + +Column { + spacing: 10 + Text { + font.family: "Open Sans" + text: "P" + font.pixelSize: app.letterSize + color: "gray" + } + Text { + font.family: "Open Sans" + text: "R" + font.pixelSize: app.letterSize + color: "gray" + } + Text { + font.family: "Open Sans" + text: "N" + font.pixelSize: app.letterSize + color: "gray" + } + Text { + font.family: "Open Sans" + text: "D" + font.pixelSize: app.letterSize + color: "blue" + } +} \ No newline at end of file diff --git a/ui/LightInfo.qml b/ui/LightInfo.qml new file mode 100644 index 0000000..0994884 --- /dev/null +++ b/ui/LightInfo.qml @@ -0,0 +1,46 @@ +import QtQuick 2.15 + +Row { + spacing: 10 + padding: 10 + + Image { + id: lowBeamSignal + source: "qrc:/assets/icons/low_beam_on.png" + width: app.iconWidth + height: app.iconHeight + visible: true + } + + Image { + id: highBeamSignal + source: "qrc:/assets/icons/high_beam_on.png" + width: app.iconWidth + height: app.iconHeight + visible: true + } + + Image { + id: frontFogSignal + source: "qrc:/assets/icons/front_fog_on.png" + width: app.iconWidth + height: app.iconHeight + visible: true + } + + Image { + id: parkingLightsSignal + source: "qrc:/assets/icons/parking_lights_on.png" + width: app.iconWidth + height: app.iconHeight + visible: true + } + + Image { + id: backFogSignal + source: "qrc:/assets/icons/back_fog_on.png" + width: app.iconWidth + height: app.iconHeight + visible: true + } +} diff --git a/ui/Main.qml b/ui/Main.qml new file mode 100644 index 0000000..0da7110 --- /dev/null +++ b/ui/Main.qml @@ -0,0 +1,74 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +ApplicationWindow { + id: app + visible: true + width: Screen.width + height: Screen.height + // flags: Qt.FramelessWindowHint + + property int letterSize: 25 + property int iconWidth: 40 + property int iconHeight: 40 + property bool carClusterVisible: true + + property bool showSplash: true + + font.family: "Roboto" + font.pixelSize: 30 + font.bold: false + + // Car CLuster + Rectangle { + anchors.fill: parent + visible: app.carClusterVisible + + // Background Gradient + Canvas { + anchors.fill: parent + onPaint: { + var ctx = getContext("2d"); + ctx.fillStyle = "#000000"; + ctx.fillRect(0, 0, width, height); + } + } + + Row { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 100 + spacing: 10 + + TurnSignals { + isLeft: true + isBlinking: true + } + SpeedDisplay {} + TurnSignals { + isLeft: false + isBlinking: false + } + } + + GearShiftInfo { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 20 + } + + LightInfo { + anchors.top: parent.top + anchors.topMargin: 30 + anchors.left: parent.left + anchors.leftMargin: 70 + } + + FootbarInfo { + anchors.bottom: parent.bottom + anchors.bottomMargin: 60 + anchors.left: parent.left + anchors.leftMargin: 70 + } + } +} \ No newline at end of file diff --git a/ui/SpeedDisplay.qml b/ui/SpeedDisplay.qml new file mode 100644 index 0000000..e2859da --- /dev/null +++ b/ui/SpeedDisplay.qml @@ -0,0 +1,21 @@ +import QtQuick 2.15 + +Column { + spacing: 5 + + Text { + font.family: "Open Sans" + text: canBusHandler.speed + font.pixelSize: 110 + color: "white" + opacity: 1.0 + } + + Text { + anchors.horizontalCenter: parent.horizontalCenter + font.family: "Open Sans" + text: "DM/S" + font.pixelSize: app.letterSize + color: "gray" + } +} diff --git a/ui/TurnSignals.qml b/ui/TurnSignals.qml new file mode 100644 index 0000000..3d33a4e --- /dev/null +++ b/ui/TurnSignals.qml @@ -0,0 +1,32 @@ +import QtQuick 2.15 + +Row { + id: root + spacing: 10 + + property bool isLeft: true + property bool isBlinking: false + + Image { + anchors.verticalCenter: parent.verticalCenter + id: turnSignal + source: isLeft ? "qrc:/assets/icons/turn_left_on.png" : "qrc:/assets/icons/turn_right_on.png" + width: 70 + height: 70 + opacity: 0.0 + + Timer { + id: blinkTimer + interval: 500 + running: root.isBlinking + repeat: true + onTriggered: { + if (turnSignal.isBlinking) { + turnSignal.opacity = turnSignal.opacity === 1.0 ? 0.0 : 1.0; + } else { + turnSignal.opacity = 0.0; + } + } + } + } +} diff --git a/ui/resources.qrc b/ui/resources.qrc new file mode 100644 index 0000000..7c80d25 --- /dev/null +++ b/ui/resources.qrc @@ -0,0 +1,21 @@ + + + Main.qml + TurnSignals.qml + SpeedDisplay.qml + LightInfo.qml + FootbarInfo.qml + GearShiftInfo.qml + + + + ../assets/icons/back_fog_on.png + ../assets/icons/front_fog_on.png + ../assets/icons/green-battery.png + ../assets/icons/high_beam_on.png + ../assets/icons/low_beam_on.png + ../assets/icons/parking_lights_on.png + ../assets/icons/turn_left_on.png + ../assets/icons/turn_right_on.png + + \ No newline at end of file