Skip to content

Commit

Permalink
fix trigger randomly not working with auto gain/changing gain
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsmark committed May 9, 2021
1 parent 0bb3bbc commit 5170362
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Desktop_Interface/isobuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void isoBuffer::gainBuffer(int gain_log)
m_buffer[i+m_bufferLen] >>= gain_log;
}
}
updateTriggerLevel();
}


Expand Down Expand Up @@ -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<short>(1 + abs(voltageLevel * kTriggerSensitivityMultiplier * static_cast<double>(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<short>(1 + abs(m_triggerVoltage * kTriggerSensitivityMultiplier * static_cast<double>(m_triggerTop) / 128.));
qDebug() << "Trigger Level: " << m_triggerLevel;
qDebug() << "Trigger sensitivity:" << m_triggerSensitivity;

}

// TODO: Clear trigger
Expand Down
4 changes: 4 additions & 0 deletions Desktop_Interface/isobuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class isoBuffer : public QWidget
template<typename Function>
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);
Expand Down Expand Up @@ -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<uint32_t> m_triggerPositionList = {};
Expand Down

0 comments on commit 5170362

Please sign in to comment.