From 5b9ca00fedc0d002413103ee6a287c72e71d147b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= Date: Sun, 11 Feb 2024 05:08:39 +0100 Subject: [PATCH 1/3] Improve and unify config reading and writing messages (#352) * Unify text of custom config writing message with the reading message * Unify text of Motor/App config reads and writes * Consistently use the custom config hw_name in messages --- commands.cpp | 13 +++++++------ commands.h | 1 + vescinterface.cpp | 25 ++++++++++++++++++------- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/commands.cpp b/commands.cpp index 57008f9e3..f24d0acc3 100755 --- a/commands.cpp +++ b/commands.cpp @@ -399,15 +399,15 @@ void Commands::processPacket(QByteArray data) break; case COMM_SET_MCCONF: - emit ackReceived("MCCONF Write OK"); + emit ackReceived("Motor config write OK"); break; case COMM_SET_APPCONF: - emit ackReceived("APPCONF Write OK"); + emit ackReceived("App config write OK"); break; case COMM_SET_APPCONF_NO_STORE: - emit ackReceived("APPCONF_NO_STORE Write OK"); + emit ackReceived("App config set OK"); break; case COMM_CUSTOM_APP_DATA: @@ -731,9 +731,10 @@ void Commands::processPacket(QByteArray data) emit bmsValuesRx(val); } break; - case COMM_SET_CUSTOM_CONFIG: - emit ackReceived("COMM_SET_CUSTOM_CONFIG Write OK"); - break; + case COMM_SET_CUSTOM_CONFIG: { + int confId = vb.vbPopFrontUint8(); + emit customConfigAckReceived(confId); + } break; case COMM_GET_CUSTOM_CONFIG: case COMM_GET_CUSTOM_CONFIG_DEFAULT: { diff --git a/commands.h b/commands.h index fe2ace664..9cd10444c 100644 --- a/commands.h +++ b/commands.h @@ -135,6 +135,7 @@ class Commands : public QObject void bmsValuesRx(BMS_VALUES val); void customConfigChunkRx(int confInd, int lenConf, int ofsConf, QByteArray data); void customConfigRx(int confInd, QByteArray data); + void customConfigAckReceived(int confId); void pswStatusRx(PSW_STATUS stat); void qmluiHwRx(int lenQml, int ofsQml, QByteArray data); void qmluiAppRx(int lenQml, int ofsQml, QByteArray data); diff --git a/vescinterface.cpp b/vescinterface.cpp index b73e5ecd5..0be84573b 100755 --- a/vescinterface.cpp +++ b/vescinterface.cpp @@ -537,6 +537,17 @@ VescInterface::VescInterface(QObject *parent) : QObject(parent) connect(mCommands, SIGNAL(customConfigRx(int,QByteArray)), this, SLOT(customConfigRx(int,QByteArray))); + connect(mCommands, &Commands::customConfigAckReceived, [this](int confId) { + ConfigParams *custConf = customConfig(confId); + QString name; + if (custConf) { + name = custConf->getLongName("hw_name"); + } else { + name = tr("Custom config %1").arg(confId); + } + emit ackReceived(tr("%1 write OK").arg(name)); + }); + #if VT_IS_TEST_VERSION QTimer::singleShot(1000, [this]() { emitMessageDialog("VESC Tool Test Version", @@ -3823,7 +3834,7 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params) break; } - emitStatusMessage(QString("Got custom config %1").arg(i), true); + emitStatusMessage(QString("Got %1").arg(mCustomConfigs.last()->getLongName("hw_name")), true); } else { emitMessageDialog("Get Custom Config", "Could not read custom config from hardware", @@ -3951,12 +3962,12 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params) void VescInterface::appconfUpdated() { - emit statusMessage(tr("App configuration updated"), true); + emit statusMessage(tr("App config updated"), true); } void VescInterface::mcconfUpdated() { - emit statusMessage(tr("MC configuration updated"), true); + emit statusMessage(tr("Motor config updated"), true); if (isPortConnected() && fwRx()) { QPair fw_connected = qMakePair(mLastFwParams.major, mLastFwParams.minor); @@ -3988,7 +3999,7 @@ void VescInterface::customConfigRx(int confId, QByteArray data) auto vb = VByteArray(data); if (params->deSerialize(vb)) { params->updateDone(); - emitStatusMessage(tr("Custom config %1 updated").arg(confId), true); + emitStatusMessage(tr("%1 updated").arg(params->getLongName("hw_name")), true); } else { emitMessageDialog(tr("Custom Configuration"), tr("Could not deserialize custom config %1").arg(confId), @@ -4305,17 +4316,17 @@ bool VescInterface::confRestoreBackup(bool can) if (!txMc) { emitMessageDialog("Restore Configuration", - "No response when writing MC configuration to " + uuid + ".", false, false); + "No response when writing Motor config to " + uuid + ".", false, false); } if (!txApp) { emitMessageDialog("Restore Configuration", - "No response when writing app configuration to " + uuid + ".", false, false); + "No response when writing App config to " + uuid + ".", false, false); } if (!txCustom) { emitMessageDialog("Restore Configuration", - "No response when writing" + pCustom->getParam("hw_name")->longName + "configuration to " + uuid + ".", false, false); + "No response when writing " + pCustom->getLongName("hw_name") + " configuration to " + uuid + ".", false, false); } return txMc && txApp; From 95222fadc9d113246c80dfe37242e8b55a871f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= Date: Sun, 11 Feb 2024 05:09:13 +0100 Subject: [PATCH 2/3] Add a Reload and Run button to the QML editor page (#353) When using an external editor, it's a lot of clicks to reload and run the file. Adds a button to do everything in one click. --- pages/pagescripting.cpp | 19 +++++++++++++++++++ pages/pagescripting.h | 1 + pages/pagescripting.ui | 14 ++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/pages/pagescripting.cpp b/pages/pagescripting.cpp index 288379de8..7d123bc66 100755 --- a/pages/pagescripting.cpp +++ b/pages/pagescripting.cpp @@ -242,6 +242,25 @@ void PageScripting::on_stopButton_clicked() mQmlUi.stopCustomGui(); } +void PageScripting::on_reloadAndRunButton_clicked() +{ + QFile file(ui->mainEdit->fileNow()); + + if (!file.open(QIODevice::ReadOnly)) { + QMessageBox::critical(this, "Open QML File", + "Could not open example for reading"); + return; + } + + ui->mainEdit->codeEditor()->setPlainText(file.readAll()); + + file.close(); + + ui->qmlWidget->setSource(QUrl(QLatin1String("qrc:/res/qml/DynamicLoader.qml"))); + ui->qmlWidget->engine()->clearComponentCache(); + emit reloadQml(qmlToRun()); +} + void PageScripting::on_runWindowButton_clicked() { ui->runWindowButton->setEnabled(false); diff --git a/pages/pagescripting.h b/pages/pagescripting.h index e7004d748..4f12ed0e8 100644 --- a/pages/pagescripting.h +++ b/pages/pagescripting.h @@ -55,6 +55,7 @@ public slots: private slots: void on_runButton_clicked(); void on_stopButton_clicked(); + void on_reloadAndRunButton_clicked(); void on_runWindowButton_clicked(); void on_fullscreenButton_clicked(); void on_openRecentButton_clicked(); diff --git a/pages/pagescripting.ui b/pages/pagescripting.ui index fdf8a7b0c..ff3a08433 100644 --- a/pages/pagescripting.ui +++ b/pages/pagescripting.ui @@ -53,6 +53,20 @@ + + + + Reload and Run + + + + :/res/icons/Circled Play-96.png:/res/icons/Circled Play-96.png + + + true + + + From e6c66326290ca568da1edd262a2319685c46a0ee Mon Sep 17 00:00:00 2001 From: Benjamin Vedder Date: Sun, 11 Feb 2024 05:20:47 +0100 Subject: [PATCH 3/3] Added tooltips, renamed buttons to save space for small screens --- pages/pagescripting.ui | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pages/pagescripting.ui b/pages/pagescripting.ui index ff3a08433..b1390dfcc 100644 --- a/pages/pagescripting.ui +++ b/pages/pagescripting.ui @@ -37,10 +37,13 @@ - 12 + 2 + + Run in panel. + Run @@ -54,9 +57,12 @@ - + + + Run in Window + - Reload and Run + Window @@ -68,9 +74,12 @@ - + + + Reload file from filesystem and run in panel. Warning: This will replace the editor content if it is unsaved. + - Run in Window + Reload && Run @@ -83,8 +92,11 @@ + + Toggle fullscreen in running window. + - Toggle Fullscreen + Fullscreen