From 51703628d6b1e72b65bf24a5cec56728d9b45ebb Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sun, 9 May 2021 16:01:15 +0200 Subject: [PATCH] fix trigger randomly not working with auto gain/changing gain --- Desktop_Interface/isobuffer.cpp | 15 +++++++++++++-- Desktop_Interface/isobuffer.h | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Desktop_Interface/isobuffer.cpp b/Desktop_Interface/isobuffer.cpp index 771e7562..2b452063 100644 --- a/Desktop_Interface/isobuffer.cpp +++ b/Desktop_Interface/isobuffer.cpp @@ -219,6 +219,7 @@ void isoBuffer::gainBuffer(int gain_log) m_buffer[i+m_bufferLen] >>= gain_log; } } + updateTriggerLevel(); } @@ -417,10 +418,20 @@ void isoBuffer::setTriggerType(TriggerType newType) void isoBuffer::setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled) { m_triggerPositionList.clear(); - m_triggerLevel = inverseSampleConvert(voltageLevel, top, acCoupled); - m_triggerSensitivity = static_cast(1 + abs(voltageLevel * kTriggerSensitivityMultiplier * static_cast(top) / 128.)); + m_triggerVoltage = voltageLevel; + m_triggerTop = top; + m_triggerACCoupled = acCoupled; + + updateTriggerLevel(); +} + +void isoBuffer::updateTriggerLevel() +{ + m_triggerLevel = inverseSampleConvert(m_triggerVoltage, m_triggerTop, m_triggerACCoupled); + m_triggerSensitivity = static_cast(1 + abs(m_triggerVoltage * kTriggerSensitivityMultiplier * static_cast(m_triggerTop) / 128.)); qDebug() << "Trigger Level: " << m_triggerLevel; qDebug() << "Trigger sensitivity:" << m_triggerSensitivity; + } // TODO: Clear trigger diff --git a/Desktop_Interface/isobuffer.h b/Desktop_Interface/isobuffer.h index 39f459b2..801c2e3d 100644 --- a/Desktop_Interface/isobuffer.h +++ b/Desktop_Interface/isobuffer.h @@ -87,6 +87,7 @@ class isoBuffer : public QWidget template int capSample(int offset, int target, double seconds, double value, Function comp); void checkTriggered(); + void updateTriggerLevel(); public: int cap_x0fromLast(double seconds, double vbot); int cap_x1fromLast(double seconds, int x0, double vbot); @@ -121,6 +122,9 @@ class isoBuffer : public QWidget TriggerType m_triggerType = TriggerType::Disabled; TriggerSeekState m_triggerSeekState = TriggerSeekState::BelowTriggerLevel; DownsamplingMethod m_downsamplingMethod = DownsamplingMethod::AverageDelta; + double m_triggerVoltage = 0.; + uint16_t m_triggerTop = 0; + bool m_triggerACCoupled = false; short m_triggerLevel = 0; short m_triggerSensitivity = 0; QVector m_triggerPositionList = {};