diff --git a/INSTALL b/INSTALL index b5e6580..1bee0cb 100644 --- a/INSTALL +++ b/INSTALL @@ -28,7 +28,7 @@ JS8Call depends on: #### 18.04 LTS: -sudo apt install build-essential git automake cmake clang gfortran libfftw3-dev git libgfortran3 libusb-1.0-dev autoconf libtool texinfo qt5-default qtmultimedia5-dev libqt5multimedia5-plugins libqt5serialport5-dev libudev-dev pkg-config +sudo apt install build-essential git automake cmake clang gfortran libfftw3-dev git libgfortran5 libusb-1.0-0-dev autoconf libtool texinfo qt5-default qtmultimedia5-dev libqt5multimedia5-plugins libqt5serialport5-dev libudev-dev pkg-config #### 20.04 LTS: diff --git a/mainwindow.cpp b/mainwindow.cpp index 5f002c6..0f71452 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -450,7 +450,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_hbPaused { false }, m_hbInterval {0}, m_cqInterval {0}, - m_cqPaused { false } + m_cqPaused { false }, + m_driftMsMMA { 0 }, + m_driftMsMMA_N { 0 } { ui->setupUi(this); @@ -5049,7 +5051,7 @@ void MainWindow::processDecodedLine(QByteArray t){ bool bAvgMsg=false; int navg=0; - static QList driftQueue; + static QList driftQueue; static qint32 syncStart = -1; if(t.indexOf(" sync start") >= 0){ @@ -5138,15 +5140,22 @@ void MainWindow::processDecodedLine(QByteArray t){ m_wideGraph->notifyDriftedSignalsDecoded(driftQueue.count()); while(!driftQueue.isEmpty()){ - int newDrift = driftQueue.first(); + qint32 newDrift = driftQueue.first(); driftQueue.removeFirst(); - m_driftMsMMA = ((m_driftMsMMA_N-1)*m_driftMsMMA + newDrift)/m_driftMsMMA_N; + m_driftMsMMA = (((m_driftMsMMA_N-1) * m_driftMsMMA) + newDrift) / m_driftMsMMA_N; if(m_driftMsMMA_N < 60) m_driftMsMMA_N++; // cap it to 60 observations } - setDrift(m_driftMsMMA); + qint32 driftLimitMs = computePeriodForSubmode(Varicode::JS8CallNormal) * 1000; + qint32 newDriftMs = m_driftMsMMA; + if(newDriftMs < 0){ + newDriftMs = -((-newDriftMs) % driftLimitMs); + } else { + newDriftMs = ((newDriftMs) % driftLimitMs); + } + setDrift(m_driftMsMMA); //writeNoticeTextToUI(QDateTime::currentDateTimeUtc(), QString("Automatic Drift: %1").arg(driftAvg)); } @@ -5231,7 +5240,7 @@ void MainWindow::processDecodedLine(QByteArray t){ // 3) compute the delta // 4) apply the drift - int periodMs = 1000 * computePeriodForSubmode(m); + qint32 periodMs = 1000 * computePeriodForSubmode(m); //writeNoticeTextToUI(now, QString("Decode at %1 (kin: %2, lastDecoded: %3)").arg(syncStart).arg(dec_data.params.kin).arg(m_lastDecodeStartMap.value(m))); @@ -5258,9 +5267,9 @@ void MainWindow::processDecodedLine(QByteArray t){ //writeNoticeTextToUI(now, QString("--> so signal adjusted started at %1 seconds into the start of my drifted minute").arg(decodedSignalTime)); - int decodedSignalTimeMs = 1000 * decodedSignalTime; - int cycleStartTimeMs = (decodedSignalTimeMs / periodMs) * periodMs; - int driftMs = cycleStartTimeMs - decodedSignalTimeMs; + qint32 decodedSignalTimeMs = 1000 * decodedSignalTime; + qint32 cycleStartTimeMs = (decodedSignalTimeMs / periodMs) * periodMs; + qint32 driftMs = cycleStartTimeMs - decodedSignalTimeMs; //writeNoticeTextToUI(now, QString("--> which is a drift adjustment of %1 milliseconds").arg(driftMs)); @@ -5275,7 +5284,7 @@ void MainWindow::processDecodedLine(QByteArray t){ //writeNoticeTextToUI(now, QString("--> which is a corrected drift adjustment of %1 milliseconds").arg(driftMs)); - int newDrift = DriftingDateTime::drift() + driftMs; + qint32 newDrift = DriftingDateTime::drift() + driftMs; if(newDrift < 0){ newDrift %= -periodMs; } else { @@ -10958,7 +10967,7 @@ void MainWindow::processActivity(bool force) { void MainWindow::resetTimeDeltaAverage(){ m_driftMsMMA = 0; - m_driftMsMMA_N = 1; + m_driftMsMMA_N = 0; } void MainWindow::setDrift(int n){ diff --git a/mainwindow.h b/mainwindow.h index d5ea3ac..0ea4268 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -833,8 +833,8 @@ private: QString m_totalTxMessage; QDateTime m_lastTxStartTime; QDateTime m_lastTxStopTime; - int m_driftMsMMA; - int m_driftMsMMA_N; + qint32 m_driftMsMMA; + qint32 m_driftMsMMA_N; enum Priority { PriorityLow = 10, diff --git a/widegraph.cpp b/widegraph.cpp index 961050c..dbd982d 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -256,7 +256,14 @@ bool WideGraph::shouldDisplayDecodeAttempts(){ } bool WideGraph::isAutoSyncEnabled(){ - return ui->autoDriftButton->isChecked() && m_autoSyncDecodesLeft > 0; + // enabled if we're auto drifting + // and we are not auto stopping + // or if we are auto stopping, + // we have auto sync decodes left + return ui->autoDriftButton->isChecked() && ( + !ui->autoDriftAutoStopCheckBox->isChecked() || + m_autoSyncDecodesLeft > 0 + ); } bool WideGraph::shouldAutoSyncSubmode(int submode){