lots of improvements and launch screen

This commit is contained in:
2021-07-27 18:40:46 +02:00
parent 55a37897c0
commit 1f29eb8ff1
5 changed files with 128 additions and 123 deletions

View File

@ -146,7 +146,7 @@ private:
float m_frontLeftSpeed{};
float m_frontRightSpeed{};
float m_backLeftSpeed{};
float m_backRightSpeed;
float m_backRightSpeed{};
float m_frontLeftDcLink{};
float m_frontRightDcLink{};
float m_backLeftDcLink{};

View File

@ -124,26 +124,6 @@ GamePage {
font.pixelSize: GameSettings.mediumFontSize
}
Image {
id: bobbycar
//anchors.horizontalCenter: flickable.horizontalCenter
//anchors.verticalCenter: flickable.bottom
width: parent.width * 0.2
height: width
source: "images/logo.png"
smooth: true
antialiasing: true
SequentialAnimation{
id: bobbycarAnim
running: deviceHandler.alive
loops: Animation.Infinite
alwaysRunToEnd: true
PropertyAnimation { target: bobbycar; property: "scale"; to: 1.2; duration: 500; easing.type: Easing.InQuad }
PropertyAnimation { target: bobbycar; property: "scale"; to: 1.0; duration: 500; easing.type: Easing.OutQuad }
}
}
Row {
Label {
text: 'iMotMax:'
@ -169,20 +149,6 @@ GamePage {
value: 50
}
}
Repeater {
model: 20
Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
text: "Placeholder"
//visible: deviceHandler.alive
color: GameSettings.textColor
minimumPixelSize: 10
font.pixelSize: GameSettings.mediumFontSize
}
}
}
}
}

View File

