Skip to content

Commit

Permalink
Add getHardwareNow and getHardwareTypeNow
Browse files Browse the repository at this point in the history
This allows getting hardware name and type from QML
  • Loading branch information
cortex committed Nov 1, 2024
1 parent 85f5a58 commit 9cf773a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions vescinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,24 @@ QPair<int, int> VescInterface::getFirmwareNowPair()
return mFwPair;
}

QString VescInterface::getHardwareNow()
{
return mHwTxt;
}

QString VescInterface::getHardwareTypeNow()
{
switch (mHwType){
case HW_TYPE_VESC:
return "VESC";
case HW_TYPE_VESC_BMS:
return "VESC BMS";
case HW_TYPE_CUSTOM_MODULE:
return "Custom Module";
}
return "Unknown";
}

void VescInterface::emitStatusMessage(const QString &msg, bool isGood)
{
emit statusMessage(msg, isGood);
Expand Down Expand Up @@ -3832,6 +3850,7 @@ void VescInterface::fwVersionReceived(FW_RX_PARAMS params)
mFwTxt = QString("Fw: %1.%2").arg(params.major).arg(params.minor);
mFwPair = qMakePair(params.major, params.minor);
mHwTxt = params.hw;
mHwType = params.hwType;
if (!params.hw.isEmpty()) {
mFwTxt += ", Hw: " + params.hw;
}
Expand Down
3 changes: 3 additions & 0 deletions vescinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class VescInterface : public QObject
Q_INVOKABLE void emitStatusMessage(const QString &msg, bool isGood);
Q_INVOKABLE void emitMessageDialog(const QString &title, const QString &msg, bool isGood, bool richText = false);
Q_INVOKABLE bool fwRx();
Q_INVOKABLE QString getHardwareNow();
Q_INVOKABLE QString getHardwareTypeNow();
Q_INVOKABLE void storeSettings();

// Profiles
Expand Down Expand Up @@ -379,6 +381,7 @@ private slots:
QString mFwTxt;
QPair<int, int> mFwPair;
QString mHwTxt;
HW_TYPE mHwType;
QString mUuidStr;
QString mUuidStrLocal;
bool mIsUploadingFw;
Expand Down

0 comments on commit 9cf773a

Please sign in to comment.