mirror of https://github.com/EspoTek/Labrador.git
new trigger working (with some bugs)
This commit is contained in:
parent
6773347739
commit
9e2f678dce
|
@ -364,10 +364,50 @@ void isoBuffer::checkTriggered()
|
||||||
{
|
{
|
||||||
// Rising Edge
|
// Rising Edge
|
||||||
m_triggerSeekState = TriggerSeekState::AboveTriggerLevel;
|
m_triggerSeekState = TriggerSeekState::AboveTriggerLevel;
|
||||||
|
if (m_triggerType == TriggerType::Rising)
|
||||||
|
m_triggerPositionList.push_back(m_back - 1);
|
||||||
}
|
}
|
||||||
else if ((bufferAt(0) < (m_triggerLevel - m_triggerSensitivity)) && (m_triggerSeekState == TriggerSeekState::AboveTriggerLevel))
|
else if ((bufferAt(0) < (m_triggerLevel - m_triggerSensitivity)) && (m_triggerSeekState == TriggerSeekState::AboveTriggerLevel))
|
||||||
{
|
{
|
||||||
// Falling Edge
|
// Falling Edge
|
||||||
m_triggerSeekState = TriggerSeekState::BelowTriggerLevel;
|
m_triggerSeekState = TriggerSeekState::BelowTriggerLevel;
|
||||||
|
if (m_triggerType == TriggerType::Falling)
|
||||||
|
m_triggerPositionList.push_back(m_back - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double isoBuffer::getDelayedTriggerPoint(double delay)
|
||||||
|
{
|
||||||
|
const uint32_t delaySamples = delay * m_samplesPerSecond;
|
||||||
|
|
||||||
|
auto isValid = [=](uint32_t index)->bool
|
||||||
|
{
|
||||||
|
if (m_back > delaySamples)
|
||||||
|
return (index < ((uint32_t)m_back - delaySamples)) || (index >= (uint32_t)m_back);
|
||||||
|
else
|
||||||
|
// Fixme: There's probably an off by one here.
|
||||||
|
return (index < (m_bufferEnd + m_back - delaySamples)) && (index >= m_back);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto getDelay = [=](uint32_t index)->double
|
||||||
|
{
|
||||||
|
if (m_back > index)
|
||||||
|
return (m_back - index) / static_cast<double>(m_samplesPerSecond);
|
||||||
|
else
|
||||||
|
return (m_bufferEnd + m_back - index) / static_cast<double>(m_samplesPerSecond);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Fixme: this won't look at the first element in the list.
|
||||||
|
for (auto it = std::prev(m_triggerPositionList.end()); it != m_triggerPositionList.begin(); it--)
|
||||||
|
{
|
||||||
|
if (isValid(*it))
|
||||||
|
{
|
||||||
|
uint32_t index = *it;
|
||||||
|
if (it != m_triggerPositionList.begin())
|
||||||
|
m_triggerPositionList.erase(m_triggerPositionList.begin(), std::prev(it));
|
||||||
|
return getDelay(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
void serialManage(double baudRate, UartParity parity);
|
void serialManage(double baudRate, UartParity parity);
|
||||||
void setTriggerType(TriggerType newType);
|
void setTriggerType(TriggerType newType);
|
||||||
void setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled);
|
void setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled);
|
||||||
|
double getDelayedTriggerPoint(double delay);
|
||||||
|
|
||||||
// ---- MEMBER VARIABLES ----
|
// ---- MEMBER VARIABLES ----
|
||||||
|
|
||||||
|
|
|
@ -685,13 +685,16 @@ void isoDriver::frameActionGeneric(char CH1_mode, char CH2_mode) //0 for off, 1
|
||||||
//qDebug() << "Now offset = " << offset;
|
//qDebug() << "Now offset = " << offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixme: Won't work with CH2
|
||||||
double triggerDelay = 0;
|
double triggerDelay = 0;
|
||||||
|
if (triggerEnabled)
|
||||||
|
triggerDelay = internalBuffer375_CH1->getDelayedTriggerPoint(window) - window;
|
||||||
if(singleShotEnabled && (triggerDelay != 0))
|
if(singleShotEnabled && (triggerDelay != 0))
|
||||||
singleShotTriggered(1);
|
singleShotTriggered(1);
|
||||||
|
|
||||||
readData375_CH1 = internalBuffer375_CH1->readBuffer(window,GRAPH_SAMPLES,CH1_mode==2, delay + (triggerEnabled ? triggerDelay + window/2 : 0));
|
readData375_CH1 = internalBuffer375_CH1->readBuffer(window,GRAPH_SAMPLES,CH1_mode==2, delay + triggerDelay);
|
||||||
if(CH2_mode) readData375_CH2 = internalBuffer375_CH2->readBuffer(window,GRAPH_SAMPLES,CH2_mode==2, delay + (triggerEnabled ? triggerDelay + window/2 : 0));
|
if(CH2_mode) readData375_CH2 = internalBuffer375_CH2->readBuffer(window,GRAPH_SAMPLES,CH2_mode==2, delay + triggerDelay);
|
||||||
if(CH1_mode == -1) readData750 = internalBuffer750->readBuffer(window,GRAPH_SAMPLES,false, delay + (triggerEnabled ? triggerDelay + window/2 : 0));
|
if(CH1_mode == -1) readData750 = internalBuffer750->readBuffer(window,GRAPH_SAMPLES,false, delay + triggerDelay);
|
||||||
if(CH1_mode == -2) readDataFile = internalBufferFile->readBuffer(window,GRAPH_SAMPLES,false, delay);
|
if(CH1_mode == -2) readDataFile = internalBufferFile->readBuffer(window,GRAPH_SAMPLES,false, delay);
|
||||||
|
|
||||||
QVector<double> x(GRAPH_SAMPLES), CH1(GRAPH_SAMPLES), CH2(GRAPH_SAMPLES);
|
QVector<double> x(GRAPH_SAMPLES), CH1(GRAPH_SAMPLES), CH2(GRAPH_SAMPLES);
|
||||||
|
|
Loading…
Reference in New Issue