Skip to content

Commit

Permalink
Old steering wheel config (#96)
Browse files Browse the repository at this point in the history
* Update Button Inputs for Old Steering Wheel

* Setup Speed Mode

* Lower SIze of Menu Items

* Set Previous Max Speed in Model
  • Loading branch information
Peyton-McKee authored Apr 15, 2024
1 parent c661614 commit 45f317b
Show file tree
Hide file tree
Showing 22 changed files with 545 additions and 26 deletions.
2 changes: 1 addition & 1 deletion NERODesign/NERO.qmlproject.qtds
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtDesignStudio 4.3.2, 2024-04-07T21:53:00. -->
<!-- Written by QtDesignStudio 4.3.2, 2024-04-13T17:21:43. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
5 changes: 5 additions & 0 deletions NERODevelopment/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ qt6_add_qml_module(content
EfficiencyScreen.qml
TorqueValueComponent.qml
TorqueAdj.qml
SpeedMode.qml
TimerDisplay.qml
MaxSpeedComparator.qml
MaxDrawGraph.qml
RunInfo.qml

RESOURCES
fonts/fonts.txt
Expand Down
1 change: 1 addition & 0 deletions NERODevelopment/content/HomeMenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Rectangle {
LabelText {
id: label
padding: 8
font.pixelSize: 16
text: parent.text
}
}
56 changes: 56 additions & 0 deletions NERODevelopment/content/MaxDrawGraph.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.3

Rectangle {
id: background

property int dimension: 200

width: dimension
height: dimension

color: "transparent"

property int value: 130

Canvas {
id: canvas
anchors.fill: parent
onPaint: {
var ctx = getContext("2d")
var centerX = dimension / 2
var centerY = dimension / 2
var radius = Math.min(dimension, dimension) / 2 - 25
var startAngle = -Math.PI / 2
var endAngle = startAngle + (value / 300) * 2 * Math.PI

ctx.beginPath()
ctx.arc(centerX, centerY, radius, startAngle, endAngle, false)
ctx.strokeStyle = '#14f804'
ctx.lineWidth = 0.06 * background.dimension
ctx.stroke()
}
}

RowLayout {
spacing: 0
anchors.centerIn: parent
LabelText {
text: value.toString()
font.pixelSize: 0.25 * background.dimension
font.bold: true
color: "white"
}

LabelText {
text: "A"
font.pixelSize: 0.15 * background.dimension
font.bold: true
color: "white"
Layout.topMargin: 0.06 * background.dimension
}
}

onValueChanged: canvas.requestPaint()
}
114 changes: 114 additions & 0 deletions NERODevelopment/content/MaxSpeedComparator.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

Rectangle {
id: maxSpeedComparator
property int dimension: 100
property int maxSpeed: 100
property int lowestSpeed: 0
property int previousTopSpeed: 40
property int currentSpeed: 50 //change to 0

width: dimension
height: dimension * 3
radius: 5
color: "black"
border.color: "white"

Text {
id: maxSpeed
text: maxSpeedComparator.maxSpeed
font.pixelSize: parent.width * 0.2
color: "white"
x: -(width + dimension / 20)
}

Text {
id: lowestSpeed
text: maxSpeedComparator.lowestSpeed
font.pixelSize: parent.width * 0.2
color: "white"
x: -(width + dimension / 20)
y: maxSpeedComparator.height - height
}

Rectangle {
id: bar
y: (maxSpeedComparator.height - height) - 5
anchors.horizontalCenter: parent.horizontalCenter
width: topSpeedBar.width
height: maxSpeedComparator.height * percentageHeight - 10
radius: 5
property real percentageHeight: parseFloat(
(maxSpeedComparator.currentSpeed
/ maxSpeedComparator.maxSpeed).toFixed(
2)) // Calculate percentage of height relative to maxSpeedComparator

gradient: Gradient {
GradientStop {
position: -5 * (1 - bar.percentageHeight
+ 0.1) // Start of gradient relative to parent's height
color: "red"
}
GradientStop {
position: 1.0 // End of gradient relative to parent's height
color: "#55FF00"
}
}
transformOrigin: Item.BottomLeft
Behavior on rotation {
SpringAnimation {
spring: 1.4
damping: .15
}
}
}

Text {
id: topSpeed
text: qsTr("TOP SPEED")
color: "white"
x: -(width + dimension / 20)
y: maxSpeedComparator.height * (1 - maxSpeedComparator.previousTopSpeed
/ maxSpeedComparator.maxSpeed)
font.pixelSize: parent.width * 0.2
Text {
id: topSpeedNumber
text: maxSpeedComparator.previousTopSpeed + qsTr("MPH")
color: "white"
y: -height
font.pixelSize: parent.width * 0.2

x: (topSpeed.width - width)
}
}

onCurrentSpeedChanged: {
console.log("Speededd", maxSpeedComparator.currentSpeed)
}

Rectangle {
id: topSpeedBar
y: maxSpeedComparator.height * (1 - maxSpeedComparator.previousTopSpeed
/ maxSpeedComparator.maxSpeed)
width: maxSpeedComparator.width - dimension / 6
anchors.horizontalCenter: parent.horizontalCenter
height: 2
color: "white"
}

function setCurrentSpeed(speed) {
maxSpeedComparator.currentSpeed = speed
}

function setTopSpeed(top_speed) {
topSpeedNumber.text = top_speed + "MPH"
topSpeed.y = top_speed
}

Behavior on currentSpeed {
NumberAnimation {
duration: 100
}
}
}
28 changes: 19 additions & 9 deletions NERODevelopment/content/NavigationController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,31 @@ Item {

HomeMenuItem {
highlighted: selectedPageIndex === 2
text: "Efficiency"
text: "Performance"
}

HomeMenuItem {
highlighted: selectedPageIndex === 3
text: "Debug"
text: "Efficiency"
}

HomeMenuItem {
highlighted: selectedPageIndex === 4
text: "Configuration"
text: "Debug"
}

HomeMenuItem {
highlighted: selectedPageIndex === 5
text: "Flappy Bird"
text: "Configuration"
}

HomeMenuItem {
highlighted: selectedPageIndex === 6
text: "Flappy Bird"
}

HomeMenuItem {
highlighted: selectedPageIndex === 7
text: "Exit"
}
}
Expand All @@ -92,23 +97,28 @@ Item {
focus: selectedPageIndex === 1 && isSelected
}

EfficiencyScreen {
SpeedMode {
visible: selectedPageIndex === 2 && isSelected
focus: selectedPageIndex === 2 && isSelected
}

DebugTable {
EfficiencyScreen {
visible: selectedPageIndex === 3 && isSelected
focus: selectedPageIndex === 3 && isSelected
}

Configuration {
DebugTable {
visible: selectedPageIndex === 4 && isSelected
isFocused: selectedPageIndex === 4 && isSelected
focus: selectedPageIndex === 4 && isSelected
}

FlappyBird {
Configuration {
visible: selectedPageIndex === 5 && isSelected
isFocused: selectedPageIndex === 5 && isSelected
}

FlappyBird {
visible: selectedPageIndex === 6 && isSelected
isFocused: selectedPageIndex === 6 && isSelected
}
}
89 changes: 89 additions & 0 deletions NERODevelopment/content/RunInfo.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
id: runInfo

property int widthValue: 200
property int heightValue: 40

width: widthValue
height: heightValue

property string backgroundColor: "white"
property string label: ""
property int value: 0
property int topRadius: 0
property int radius: 0
property bool isTop: false
property bool isBottom: false

Rectangle {
id: bottomRect
visible: runInfo.isTop
width: runInfo.width
height: runInfo.radius
color: runInfo.backgroundColor

anchors {
left: runInfo.left
bottom: runInfo.bottom
}
}

Rectangle {
id: topRect
visible: runInfo.isBottom
width: runInfo.width
height: runInfo.radius
color: runInfo.backgroundColor

anchors {
left: runInfo.left
top: runInfo.top
}
}

Rectangle {
height: runInfo.height
width: runInfo.width
color: backgroundColor
radius: runInfo.radius

anchors {
left: runInfo.left
top: runInfo.top
}

Rectangle {
id: rightBlackRectangle
width: runInfo.width / 4
height: runInfo.height * 0.8
color: "black"

x: parent.width * 0.7
y: parent.height / 10

ValueText {
id: valueText
text: value
font.pixelSize: rightBlackRectangle.height * 0.8
x: rightBlackRectangle.width * 0.5 - rightBlackRectangle.height / 4.5
y: rightBlackRectangle.height * -0.1
color: "white"
font.bold: true
}
}

LabelText {
id: labelText
text: label
x: runInfo.width * 0.05
y: runInfo.isTop ? runInfo.height * 0.6 - font.pixelSize + topRect.height
* 0.1 : (runInfo.isBottom ? runInfo.height * 0.6 - font.pixelSize + bottomRect.height * 0.15 : runInfo.height * 0.6 - font.pixelSize)
font.pixelSize: Math.min(runInfo.height * 0.6, runInfo.width * 0.08)
color: "black"
font.bold: true
}
}
}
Loading

0 comments on commit 45f317b

Please sign in to comment.