@@ -219,6 +219,8 @@ MainWindow::MainWindow(QWidget *parent) :
219
219
mKeyLeft = false ;
220
220
mKeyRight = false ;
221
221
222
+ shouldUpdateDisplayBars = false ;
223
+
222
224
connect (mDebugTimer , SIGNAL (timeout ()),
223
225
this , SLOT (timerSlotDebugMsg ()));
224
226
connect (mTimer , SIGNAL (timeout ()),
@@ -481,6 +483,8 @@ MainWindow::MainWindow(QWidget *parent) :
481
483
mPollImuTimer .start (int (1000.0 / mSettings .value (" poll_rate_imu_data" , 50 ).toDouble ()));
482
484
mPollBmsTimer .start (int (1000.0 / mSettings .value (" poll_rate_bms_data" , 10 ).toDouble ()));
483
485
486
+ mRepaintDisplayBarTimer .start (1000.0 /30 ); // Set the refresh rate to 30Hz
487
+
484
488
connect (&mPollRtTimer , &QTimer::timeout, [this ]() {
485
489
if (ui->actionRtData ->isChecked ()) {
486
490
mVesc ->commands ()->getValues ();
@@ -514,6 +518,15 @@ MainWindow::MainWindow(QWidget *parent) :
514
518
}
515
519
});
516
520
521
+ connect (&mRepaintDisplayBarTimer , &QTimer::timeout, [this ]() {
522
+ if (shouldUpdateDisplayBars) {
523
+ ui->dispCurrent ->setVal (mMcValues .current_motor );
524
+ ui->dispDuty ->setVal (mMcValues .duty_now * 100.0 );
525
+
526
+ shouldUpdateDisplayBars = false ;
527
+ }
528
+ });
529
+
517
530
// Restore size and position
518
531
if (mSettings .contains (" mainwindow/size" )) {
519
532
resize (mSettings .value (" mainwindow/size" ).toSize ());
@@ -951,8 +964,8 @@ void MainWindow::serialPortNotWritable(const QString &port)
951
964
void MainWindow::valuesReceived (MC_VALUES values, unsigned int mask)
952
965
{
953
966
(void )mask;
954
- ui-> dispCurrent -> setVal ( values. current_motor ) ;
955
- ui-> dispDuty -> setVal (values. duty_now * 100.0 ) ;
967
+ mMcValues = values;
968
+ shouldUpdateDisplayBars = true ;
956
969
}
957
970
958
971
void MainWindow::paramChangedDouble (QObject *src, QString name, double newParam)
0 commit comments