Automatically stop time drift sync after decode by default

This commit is contained in:
Jordan Sherer 2020-05-16 11:57:27 -04:00
parent 9c2b5b989a
commit 7e70122cb5
4 changed files with 170 additions and 96 deletions

View File

@ -5281,9 +5281,13 @@ void MainWindow::processDecodedLine(QByteArray t){
return;
}
// TODO: can we do this for FAST & TURBO
// if fast/turbo is observed and we're in a period post 15 seconds (i.e., second 18 turbo decode)
// then make the drift relative to the first cycle instead
if(m != Varicode::JS8CallNormal && m != Varicode::JS8CallSlow){
return;
}
// if we're here at this point, we _should_ be operating a decode every second
//
// so we need to figure out where:
@ -5374,6 +5378,9 @@ void MainWindow::processDecodedLine(QByteArray t){
static int driftN = 1;
static int driftAvg = DriftingDateTime::drift();
// let the widegraph know for timing control
m_wideGraph->notifyDriftedSignalsDecoded(driftQueue.count());
while(!driftQueue.isEmpty()){
int newDrift = driftQueue.first();
driftQueue.removeFirst();
@ -5384,6 +5391,7 @@ void MainWindow::processDecodedLine(QByteArray t){
setDrift(driftAvg);
//writeNoticeTextToUI(QDateTime::currentDateTimeUtc(), QString("Automatic Drift: %1").arg(driftAvg));
}

View File

@ -168,6 +168,7 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) :
ui->cbControls->setChecked(!m_settings->value("HideControls", false).toBool());
ui->fpsSpinBox->setValue(m_settings->value ("WaterfallFPS", 4).toInt());
ui->decodeAttemptCheckBox->setChecked(m_settings->value("DisplayDecodeAttempts", false).toBool());
ui->autoDriftAutoStopCheckBox->setChecked(m_settings->value ("StopAutoSyncOnDecode", true).toBool());
auto splitState = m_settings->value("SplitState").toByteArray();
if(!splitState.isEmpty()){
@ -244,6 +245,7 @@ void WideGraph::saveSettings() //saveS
m_settings->setValue ("SplitState", ui->splitter->saveState());
m_settings->setValue ("WaterfallFPS", ui->fpsSpinBox->value());
m_settings->setValue ("DisplayDecodeAttempts", ui->decodeAttemptCheckBox->isChecked());
m_settings->setValue ("StopAutoSyncOnDecode", ui->autoDriftAutoStopCheckBox->isChecked());
}
bool WideGraph::shouldDisplayDecodeAttempts(){
@ -254,12 +256,58 @@ bool WideGraph::shouldAutoSync(){
return ui->autoDriftButton->isChecked();
}
void WideGraph::notifyDriftedSignalsDecoded(int /*signalsDecoded*/){
if(ui->autoDriftAutoStopCheckBox->isChecked()){
ui->autoDriftButton->setChecked(false);
}
}
void WideGraph::on_autoDriftButton_toggled(bool checked){
static bool connected = false;
if(!connected){
connect(&m_autoSyncTimer, &QTimer::timeout, this, [this](){
// if auto drift isn't checked, don't worry about this...
if(!ui->autoDriftButton->isChecked()){
return;
}
// uncheck after timeout
if(m_autoSyncTimeLeft == 0){
ui->autoDriftButton->setChecked(false);
return;
}
// set new text and decrement timeleft
auto text = ui->autoDriftButton->text();
auto newText = QString("%1 (%2)").arg(text.left(text.indexOf("(")).trimmed()).arg(m_autoSyncTimeLeft--);
ui->autoDriftButton->setText(newText);
});
connected = true;
}
// if in the future we want to auto sync timeout after a time period
bool autoSyncTimeout = false;
auto text = ui->autoDriftButton->text();
if(checked){
ui->autoDriftButton->setText(text.replace("Start", "Stop"));
if(autoSyncTimeout){
if(checked){
m_autoSyncTimeLeft = 120;
m_autoSyncTimer.setInterval(1000);
m_autoSyncTimer.start();
ui->autoDriftButton->setText(QString("%1 (%2)").arg(text.replace("Start", "Stop")).arg(m_autoSyncTimeLeft--));
} else {
m_autoSyncTimeLeft = 0;
m_autoSyncTimer.stop();
ui->autoDriftButton->setText(text.left(text.indexOf("(")).trimmed().replace("Stop", "Start"));
}
return;
} else {
ui->autoDriftButton->setText(text.replace("Stop", "Start"));
if(checked){
ui->autoDriftButton->setText(text.left(text.indexOf("(")).trimmed().replace("Start", "Stop"));
} else {
ui->autoDriftButton->setText(text.left(text.indexOf("(")).trimmed().replace("Stop", "Start"));
}
}
}

View File

@ -90,6 +90,7 @@ public slots:
int drift();
void setQSYEnabled(bool enabled);
void setPaused(bool paused){ m_paused = paused; }
void notifyDriftedSignalsDecoded(int signalsDecoded);
protected:
void keyPressEvent (QKeyEvent *e) override;
@ -165,6 +166,9 @@ private:
bool m_bRef;
bool m_bHaveTransmitted; //Set true at end of a WSPR transmission
QTimer m_autoSyncTimer;
int m_autoSyncTimeLeft;
QTimer m_drawTimer;
QMutex m_drawLock;

View File

@ -179,7 +179,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<width>323</width>
<height>372</height>
</rect>
</property>
@ -428,7 +428,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>267</width>
<width>323</width>
<height>742</height>
</rect>
</property>
@ -975,8 +975,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>273</width>
<height>252</height>
<width>337</width>
<height>351</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -1021,100 +1021,114 @@
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QGroupBox" name="groupBox_10">
<property name="title">
<string>Automatic</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QPushButton" name="autoDriftButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatically synchronize time drift every second to decodes of NORMAL and SLOW signals observed.&lt;/p&gt;&lt;p&gt;This process is CPU intensive and may cause abnormal decoder behavior if run for extended periods of time. Default operation should be paired with stopping automatic time drift after signals have been decoded. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Start Automatic Time Drift</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="autoDriftAutoStopCheckBox">
<property name="text">
<string>Stop Automatic Drift After First Decode</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="autoDriftButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatically synchronize time drift every second to decodes of signals observed.&lt;/p&gt;&lt;p&gt;This process is CPU intensive and may cause abnormal decoder behavior if run for extended periods of time.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Start Automatic Time Drift</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncMinuteButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the start of a minute.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Set Time Drift to Now (Minute Start)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the start of a TX cycle in the current transmission speed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Set Time Drift to Now (TX Start)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncEndButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the end of a TX cycle in the current transmission speed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Set Time Drift to Now (TX End)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncResetButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Reset your time drift to zero.</string>
</property>
<property name="text">
<string>Reset Time Drift</string>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Manual</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QPushButton" name="driftSyncMinuteButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the start of a minute.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Set Time Drift to Now (Minute Start)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncEndButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the end of a TX cycle in the current transmission speed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Set Time Drift to Now (TX End)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Observe signals in the waterfall and click this to synchronize your time drift with the start of a TX cycle in the current transmission speed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Set Time Drift to Now (TX Start)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="driftSyncResetButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Reset your time drift to zero.</string>
</property>
<property name="text">
<string>Reset Time Drift</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>