diff --git a/software/usbflashprog/i18n/ufprog_en_US.ts b/software/usbflashprog/i18n/ufprog_en_US.ts index 197e4870..2588f30a 100644 --- a/software/usbflashprog/i18n/ufprog_en_US.ts +++ b/software/usbflashprog/i18n/ufprog_en_US.ts @@ -433,18 +433,6 @@ Calibrate Calibrate - - Set Address - Set Address - - - Set Data - Set Data - - - Get Data - Get Data - File File @@ -550,6 +538,14 @@ %1 second(s) %1 second(s) + + Get Word + Get Word + + + Get Byte + Get Byte + SettingsDialog @@ -601,5 +597,9 @@ Note: The log file can be found at %1 Note: The log file can be found at %1 + + Settings + Settings + diff --git a/software/usbflashprog/i18n/ufprog_pt_BR.ts b/software/usbflashprog/i18n/ufprog_pt_BR.ts index 7a0fda06..0361ec96 100644 --- a/software/usbflashprog/i18n/ufprog_pt_BR.ts +++ b/software/usbflashprog/i18n/ufprog_pt_BR.ts @@ -433,18 +433,6 @@ Calibrate Calibrar - - Set Address - Gravar Endereço - - - Set Data - Gravar Dados - - - Get Data - Ler Dados - File Arquivo @@ -549,6 +537,14 @@ %1 second(s) %1 segundo(s) + + Get Word + Ler 16 Bits + + + Get Byte + Ler 8 Bits + SettingsDialog @@ -600,5 +596,9 @@ Note: The log file can be found at %1 Nota: O arquivo de log pode ser encontrado em %1 + + Settings + Configurações + diff --git a/software/usbflashprog/main.cpp b/software/usbflashprog/main.cpp index 87cb508d..cc58b169 100644 --- a/software/usbflashprog/main.cpp +++ b/software/usbflashprog/main.cpp @@ -31,6 +31,13 @@ #include "main.hpp" #include "ui/mainwindow.hpp" +#ifdef Q_OS_WINDOWS +#include +#else +#include +#include +#endif + // --------------------------------------------------------------------------- /** * @brief Main routine. @@ -82,26 +89,26 @@ void initLogging(int level) { QString strType; switch (level) { case 1: // Fatal - rules = "*.fatal=true"; + rules = "*.critical=false"; strType = "FATAL"; break; case 2: // Critical - rules = "*.critical=true"; + rules = "*.warning=false"; strType = "CRITICAL"; break; case 3: // Warning - rules = "*.warning=true"; + rules = "*.info=false"; strType = "WARNING"; break; case 4: // Info - rules = "*.warning=true\nbackend.*.info=true\ndevice.*.info=true"; + rules = "*.debug=false"; strType = "INFO"; break; case 5: // Debug default: if (level >= 5) { rules = - "*.info=true\nbackend.*.debug=true\ndevice.*.debug=true"; + "*.debug=false\nbackend.*.debug=true\ndevice.*.debug=true"; strType = "DEBUG"; } break; @@ -134,19 +141,19 @@ void initLogging(int level) { strType = "DEBUG"; break; } - QString timeStamp = - QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"); - QString txt = QString("%1 %2 %3 - %4") - .arg(timeStamp) - .arg("[" + QString(context.category) + "]", -25) - .arg(strType, -8) - .arg(localMsg); QFile logFile(QDir::homePath() + "/" + QString(kLogFileName)); logFile.open(QIODevice::WriteOnly | QIODevice::Append); QTextStream ts(&logFile); - ts << txt << endl; + QString timeStamp = + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz"); + ts << QString("%1 %2 %3 - %4") + .arg(timeStamp) + .arg("[" + QString(context.category) + "]", -25) + .arg(strType, -8) + .arg(localMsg) + << endl; }); - qInfo() << "Setting Log Level: " << strType; + qInfo() << "Setting Log Level:" << strType; } void loadLanguage(const QString &language, QApplication *app) { @@ -203,17 +210,24 @@ void loadLanguage(const QString &language, QApplication *app) { } if (baseOk) { app->installTranslator(baseTranslator); - qInfo() << "Installed Qt Base translator for language: " << localeName; + qInfo() << "Installed Qt Base translator for language:" << localeName; } if (customOk) { app->installTranslator(customTranslator); - qInfo() << "Installed Custom translator for language: " << localeName; + qInfo() << "Installed Custom translator for language:" << localeName; } } int main(int argc, char *argv[]) { #ifdef Q_OS_LINUX setenv("XDG_SESSION_TYPE", "x11", 1); +#endif + // elevates priority of process +#ifdef Q_OS_WINDOWS + SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); +#else + // only if running as superuser + setpriority(PRIO_PROCESS, 0, -20); #endif // create app QApplication app(argc, argv); diff --git a/software/usbflashprog/ui/mainwindow.cpp b/software/usbflashprog/ui/mainwindow.cpp index 4f1f46ad..7ee6e189 100644 --- a/software/usbflashprog/ui/mainwindow.cpp +++ b/software/usbflashprog/ui/mainwindow.cpp @@ -339,8 +339,6 @@ void MainWindow::onSelectDeviceTriggered(bool checked) { noWarningDevice_ = false; } -#include - void MainWindow::onActionProgress(uint32_t current, uint32_t total, bool done, bool success, bool canceled) { static qint64 startTime = 0; @@ -1173,14 +1171,17 @@ void MainWindow::refreshPortComboBox_() { } QString MainWindow::calculateDataRate_(int64_t elapsed, uint32_t amount) { + // Bytes/s double value = (elapsed ? (amount * 1.0 / elapsed) : 0.0) * 1000.0; - if (value >= 1024 * 1024) { // MB/s - return QString("%1 MB/s").arg( - static_cast(round(value / 1024.0 / 1024.0))); - } else if (value >= 1024) { // KB/s - return QString("%1 KB/s").arg(static_cast(round(value / 1024.0))); - } else { // Byte/s - return QString("%1 byte/s").arg(static_cast(round(value))); + // bps + value *= (!device_ || !device_->is16Bit()) ? 8 : 16; + if (value >= 1000 * 1000) { // Mbps + return QString("%1 Mbps").arg( + static_cast(round(value / 1000.0 / 1000.0))); + } else if (value >= 1000) { // Kbps + return QString("%1 Kbps").arg(static_cast(round(value / 1000.0))); + } else { // bps + return QString("%1 bps").arg(static_cast(round(value))); } } @@ -1212,9 +1213,7 @@ void MainWindow::on_pushButtonConnect_clicked() { } void MainWindow::on_pushButtonVddInitCal_clicked() { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; enableDiagControls_(false); float measured = 0.0f; bool ok = runner_.vddInitCal(); @@ -1254,9 +1253,7 @@ void MainWindow::on_pushButtonVddInitCal_clicked() { } void MainWindow::on_pushButtonVppInitCal_clicked() { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; enableDiagControls_(false); float measured = 0.0f; bool ok = runner_.vppInitCal(); @@ -1295,125 +1292,81 @@ void MainWindow::on_pushButtonVppInitCal_clicked() { enableDiagControls_(true); } -void MainWindow::on_pushButtonSetData_clicked() { - if (!runner_.isOpen()) { - return; - } - uint16_t data = ui_->spinBoxData->value(); - if (!runner_.dataSetW(data)) { - QMessageBox::critical( - this, tr("USB Flash/EPROM Programmer"), - tr("The device has been disconnected from the \"%1\" port.") - .arg(runner_.getPath()) - .leftJustified(kDialogLabelMinLength)); - } -} - -void MainWindow::on_pushButtonGetData_clicked() { - if (!runner_.isOpen()) { - return; - } +void MainWindow::on_pushButtonGetDataW_clicked() { + if (!runner_.isOpen()) return; uint16_t value = runner_.dataGetW(); ui_->spinBoxData->setValue(value); } -void MainWindow::on_pushButtonSetAddr_clicked() { - if (!runner_.isOpen()) { - return; - } - uint32_t data = ui_->spinBoxAddr->value(); - runner_.addrSet(data); +void MainWindow::on_pushButtonGetDataB_clicked() { + if (!runner_.isOpen()) return; + uint8_t value = runner_.dataGet(); + ui_->spinBoxData->setValue(value); } void MainWindow::on_checkBoxVddCtrl_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vddCtrl(checked); } void MainWindow::on_checkBoxVppCtrl_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vppCtrl(checked); } void MainWindow::on_checkBoxVddOnVpp_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vddOnVpp(checked); } void MainWindow::on_checkBoxVppOnA9_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vppOnA9(checked); } void MainWindow::on_checkBoxVppOnA18_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vppOnA18(checked); } void MainWindow::on_checkBoxVppOnCE_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vppOnCE(checked); } void MainWindow::on_checkBoxVppOnOE_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vppOnOE(checked); } void MainWindow::on_checkBoxVppOnWE_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.vppOnWE(checked); } void MainWindow::on_checkBoxCE_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.setCE(checked); } void MainWindow::on_checkBoxOE_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.setOE(checked); } void MainWindow::on_checkBoxWE_toggled(bool checked) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; runner_.setWE(checked); } void MainWindow::on_dialVdd_valueChanged(int value) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; float v = value / 10.0f; runner_.vddSet(v); } void MainWindow::on_dialVpp_valueChanged(int value) { - if (!runner_.isOpen()) { - return; - } + if (!runner_.isOpen()) return; float v = value / 10.0f; runner_.vppSet(v); } @@ -1463,18 +1416,22 @@ void MainWindow::onRefreshTimerTimeout() { void MainWindow::onCheckBoxAddressToggled(bool checked) { addressBinToHex_(); + // sendAddrBus_(); } void MainWindow::on_spinBoxAddr_valueChanged(int value) { addressHexToBin_(); + sendAddrBus_(); } void MainWindow::onCheckBoxDataToggled(bool checked) { dataBinToHex_(); + // sendDataBus_(); } void MainWindow::on_spinBoxData_valueChanged(int value) { dataHexToBin_(); + sendDataBus_(); } void MainWindow::connect_(bool state) { @@ -1517,6 +1474,24 @@ void MainWindow::connect_(bool state) { } } +void MainWindow::sendDataBus_() { + if (!runner_.isOpen()) return; + uint16_t data = ui_->spinBoxData->value(); + if (!runner_.dataSetW(data)) { + QMessageBox::critical( + this, tr("USB Flash/EPROM Programmer"), + tr("The device has been disconnected from the \"%1\" port.") + .arg(runner_.getPath()) + .leftJustified(kDialogLabelMinLength)); + } +} + +void MainWindow::sendAddrBus_() { + if (!runner_.isOpen()) return; + uint32_t data = ui_->spinBoxAddr->value(); + runner_.addrSet(data); +} + void MainWindow::enableDiagControls_(bool state) { ui_->frameVdd->setEnabled(state); ui_->frameVpp->setEnabled(state); diff --git a/software/usbflashprog/ui/mainwindow.hpp b/software/usbflashprog/ui/mainwindow.hpp index d5796c62..f5166f84 100644 --- a/software/usbflashprog/ui/mainwindow.hpp +++ b/software/usbflashprog/ui/mainwindow.hpp @@ -120,9 +120,8 @@ class MainWindow : public QMainWindow { void on_pushButtonConnect_clicked(); void on_pushButtonVddInitCal_clicked(); void on_pushButtonVppInitCal_clicked(); - void on_pushButtonSetData_clicked(); - void on_pushButtonGetData_clicked(); - void on_pushButtonSetAddr_clicked(); + void on_pushButtonGetDataW_clicked(); + void on_pushButtonGetDataB_clicked(); void on_checkBoxVddCtrl_toggled(bool checked = false); void on_checkBoxVppCtrl_toggled(bool checked = false); void on_checkBoxVddOnVpp_toggled(bool checked = false); @@ -259,6 +258,10 @@ class MainWindow : public QMainWindow { * @param state True to connect, false to disconnect. */ void connect_(bool state = true); + + void sendDataBus_(); + void sendAddrBus_(); + /* * @brief Enables/Disables the controls (Diag). * @param state True to enable, false otherwise. diff --git a/software/usbflashprog/ui/mainwindow.ui b/software/usbflashprog/ui/mainwindow.ui index ed110221..58c843f8 100644 --- a/software/usbflashprog/ui/mainwindow.ui +++ b/software/usbflashprog/ui/mainwindow.ui @@ -2278,7 +2278,7 @@ Wr - + 0 0 @@ -2373,7 +2373,7 @@ Wr - + 0 0 @@ -2801,23 +2801,17 @@ Wr - - - - 0 - 0 - + + + Qt::Vertical - + - 120 - 25 + 20 + 40 - - Set Address - - + @@ -3291,7 +3285,7 @@ Wr - + 0 @@ -3305,12 +3299,12 @@ Wr - Set Data + Get Word - + 0 @@ -3324,7 +3318,7 @@ Wr - Get Data + Get Byte @@ -3936,46 +3930,46 @@ Wr - SRAM 2016/6116 + SRAM 20/6116 - SRAM 2016/6116 + SRAM 20/6116 - SRAM 2016/6116 + SRAM 20/6116 - SRAM 6264 + SRAM 61/6264 - SRAM 6264 + SRAM 61/6264 - SRAM 6264 + SRAM 61/6264 - SRAM 62128 + SRAM 61/62128 - SRAM 62128 + SRAM 61/62128 - SRAM 62128 + SRAM 61/62128 - SRAM 62256 + SRAM 61/62256 - SRAM 62256 + SRAM 61/62256 - SRAM 62256 + SRAM 61/62256 @@ -4526,7 +4520,6 @@ Wr checkBoxA1 checkBoxA0 spinBoxAddr - pushButtonSetAddr checkBoxD15 checkBoxD14 checkBoxD13 @@ -4544,8 +4537,7 @@ Wr checkBoxD1 checkBoxD0 spinBoxData - pushButtonSetData - pushButtonGetData + pushButtonGetDataW btnOpen tabWidget diff --git a/software/usbflashprog/ui/settings.cpp b/software/usbflashprog/ui/settings.cpp index c480eeba..aab3d33f 100644 --- a/software/usbflashprog/ui/settings.cpp +++ b/software/usbflashprog/ui/settings.cpp @@ -30,6 +30,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) ui_->setupUi(this); setWindowFlag(Qt::MSWindowsFixedSizeDialogHint); setWindowFlag(Qt::WindowContextHelpButtonHint, false); + setWindowTitle(tr("USB Flash/EPROM Programmer") + " - " + tr("Settings")); QString logFileInfo = ui_->labelLogFileInfo->text(); logFileInfo = logFileInfo.arg("\n" + QDir::toNativeSeparators(QDir::homePath() + "/" +