Make UI update rate a settings parameter
MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -31,9 +31,12 @@ ProcessorHandler::ProcessorHandler() {
ProcessorRegistry::getDescription(m_currentID).defaultRegisterVals);
// The m_procStateChangeTimer limits maximum frequency of which the procStateChangedNonRun is emitted.
- constexpr int f_pscSignal = 15;
m_procStateChangeTimer.setSingleShot(true);
- m_procStateChangeTimer.setInterval(1000 / f_pscSignal);
+ m_procStateChangeTimer.setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt());
+ connect(RipesSettings::getObserver(RIPES_SETTING_UIUPDATEPS), &SettingObserver::modified, [=] {
+ m_procStateChangeTimer.setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt());
+ });
+
connect(&m_procStateChangeTimer, &QTimer::timeout, this, [=] {
emit procStateChangedNonRun();
m_enqueueStateChangeLock.lock();

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -97,10 +97,13 @@ ProcessorTab::ProcessorTab(QToolBar* controlToolbar, QToolBar* additionalToolbar
setupSimulatorActions(controlToolbar);
- // Setup statistics update timer
+ // Setup statistics update timer - this timer is distinct from the ProcessorHandler's update timer, given that it
+ // needs to run during 'running' the processor.
m_statUpdateTimer = new QTimer(this);
- m_statUpdateTimer->setInterval(100);
+ m_statUpdateTimer->setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt());
connect(m_statUpdateTimer, &QTimer::timeout, this, &ProcessorTab::updateStatistics);
+ connect(RipesSettings::getObserver(RIPES_SETTING_UIUPDATEPS), &SettingObserver::modified,
+ [=] { m_statUpdateTimer->setInterval(1000.0 / RipesSettings::value(RIPES_SETTING_UIUPDATEPS).toUInt()); });
connect(m_ui->clearConsoleButton, &QPushButton::clicked, m_ui->console, &Console::clearConsole);
m_ui->clearConsoleButton->setIcon(QIcon(":/icons/clear.svg"));

MODIFY
src/ripessettings.cpp
src/ripessettings.cpp
@@ -20,6 +20,7 @@ const std::map<QString, QVariant> s_defaultSettings = {
{RIPES_SETTING_CONSOLEFONT, QVariant() /* Let Console define its own default font */},
{RIPES_SETTING_CONSOLEFONT, QColorConstants::Black},
{RIPES_SETTING_INDENTAMT, 4},
+ {RIPES_SETTING_UIUPDATEPS, 15},
{RIPES_SETTING_ASSEMBLER_TEXTSTART, 0x0},
{RIPES_SETTING_ASSEMBLER_DATASTART, 0x10000000},

MODIFY
src/ripessettings.h
src/ripessettings.h
@@ -17,6 +17,7 @@ namespace Ripes {
#define RIPES_SETTING_CONSOLEFONTCOLOR ("console_font_color")
#define RIPES_SETTING_CONSOLEFONT ("console_font")
#define RIPES_SETTING_INDENTAMT ("editor_indent")
+#define RIPES_SETTING_UIUPDATEPS ("ui_update_ps")
#define RIPES_SETTING_ASSEMBLER_TEXTSTART ("text_start")
#define RIPES_SETTING_ASSEMBLER_DATASTART ("data_start")

MODIFY
src/settingsdialog.cpp
src/settingsdialog.cpp
@@ -290,6 +290,13 @@ QWidget* SettingsDialog::createEditorPage() {
QWidget* SettingsDialog::createEnvironmentPage() {
auto [pageWidget, pageLayout] = constructPage();
+ auto [uiUpdateMsLabel, uiUpdateMsSb] =
+ createSettingsWidgets<QSpinBox>(RIPES_SETTING_UIUPDATEPS, "Max. UI updates per second");
+ uiUpdateMsSb->setMinimum(1);
+ uiUpdateMsSb->setMaximum(100);
+ appendToLayout({uiUpdateMsLabel, uiUpdateMsSb}, pageLayout,
+ "Maximum updates of UI elements per second. Increasing this may reduce performance.");
+
auto [maxcyclesLabel, maxcyclesSb] =
createSettingsWidgets<QSpinBox>(RIPES_SETTING_CACHE_MAXCYCLES, "Max. cache plot cycles");
maxcyclesSb->setMinimum(0);

Make UI update rate a settings parameter