trigger frequency displayed

This commit is contained in:
Chris Esposito 2021-06-24 20:12:28 +10:00
parent ae7c631de0
commit b24e39fb8b
7 changed files with 64 additions and 7 deletions

View File

@ -358,6 +358,7 @@ void isoBuffer::setTriggerType(TriggerType newType)
{
qDebug() << "Trigger Type: " << (uint8_t)newType;
m_triggerType = newType;
m_lastTriggerDetlaT = 0;
}
void isoBuffer::setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled)
@ -366,6 +367,7 @@ void isoBuffer::setTriggerLevel(double voltageLevel, uint16_t top, bool acCouple
m_triggerSensitivity = static_cast<short>(1 + abs(voltageLevel * kTriggerSensitivityMultiplier * static_cast<double>(top) / 128.));
qDebug() << "Trigger Level: " << m_triggerLevel;
qDebug() << "Trigger sensitivity:" << m_triggerSensitivity;
m_lastTriggerDetlaT = 0;
}
// TODO: Clear trigger
@ -442,6 +444,11 @@ double isoBuffer::getDelayedTriggerPoint(double delay)
return 0;
}
double isoBuffer::getTriggerFrequencyHz()
{
return (m_lastTriggerDetlaT == 0) ? -1. : static_cast<double>(m_samplesPerSecond) / static_cast<double>(m_lastTriggerDetlaT);
}
void isoBuffer::addTriggerPosition(uint32_t position)
{
static uint32_t s_lastPosition = 0;

View File

@ -86,6 +86,7 @@ public:
void setTriggerType(TriggerType newType);
void setTriggerLevel(double voltageLevel, uint16_t top, bool acCoupled);
double getDelayedTriggerPoint(double delay);
double getTriggerFrequencyHz();
// ---- MEMBER VARIABLES ----

View File

@ -1126,15 +1126,16 @@ void isoDriver::triggerGroupStateChange(bool enabled){
}
void isoDriver::broadcastStats(bool CH2){
if(CH2){
if(!update_CH2) return;
if (CH2 && update_CH2)
{
update_CH2 = false;
sendVmax_CH2(currentVmax);
sendVmin_CH2(currentVmin);
sendVmean_CH2(currentVmean);
sendVRMS_CH2(currentVRMS);
} else{
if(!update_CH1) return;
}
else if (update_CH1)
{
update_CH1 = false;
sendVmax_CH1(currentVmax);
sendVmin_CH1(currentVmin);
@ -1146,6 +1147,39 @@ void isoDriver::broadcastStats(bool CH2){
void isoDriver::slowTimerTick(){
update_CH1 = true;
update_CH2 = true;
bool frequencyLabelVisible = false;
if (triggerEnabled)
{
double triggerFrequency;
switch(triggerMode)
{
case 0:
case 1:
triggerFrequency = (driver->deviceMode == 6) ? internalBuffer750->getTriggerFrequencyHz() : internalBuffer375_CH1->getTriggerFrequencyHz();
break;
case 2:
case 3:
triggerFrequency = internalBuffer375_CH2->getTriggerFrequencyHz();
break;
}
if (triggerFrequency > 0.)
{
frequencyLabelVisible = true;
siprint triggerFreqSiprint("Hz", triggerFrequency);
siprint periodSiprint("s", 1. / triggerFrequency);
QString cursorString;
cursorString.sprintf(" Trigger ΔT = %s, f = %s ", periodSiprint.printVal(), triggerFreqSiprint.printVal());
triggerFrequencyLabel->setText(cursorString);
}
qDebug() << triggerFrequency << "Hz";
}
triggerFrequencyLabel->setVisible(frequencyLabelVisible);
}
void isoDriver::setTopRange(double newTop)

View File

@ -61,6 +61,7 @@ public:
isoBuffer_file *internalBufferFile = NULL;
#if QCP_VER == 1
QCPItemText *cursorTextPtr;
QCPItemText *triggerFrequencyLabel;
#endif
genericUsbDriver *driver;
bool doNotTouchGraph = true;

View File

@ -278,8 +278,22 @@ void MainWindow::initialisePlot()
textLabel->setPen(QPen(Qt::white));
textLabel->setBrush(QBrush(Qt::black));
textLabel->setVisible(0);
QCPItemText* triggerFrequencyLabel = new QCPItemText(ui->scopeAxes);
ui->scopeAxes->addItem(triggerFrequencyLabel);
triggerFrequencyLabel->setPositionAlignment(Qt::AlignBottom|Qt::AlignHCenter);
triggerFrequencyLabel->position->setType(QCPItemPosition::ptAxisRectRatio);
triggerFrequencyLabel->position->setCoords(0.5, 0.98);
triggerFrequencyLabel->setText("Default Trigger Frequency Text");
triggerFrequencyLabel->setFont(QFont("Courier New", 16));
triggerFrequencyLabel->setColor(Qt::white);
triggerFrequencyLabel->setPen(QPen(Qt::white));
triggerFrequencyLabel->setBrush(QBrush(Qt::black));
textLabel->setVisible(false);
triggerFrequencyLabel->setVisible(false);
ui->controller_iso->cursorTextPtr = textLabel;
ui->controller_iso->triggerFrequencyLabel = triggerFrequencyLabel;
ui->scopeAxes->yAxis->setAutoTickCount(9);
ui->scopeAxes->xAxis->setAutoTickCount(9);

View File

@ -1,6 +1,6 @@
#include "siprint.h"
siprint::siprint(char *unitsInit, double valInit)
siprint::siprint(const char *unitsInit, double valInit)
{
strncpy(units, unitsInit, 6);
value = valInit;

View File

@ -9,7 +9,7 @@
class siprint
{
public:
siprint(char *unitsInit, double valInit);
siprint(const char *unitsInit, double valInit);
char* printVal();
char units[6];
double value;