Reset drift average on clear
This commit is contained in:
parent
09e1e57c62
commit
bdcd350aa4
@ -5402,8 +5402,10 @@ void MainWindow::processDecodedLine(QByteArray t){
|
||||
if(JS8_DEBUG_DECODE) qDebug() << "decode duration" << msec << "ms";
|
||||
|
||||
if(!driftQueue.isEmpty()){
|
||||
static int driftN = 1;
|
||||
static int driftAvg = DriftingDateTime::drift();
|
||||
if(m_driftMsMMA_N == 0){
|
||||
m_driftMsMMA_N = 1;
|
||||
m_driftMsMMA = DriftingDateTime::drift();
|
||||
}
|
||||
|
||||
// let the widegraph know for timing control
|
||||
m_wideGraph->notifyDriftedSignalsDecoded(driftQueue.count());
|
||||
@ -5412,12 +5414,11 @@ void MainWindow::processDecodedLine(QByteArray t){
|
||||
int newDrift = driftQueue.first();
|
||||
driftQueue.removeFirst();
|
||||
|
||||
driftAvg = ((driftN-1)*driftAvg + newDrift)/driftN;
|
||||
if(driftN < 60) driftN++; // cap it to 60 observations
|
||||
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(driftAvg);
|
||||
|
||||
setDrift(m_driftMsMMA);
|
||||
|
||||
//writeNoticeTextToUI(QDateTime::currentDateTimeUtc(), QString("Automatic Drift: %1").arg(driftAvg));
|
||||
}
|
||||
@ -11157,40 +11158,13 @@ void MainWindow::processActivity(bool force) {
|
||||
m_rxDirty = false;
|
||||
}
|
||||
|
||||
void MainWindow::observeTimeDeltaForAverage(float delta){
|
||||
// delta can only be +/- the TR period
|
||||
delta = qMax(-(float)m_TRperiod, qMin(delta, (float)m_TRperiod));
|
||||
|
||||
// compute average drift
|
||||
if(m_timeDeltaMsMMA_N == 0){
|
||||
m_timeDeltaMsMMA_N++;
|
||||
m_timeDeltaMsMMA = (int)(delta*1000);
|
||||
} else {
|
||||
m_timeDeltaMsMMA_N++;
|
||||
m_timeDeltaMsMMA = (((m_timeDeltaMsMMA_N-1)*m_timeDeltaMsMMA) + (int)(delta*1000))/ min(m_timeDeltaMsMMA_N, 100);
|
||||
}
|
||||
|
||||
// display average
|
||||
if(m_timeDeltaMsMMA < -(float)m_TRperiod || m_timeDeltaMsMMA > (float)m_TRperiod){
|
||||
resetTimeDeltaAverage();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::resetTimeDeltaAverage(){
|
||||
m_timeDeltaMsMMA = 0;
|
||||
m_timeDeltaMsMMA_N = 0;
|
||||
|
||||
// observe zero for reset
|
||||
observeTimeDeltaForAverage(0);
|
||||
m_driftMsMMA = 0;
|
||||
m_driftMsMMA_N = 1;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setDrift(int n){
|
||||
// drifting functionality moved to the widegraph
|
||||
m_wideGraph->setDrift(n);
|
||||
|
||||
// reset the average if we set a new drift
|
||||
resetTimeDeltaAverage();
|
||||
}
|
||||
|
||||
void MainWindow::processIdleActivity() {
|
||||
@ -11260,8 +11234,6 @@ void MainWindow::processRxActivity() {
|
||||
});
|
||||
}
|
||||
|
||||
observeTimeDeltaForAverage(d.tdrift);
|
||||
|
||||
// use the actual frequency and check its delta from our current frequency
|
||||
// meaning, if our current offset is 1502 and the d.freq is 1492, the delta is <= 10;
|
||||
bool shouldDisplay = abs(d.offset - freqOffset) <= rxThreshold(d.submode);
|
||||
|
@ -833,8 +833,8 @@ private:
|
||||
QString m_totalTxMessage;
|
||||
QDateTime m_lastTxStartTime;
|
||||
QDateTime m_lastTxStopTime;
|
||||
int m_timeDeltaMsMMA;
|
||||
int m_timeDeltaMsMMA_N;
|
||||
int m_driftMsMMA;
|
||||
int m_driftMsMMA_N;
|
||||
|
||||
enum Priority {
|
||||
PriorityLow = 10,
|
||||
@ -1044,7 +1044,6 @@ private:
|
||||
void markOffsetDirected(int offset, bool isAllCall);
|
||||
void clearOffsetDirected(int offset);
|
||||
void processActivity(bool force=false);
|
||||
void observeTimeDeltaForAverage(float delta);
|
||||
void resetTimeDeltaAverage();
|
||||
void processRxActivity();
|
||||
void processIdleActivity();
|
||||
|
Loading…
Reference in New Issue
Block a user