@ -4,117 +4,146 @@ import QtQuick.Controls 2.15
GamePage {
id: remoteControlPage
Text {
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: container.top
anchors.bottomMargin: GameSettings.fieldMargin
errorMessage: deviceHandler.error
infoMessage: deviceHandler.info
font.pixelSize: GameSettings.hugeFontSize
color: GameSettings.textColor
text: qsTr("REMOTE CONTROL")
}
property real avgSpeed: (deviceHandler.frontLeftSpeed + deviceHandler.frontRightSpeed + deviceHandler.backLeftSpeed + deviceHandler.backRightSpeed) / 4
property real avgVoltage: (deviceHandler.frontVoltage + deviceHandler.backVoltage) / 2
property real totalCurrent: deviceHandler.frontLeftDcLink + deviceHandler.frontRightDcLink + deviceHandler.backLeftDcLink + deviceHandler.backRightDcLink
property real totalPower: totalCurrent * avgVoltage
Rectangle {
id: container
Column {
anchors.centerIn: parent
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(remoteControlPage.width, remoteControlPage.height-GameSettings.fieldHeight*4) - 2*GameSettings.fieldMargin
height: width
radius: GameSettings.buttonRadius
color: GameSettings.viewColor
property real remoteControlFrontLeft: (handler.relativeX * frontLeftRightSpinbox.value) + (handler.relativeY * frontUpDownSpinbox.value)
property real remoteControlFrontRight: (-handler.relativeX * frontLeftRightSpinbox.value) + (handler.relativeY * frontUpDownSpinbox.value)
property real remoteControlBackLeft: (handler.relativeX * backLeftRightSpinbox.value) + (handler.relativeY * backUpDownSpinbox.value)
property real remoteControlBackRight: (-handler.relativeX * backLeftRightSpinbox.value) + (handler.relativeY * backUpDownSpinbox.value)
Column {
width: parent.width
onRemoteControlFrontLeftChanged: deviceHandler.remoteControlFrontLeft = remoteControlFrontLeft
onRemoteControlFrontRightChanged: deviceHandler.remoteControlFrontRight = remoteControlFrontRight
onRemoteControlBackLeftChanged: deviceHandler.remoteControlBackLeft = remoteControlBackLeft
onRemoteControlBackRightChanged: deviceHandler.remoteControlBackRight = remoteControlBackRight
Text {
font.pixelSize: GameSettings.hugeFontSize
color: GameSettings.textColor
text: Number(avgSpeed).toLocaleString(Qt.locale()) + 'km/h'
}
Rectangle {
parent: container
color: "white"
anchors.centerIn: parent
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: 20
height: width
radius: width / 2
}
Text {
font.pixelSize: GameSettings.hugeFontSize
color: GameSettings.textColor
text: Number(totalCurrent).toLocaleString(Qt.locale()) + 'A'
}
Text {
anchors.top: parent.top
minimumPixelSize: 10
font.pixelSize: GameSettings.mediumFontSize
color: GameSettings.textColor
text: {
return "x:" + handler.relativeX.toFixed(1) + " y:" + handler.relativeY.toFixed(1) + "\n" +
"fl:" + Math.round(container.remoteControlFrontLeft) + " fr:" + Math.round(container.remoteControlFrontRight) + "\n" +
"bl:" + Math.round(container.remoteControlBackLeft) + " br:" + Math.round(container.remoteControlBackRight);
Text {
font.pixelSize: GameSettings.hugeFontSize
color: GameSettings.textColor
text: Number(totalPower>1000?(totalPower/1000):totalPower).toLocaleString(Qt.locale()) + (totalPower > 1000 ? "kW" : "W")
}
Text {
font.pixelSize: GameSettings.hugeFontSize
color: GameSettings.textColor
text: Number(avgVoltage).toLocaleString(Qt.locale()) + 'V'
}
}
PointHandler {
id: handler
//acceptedDevices: PointerDevice.TouchScreen
property real clampedX: handler.active ? Math.min(Math.max(handler.point.position.x, 0), container.width) : (container.width / 2)
property real clampedY: handler.active ? Math.min(Math.max(handler.point.position.y, 0), container.height) : (container.height / 2)
property real relativeX: ((clampedX / container.width) - 0.5) * 2
property real relativeY: ((clampedY / container.height) - 0.5) * -2
Rectangle {
id: container
width: parent.width
height: width
radius: GameSettings.buttonRadius
color: GameSettings.viewColor
target: Rectangle {
property real remoteControlFrontLeft: (handler.relativeX * frontLeftRightSpinbox.value) + (handler.relativeY * frontUpDownSpinbox.value)
property real remoteControlFrontRight: (-handler.relativeX * frontLeftRightSpinbox.value) + (handler.relativeY * frontUpDownSpinbox.value)
property real remoteControlBackLeft: (handler.relativeX * backLeftRightSpinbox.value) + (handler.relativeY * backUpDownSpinbox.value)
property real remoteControlBackRight: (-handler.relativeX * backLeftRightSpinbox.value) + (handler.relativeY * backUpDownSpinbox.value)
onRemoteControlFrontLeftChanged: deviceHandler.remoteControlFrontLeft = remoteControlFrontLeft
onRemoteControlFrontRightChanged: deviceHandler.remoteControlFrontRight = remoteControlFrontRight
onRemoteControlBackLeftChanged: deviceHandler.remoteControlBackLeft = remoteControlBackLeft
onRemoteControlBackRightChanged: deviceHandler.remoteControlBackRight = remoteControlBackRight
Rectangle {
parent: container
color: "red"
visible: handler.active
x: handler.clampedX - width / 2
y: handler.clampedY - height / 2
width: 50
color: "white"
anchors.centerIn: parent
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: 20
height: width
radius: width / 2
}
onActiveChanged: deviceHandler.remoteControlActive = handler.active
}
}
Text {
anchors.top: parent.top
minimumPixelSize: 10
font.pixelSize: GameSettings.mediumFontSize
color: GameSettings.textColor
text: {
return "x:" + handler.relativeX.toFixed(1) + " y:" + handler.relativeY.toFixed(1) + "\n" +
"fl:" + Math.round(container.remoteControlFrontLeft) + " fr:" + Math.round(container.remoteControlFrontRight) + "\n" +
"bl:" + Math.round(container.remoteControlBackLeft) + " br:" + Math.round(container.remoteControlBackRight);
}
}
Grid {
anchors.top: container.bottom
anchors.left: container.left
anchors.right: container.right
columns: 2
PointHandler {
id: handler
//acceptedDevices: PointerDevice.TouchScreen
property real clampedX: handler.active ? Math.min(Math.max(handler.point.position.x, 0), container.width) : (container.width / 2)
property real clampedY: handler.active ? Math.min(Math.max(handler.point.position.y, 0), container.height) : (container.height / 2)
property real relativeX: ((clampedX / container.width) - 0.5) * 2
property real relativeY: ((clampedY / container.height) - 0.5) * -2
SpinBox {
id: frontLeftRightSpinbox
value: 100
editable: true
from: 0
to: 1000
target: Rectangle {
parent: container
color: "red"
visible: handler.active
x: handler.clampedX - width / 2
y: handler.clampedY - height / 2
width: 50
height: width
radius: width / 2
}
onActiveChanged: deviceHandler.remoteControlActive = handler.active
}
}
SpinBox {
id: frontUpDownSpinbox
value: 100
editable: true
from: 0
to: 1000
}
Grid {
width: parent.width
columns: 2
horizontalItemAlignment: Grid.AlignHCenter
SpinBox {
id: backLeftRightSpinbox
value: 100
editable: true
from: 0
to: 1000
}
SpinBox {
id: frontLeftRightSpinbox
value: 100
editable: true
from: -1000
to: 1000
}
SpinBox {
id: backUpDownSpinbox
value: 100
editable: true
from: 0
to: 1000
SpinBox {
id: frontUpDownSpinbox
value: 75
editable: true
from: -1000
to: 1000
}
SpinBox {
id: backLeftRightSpinbox
value: 0
editable: true
from: -1000
to: 1000
}
SpinBox {
id: backUpDownSpinbox
value: 100
editable: true
from: -1000
to: 1000
}
}
}
}

View File

@ -24,10 +24,20 @@ Item {
}
Image {
id: bobbycar
anchors.centerIn: parent
width: Math.min(parent.height, parent.width)*0.6
height: GameSettings.heightForWidth(width, sourceSize)
source: "images/logo.png"
SequentialAnimation{
id: bobbycarAnim
running: true
loops: Animation.Infinite
alwaysRunToEnd: true
PropertyAnimation { target: bobbycar; property: "scale"; to: 1.2; duration: 500; easing.type: Easing.InQuad }
PropertyAnimation { target: bobbycar; property: "scale"; to: 1.0; duration: 500; easing.type: Easing.OutQuad }
}
}
Timer {

View File

@ -31,7 +31,7 @@ Window {
Connections {
target: splashLoader.item
onReadyToGo: {
function onReadyToGo() {
appLoader.visible = true
appLoader.item.init()
splashLoader.visible = false