isoBuffer calculates trigger frequency

This commit is contained in:
Chris Esposito 2021-06-24 19:04:36 +10:00
parent 7b0dc8e7bc
commit ae7c631de0
3 changed files with 25 additions and 3 deletions

View File

@ -380,14 +380,14 @@ void isoBuffer::checkTriggered()
// Rising Edge
m_triggerSeekState = TriggerSeekState::AboveTriggerLevel;
if (m_triggerType == TriggerType::Rising)
m_triggerPositionList.push_back(m_back - 1);
addTriggerPosition(m_back - 1);
}
else if ((bufferAt(0) < (m_triggerLevel - m_triggerSensitivity)) && (m_triggerSeekState == TriggerSeekState::AboveTriggerLevel))
{
// Falling Edge
m_triggerSeekState = TriggerSeekState::BelowTriggerLevel;
if (m_triggerType == TriggerType::Falling)
m_triggerPositionList.push_back(m_back - 1);
addTriggerPosition(m_back - 1);
}
}
@ -411,7 +411,7 @@ double isoBuffer::getDelayedTriggerPoint(double delay)
if (m_back > index)
return (m_back - index) / static_cast<double>(m_samplesPerSecond);
else
return (m_bufferLen + (m_back-1) - index) / static_cast<double>(m_samplesPerSecond);
return (m_bufferLen + (m_back - 1) - index) / static_cast<double>(m_samplesPerSecond);
};
// Like std::find_if but returns the last element matching the predicate instead of the first one
@ -441,3 +441,14 @@ double isoBuffer::getDelayedTriggerPoint(double delay)
return 0;
}
void isoBuffer::addTriggerPosition(uint32_t position)
{
static uint32_t s_lastPosition = 0;
m_triggerPositionList.push_back(m_back - 1);
m_lastTriggerDetlaT = (position > s_lastPosition) ? (position - s_lastPosition) : position + m_bufferLen - s_lastPosition;
s_lastPosition = position;
//qDebug() << position << s_lastPosition << static_cast<double>(m_samplesPerSecond) / static_cast<double>(m_lastTriggerDetlaT) << "Hz";
}

View File

@ -127,8 +127,11 @@ private:
qulonglong m_fileIO_maxFileSize;
qulonglong m_fileIO_numBytesWritten;
unsigned int m_currentColumn = 0;
uint32_t m_lastTriggerDetlaT = 0;
isoDriver* m_virtualParent;
void addTriggerPosition(uint32_t position);
signals:
void fileIOinternalDisable();
public slots:

View File

@ -1434,6 +1434,14 @@ void isoDriver::hideCH2(bool enable)
void isoDriver::triggerStateChanged()
{
if (!triggerEnabled)
{
internalBuffer375_CH1->setTriggerType(TriggerType::Disabled);
internalBuffer375_CH2->setTriggerType(TriggerType::Disabled);
internalBuffer750->setTriggerType(TriggerType::Disabled);
return;
}
qDebug() << "triggerStateChanged()";
switch(triggerMode)
{