From b6f059e701318710c7de9b44076fcda5fed5b871 Mon Sep 17 00:00:00 2001 From: SeongGino Date: Sat, 3 Aug 2024 15:04:11 -0400 Subject: [PATCH] Change board version to QString, cleanup compiler warnings QString version allows for more flexibility in case the version number returned from the board is not a pure float, e.g. contains a git hash --- constants.h | 2 +- guiwindow.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/constants.h b/constants.h index ab76094..b000b11 100644 --- a/constants.h +++ b/constants.h @@ -172,7 +172,7 @@ const int8_t adafruitItsyBitsyRP2040Presets[2][boardInputsCount-1] = { typedef struct boardInfo_t { uint8_t type = nothing; - float versionNumber = 0.0; + QString versionNumber; QString versionCodename; uint8_t selectedProfile; uint8_t previousProfile; diff --git a/guiwindow.cpp b/guiwindow.cpp index 960d7ab..16f3eb3 100644 --- a/guiwindow.cpp +++ b/guiwindow.cpp @@ -444,7 +444,7 @@ bool guiWindow::SerialInit(int portNum) QStringList buffer = bufStr.split(','); if(buffer[0].contains("OpenFIRE")) { qDebug() << "OpenFIRE gun detected!"; - board.versionNumber = buffer[1].toFloat(); + board.versionNumber = buffer[1]; qDebug() << "Version number:" << board.versionNumber; board.versionCodename = buffer[2]; qDebug() << "Version codename:" << board.versionCodename; @@ -919,7 +919,7 @@ void guiWindow::on_comPortSelector_currentIndexChanged(int index) // else, serial port is online! What do we got? } else { aliveTimer->start(ALIVE_TIMER); - ui->versionLabel->setText(QString("v%1 - \"%2\"").arg(board.versionNumber).arg(board.versionCodename)); + ui->versionLabel->setText(QString("v%1 - \"%2\"").arg(board.versionNumber, board.versionCodename)); BoxesFill(); LabelsUpdate(); @@ -2126,13 +2126,13 @@ void guiWindow::serialPort_readyRead() while(!serialPort.atEnd()) { QString idleBuffer = serialPort.readLine(); if(idleBuffer.contains("Pressed:")) { - uint8_t button = idleBuffer.trimmed().right(2).toInt(); + uint8_t button = idleBuffer.trimmed().rightRef(2).toInt(); testLabel[button-1]->setText(QString("%1").arg(valuesNameList[button])); } else if(idleBuffer.contains("Released:")) { - uint8_t button = idleBuffer.trimmed().right(2).toInt(); + uint8_t button = idleBuffer.trimmed().rightRef(2).toInt(); testLabel[button-1]->setText(valuesNameList[button]); } else if(idleBuffer.contains("Temperature:")) { - uint8_t temp = idleBuffer.trimmed().right(2).toInt(); + uint8_t temp = idleBuffer.trimmed().rightRef(2).toInt(); if(temp > tempShutoff) { testLabel[14]->setText(QString("Temp: %1°C").arg(temp)); } else if(temp > tempWarning) { @@ -2141,7 +2141,7 @@ void guiWindow::serialPort_readyRead() testLabel[14]->setText(QString("Temp: %1°C").arg(temp)); } } else if(idleBuffer.contains("Analog:")) { - uint8_t analogDir = idleBuffer.trimmed().right(1).toInt(); + uint8_t analogDir = idleBuffer.trimmed().rightRef(1).toInt(); if(analogDir) { switch(analogDir) { case 1: testLabel[15]->setText("Analog 🡹"); break; @@ -2158,14 +2158,14 @@ void guiWindow::serialPort_readyRead() } // no idea here lol } else if(idleBuffer.contains("Profile: ")) { - uint8_t selection = idleBuffer.trimmed().right(1).toInt(); + uint8_t selection = idleBuffer.trimmed().rightRef(1).toInt(); if(selection != board.selectedProfile) { board.selectedProfile = selection; selectedProfile[selection]->setChecked(true); } DiffUpdate(); } else if(idleBuffer.contains("UpdatedProf: ")) { - uint8_t selection = idleBuffer.trimmed().right(1).toInt(); + uint8_t selection = idleBuffer.trimmed().rightRef(1).toInt(); if(selection != board.selectedProfile) { selectedProfile[selection]->setChecked(true); }