Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements #971

Merged
merged 19 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
60b8ed6
Logic: changed default channel names from "DIO X" to "X"
DanielGuramulta Nov 19, 2020
7bb9a67
FreePlotLineHandleV: center the name on the handle
DanielGuramulta Nov 19, 2020
641f9ef
General: when handling exceptions don't introduce undefined behaviour
DanielGuramulta Nov 25, 2020
c9f4904
LogicAnalyzer: implement run button
DanielGuramulta Nov 27, 2020
03fcdd5
LogicTools: show buffer size and sample rate on plot
DanielGuramulta Nov 27, 2020
eed560b
PatternGenerator: display an error when the maximum buffer size is re…
DanielGuramulta Nov 27, 2020
75dda53
MixedSignalView: improve the enabling of this feature
DanielGuramulta Dec 2, 2020
6ddbdc2
LogicAnalyzer: add a sleep when continuosly running between full plots
DanielGuramulta Dec 4, 2020
a5cbe4f
Logic Tools: add time per division information to plot
DanielGuramulta Dec 4, 2020
67ce431
TriggerSettings: reposition Logic Analyzer jump to trigger settings b…
DanielGuramulta Dec 4, 2020
f2f492a
Oscilloscope: now the mixed signal button will also disable the tool
DanielGuramulta Dec 4, 2020
32cb146
MixedSignalView: implement external triggering
DanielGuramulta Dec 8, 2020
9482caf
LogicDataCurve: fix visual bug
DanielGuramulta Dec 8, 2020
af28699
LogicAnalyzer: fix lower case naming
DanielGuramulta Dec 8, 2020
d765f79
Oscilloscope: properly update the mixed signal view button
DanielGuramulta Dec 15, 2020
d1e18e0
MixedSignalView: fix a crash when selecting a channel
DanielGuramulta Dec 15, 2020
eda319a
MixedSignalView: make sure DIO is upper case
DanielGuramulta Dec 15, 2020
3b21a3b
Fix trigger issues with Mixed Signal View
DanielGuramulta Dec 18, 2020
c85bf42
MixedSignalView: enhance current selected channel menu
DanielGuramulta Dec 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 218 additions & 74 deletions src/logicanalyzer/logic_analyzer.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/logicanalyzer/logic_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ private Q_SLOTS:
int m_oscChannelSelected;
QVector<GenericLogicPlotCurve *> m_oscPlotCurves;
QWidget *m_oscDecoderMenu;
QMetaObject::Connection m_oscChannelSelectedConnection;


};
Expand Down
2 changes: 1 addition & 1 deletion src/logicanalyzer/logicanalyzer_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ class LogicAnalyzer_API : public ApiObject
Q_OBJECT

/* sweep settings */
Q_PROPERTY(bool streamOneShot READ getStreamOrOneShot WRITE setStreamOrOneShot)
Q_PROPERTY(double sampleRate READ getSampleRate WRITE setSampleRate)
Q_PROPERTY(int bufferSize READ getBufferSize WRITE setBufferSize)
Q_PROPERTY(bool streamOneShot READ getStreamOrOneShot WRITE setStreamOrOneShot)
Q_PROPERTY(int delay READ getDelay WRITE setDelay)

/* channel settings */
Expand Down
20 changes: 4 additions & 16 deletions src/logicanalyzer/logicdatacurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static const QColor LowColor(0xC0, 0x00, 0x00);
static const QColor SamplingPointColor(0x77, 0x77, 0x77);

LogicDataCurve::LogicDataCurve(uint16_t *data, uint8_t bit, adiscope::logic::LogicTool *logic) :
GenericLogicPlotCurve(QString("Dio " + QString::number(bit)), QString("Dio " + QString::number(bit))),
GenericLogicPlotCurve(QString(QString::number(bit)), QString(QString::number(bit))),
m_logic(logic),
m_startSample(0),
m_endSample(0),
Expand Down Expand Up @@ -170,7 +170,9 @@ void LogicDataCurve::drawLines(QPainter *painter, const QwtScaleMap &xMap,
displayedData += QPointF(fromSampleToTime(m_endSample - 1), (!edges.back().second) * heightInPoints + m_pixelOffset);
}

displayedData += QPointF(plot()->axisInterval(QwtAxis::xBottom).maxValue(), displayedData.back().y());
if (edges.back().first + 1 == m_endSample - 1) {
displayedData += QPointF(plot()->axisInterval(QwtAxis::xBottom).maxValue(), displayedData.back().y());
}

painter->save();
painter->setPen(QColor(74, 100, 255)); //4a64ff
Expand Down Expand Up @@ -230,26 +232,14 @@ void LogicDataCurve::getSubsampledEdges(std::vector<std::pair<uint64_t, bool>> &
double dist = xMap.transform(fromSampleToTime(1)) - xMap.transform(fromSampleToTime(0));

QwtInterval interval = plot()->axisInterval(QwtAxis::xBottom);
// qDebug() << "from plot, left: " << interval.minValue() << " right: " << interval.maxValue();
uint64_t firstEdge = edgeAtX(fromTimeToSample(interval.minValue()), m_edges);
uint64_t lastEdge = edgeAtX(fromTimeToSample(interval.maxValue()), m_edges);

// qDebug() << "First edge is: " << firstEdge;
// qDebug() << "Last edge is: " << lastEdge;

// qDebug() << "first edge: " << firstEdge;
// qDebug() << "last edge: " << lastEdge;

if (m_edges.size() == 0) {
// qDebug() << "first edge: " << firstEdge << " last edge: " << lastEdge;
}

if (firstEdge > 0) {
firstEdge--;
}

if (lastEdge < m_edges.size() - 1) {
// qDebug() << "lastEdge: " << lastEdge << " < " << "m_edges.size() - 1: " << m_edges.size() - 1;
lastEdge++;
}

Expand Down Expand Up @@ -304,12 +294,10 @@ void LogicDataCurve::getSubsampledEdges(std::vector<std::pair<uint64_t, bool>> &
// between the blocks and we want to make sure we display the correct logic level
if (std::abs(a1 - a2) > pointsPerPixel) {
edges.emplace_back(m_edges[std::distance(m_edges.begin(), previous)]);
// qDebug() << "gap emplace!!!!!!!";
} else {
const int64_t currentSample = (*next).first;
if ((*next).second == lastTransition) {
edges.emplace_back((lastSample + currentSample) / 2, !lastTransition);
// qDebug() << "HACK!!!!!!";
}
}

Expand Down
31 changes: 29 additions & 2 deletions src/oscilloscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ void Oscilloscope::setFilteringEnabled(bool set)
setSampleRate(active_sample_rate);
}

void Oscilloscope::enableMixedSignalView()
void Oscilloscope::enableMixedSignalView(ChannelWidget *cw)
{
const bool iioStarted = isIioManagerStarted();
if (iioStarted) {
Expand All @@ -1299,6 +1299,13 @@ void Oscilloscope::enableMixedSignalView()

ui->logicSettingsLayout->addWidget(m_mixedSignalViewMenu[0]);

QTabWidget *tb = qobject_cast<QTabWidget *>(m_mixedSignalViewMenu[0]);
showLogicAnalyzerTriggerConnection = connect(&trigger_settings, &TriggerSettings::showLogicAnalyzerTriggerSettings,
this, [=](){
cw->menuButton()->setChecked(true);
tb->setCurrentIndex(tb->indexOf(m_mixedSignalViewMenu[1]));
});

mixed_sink = mixed_signal_sink::make(m_logicAnalyzer, &this->plot, active_sample_count);

mixed_source = gr::m2k::mixed_signal_source::make_from(m_m2k_context, active_sample_count);
Expand Down Expand Up @@ -1339,6 +1346,8 @@ void Oscilloscope::disableMixedSignalView()

m_mixedSignalViewEnabled = false;

disconnect(showLogicAnalyzerTriggerConnection);

// disable mixed signal from logic
ui->logicSettingsLayout->removeWidget(m_mixedSignalViewMenu[0]);
m_logicAnalyzer->disableMixedSignalView();
Expand Down Expand Up @@ -2076,6 +2085,22 @@ void Oscilloscope::create_add_channel_panel()

tabWidget->addTab(logic, tr("Logic"));

connect(ui->mixedSignalBtn, &QPushButton::clicked, [=](){
if (!m_mixedSignalViewEnabled) {
ui->btnAddMath->click();
tabWidget->setCurrentIndex(tabWidget->indexOf(logic));
} else {
for (int i = 0; i < ui->channelsList->count(); ++i) {
ChannelWidget *cw = qobject_cast<ChannelWidget *>(
ui->channelsList->itemAt(i)->widget());
if (cw && cw->fullName() == "Logic Analyzer") {
cw->deleteButton()->click();
break;
}
}
}
});

connect(btnOpenFile, &QPushButton::clicked, this, &Oscilloscope::import);

connect(tabWidget, &QTabWidget::currentChanged, [=](int index) {
Expand Down Expand Up @@ -2105,6 +2130,7 @@ void Oscilloscope::create_add_channel_panel()
if (tabWidget->currentIndex() == 2) {

qDebug() << "Enable mixed signal view!";
ui->mixedSignalBtn->setText("Disable Mixed\nSignal View");

ChannelWidget *logicAnalyzerChannelWidget = new ChannelWidget(-1, true, false,
QColor(Qt::yellow), this);
Expand Down Expand Up @@ -2144,13 +2170,14 @@ void Oscilloscope::create_add_channel_panel()
logicAnalyzerChannelWidget->deleteLater();

tabWidget->setTabEnabled(logicTab, true);
ui->mixedSignalBtn->setText("Enable Mixed\nSignal View");

disableMixedSignalView();
});

logicAnalyzerChannelWidget->menuButton()->setChecked(true);

enableMixedSignalView();
enableMixedSignalView(logicAnalyzerChannelWidget);

return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/oscilloscope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ namespace adiscope {
void toolDetached(bool);
void setFilteringEnabled(bool set);

void enableMixedSignalView();
void enableMixedSignalView(ChannelWidget *cw);
void disableMixedSignalView();
void setDigitalPlotCurvesParams();

Expand Down Expand Up @@ -490,6 +490,7 @@ namespace adiscope {

gr::m2k::mixed_signal_source::sptr mixed_source;
mixed_signal_sink::sptr mixed_sink;
QMetaObject::Connection showLogicAnalyzerTriggerConnection;
};
}
#endif /* M2K_OSCILLOSCOPE_H */
22 changes: 17 additions & 5 deletions src/oscilloscope_plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ CapturePlot::CapturePlot(QWidget *parent,
d_startedGrouping(false),
d_bottomHandlesArea(nullptr),
d_xAxisInterval{0.0, 0.0},
d_currentHandleInitPx(1)
d_currentHandleInitPx(1),
d_maxBufferError(nullptr)
{
setMinimumHeight(250);
setMinimumWidth(500);
Expand Down Expand Up @@ -160,6 +161,11 @@ CapturePlot::CapturePlot(QWidget *parent,
"color: #ffffff;"
"}");

d_maxBufferError = new QLabel(this);
d_maxBufferError->setStyleSheet("QLabel {"
"color: #ff0000;"
"}");

// Top area layout
QHBoxLayout *topWidgetLayout = new QHBoxLayout(d_topWidget);
topWidgetLayout->setContentsMargins(d_leftHandlesArea->minimumWidth(),
Expand All @@ -171,7 +177,9 @@ CapturePlot::CapturePlot(QWidget *parent,
Qt::AlignBottom);
topWidgetLayout->insertWidget(1, d_sampleRateLabel, 0, Qt::AlignLeft |
Qt::AlignBottom);
topWidgetLayout->insertWidget(2, d_triggerStateLabel, 0, Qt::AlignRight |
topWidgetLayout->insertWidget(2, d_maxBufferError, 0, Qt::AlignRight |
Qt::AlignBottom);
topWidgetLayout->insertWidget(3, d_triggerStateLabel, 0, Qt::AlignRight |
Qt::AlignBottom);

QSpacerItem *spacerItem = new QSpacerItem(0, 0, QSizePolicy::Expanding,
Expand Down Expand Up @@ -1501,7 +1509,6 @@ void CapturePlot::addToGroup(int currentGroup, int toAdd)

void CapturePlot::onDigitalChannelAdded(int chnIdx)
{
qDebug() << "Digital Channel Added!";
setLeftVertAxesCount(d_ydata.size() + d_ref_ydata.size() + chnIdx + 1);
setAxisScale( QwtAxisId(QwtPlot::yLeft, d_ydata.size() + d_ref_ydata.size() + chnIdx), -5, 5);
replot();
Expand Down Expand Up @@ -2374,6 +2381,11 @@ void CapturePlot::setTriggerState(int triggerState)
d_triggerStateLabel->show();
}

void CapturePlot::setMaxBufferSizeErrorLabel(bool reached)
{
d_maxBufferError->setText(reached ? "Maximum buffer size reached" : "");
}

void CapturePlot::setCursorReadoutsTransparency(int value)
{
d_cursorReadouts->setTransparency(value);
Expand All @@ -2387,8 +2399,8 @@ void CapturePlot::moveCursorReadouts(CustomPlotPositionButton::ReadoutsPosition
void CapturePlot::updateBufferSizeSampleRateLabel(int nsamples, double sr)
{
QString txtSampleRate = d_cursorMetricFormatter.format(sr, "sps", 0);
QString txtSamplingPeriod = d_cursorTimeFormatter.format(1 / sr, "", 0);
QString text = QString("%1 Samples at ").arg(nsamples) + txtSampleRate;
QString txtSamples = d_cursorMetricFormatter.format(nsamples, "", 0);
QString text = QString("%1 Samples at ").arg(txtSamples) + txtSampleRate;
d_sampleRateLabel->setText(text);
}

Expand Down
2 changes: 2 additions & 0 deletions src/oscilloscope_plot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ namespace adiscope {
void setBufferSizeLabelValue(int numSamples);
void setSampleRatelabelValue(double sampleRate);
void setTriggerState(int triggerState);
void setMaxBufferSizeErrorLabel(bool reached);
void setCursorReadoutsTransparency(int value);
void moveCursorReadouts(CustomPlotPositionButton::ReadoutsPosition position);
void setHorizCursorsLocked(bool value);
Expand Down Expand Up @@ -249,6 +250,7 @@ namespace adiscope {
QLabel *d_timeBaseLabel;
QLabel *d_sampleRateLabel;
QLabel *d_triggerStateLabel;
QLabel *d_maxBufferError;

int d_bufferSizeLabelVal;
double d_sampleRateLabelVal;
Expand Down
7 changes: 7 additions & 0 deletions src/patterngenerator/pattern_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,17 @@ void PatternGenerator::generateBuffer()
m_sampleRate = sr;

const uint64_t bufferSize = computeBufferSize(sr);
m_plot.setMaxBufferSizeErrorLabel(bufferSize == MAX_BUFFER_SIZE);

qDebug() << "Buffer size is: " << bufferSize;
m_bufferSize = bufferSize;

m_plot.setSampleRatelabelValue(m_sampleRate);
m_plot.setBufferSizeLabelValue(m_bufferSize);
m_plot.setTimeBaseLabelValue(static_cast<double>(m_bufferSize) /
static_cast<double>(m_sampleRate) /
m_plot.xAxisNumDiv());

if (m_buffer) {
delete[] m_buffer;
}
Expand Down
8 changes: 4 additions & 4 deletions src/plot_line_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,14 +662,14 @@ void FreePlotLineHandleV::paintEvent(QPaintEvent *)
setToolTip("");
}

const double textHeight = QFontMetrics(QFont(fontFamily, fontSize)).height();

QPointF textPos(0.0, m_height / 2.0 + textHeight / 4.0);
const QSizeF size = QFontMetricsF(QFont(fontFamily, fontSize)).size(Qt::TextSingleLine, m_name);
QRectF textRect(QPointF(0.0, 0.0), size);
textRect.moveCenter(QPointF(m_image.width() / 2.0, m_height / 2.0));

p.save();
p.setPen(QPen(QBrush(Qt::white), 20));
p.setFont(QFont(fontFamily, fontSize));
p.drawText(textPos, m_name);
p.drawText(textRect, m_name);
p.restore();
} else {
p.drawPixmap(imageTopLeft, m_image);
Expand Down
22 changes: 15 additions & 7 deletions src/scopyExceptionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,33 @@
#include <config.h>
#include <libm2k/m2kexceptions.hpp>
#include <scopyApplication.hpp>
#include <QThread>

using namespace adiscope;

#define HANDLE_EXCEPTION(e) \
if(GetScopyApplicationInstance()->getDebugMode()) { \
if (GetScopyApplicationInstance()->getDebugMode()) { \
auto me = dynamic_cast<libm2k::m2k_exception *>(&e); \
auto handleLambda = [me, e](){ \
QMessageBox msg; \
QString str; \
auto me = dynamic_cast<libm2k::m2k_exception*>(&e);\
if(me) { \
if (me) { \
str = QString("Exception %1\ne.type() - %2\ne.what() - %3\ne.iioCode() - %4\nthrown from %5:%6\ncaught in %7:%8\nScopy git tag %9\n") \
.arg("m2k_exception").arg(me->type()).arg(me->what()).arg(me->iioCode()).arg(QString::fromStdString(me->file())).arg(QString::number(me->line())).arg(__FILE__).arg(__LINE__).arg(SCOPY_VERSION_GIT); \
} else { \
str = QString("Exception %1\ncaught in %2:%3\nScopy git tag %4\n").arg(e.what()).arg(__FILE__).arg(__LINE__).arg(SCOPY_VERSION_GIT); \
} \
if(WriteScopyMinidump()) { \
if (WriteScopyMinidump()) { \
str = str + "Created minidump."; \
}\
msg.setText(str);\
msg.exec();\
} \
msg.setText(str); \
msg.exec(); \
}; \
if (GetScopyApplicationInstance()->thread() != QThread::currentThread()) { \
QMetaObject::invokeMethod(GetScopyApplicationInstance(), handleLambda, Qt::BlockingQueuedConnection); \
} else { \
handleLambda(); \
} \
} \

#endif // SCOPYEXCEPTIONHANDLER_H
18 changes: 17 additions & 1 deletion src/trigger_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ TriggerSettings::TriggerSettings(M2kAnalogIn* libm2k_adc,
trigger_raw_delay(0),
daisyChainCompensation(0),
m_trigger_in(false),
m_has_external_trigger_out(false)
m_has_external_trigger_out(false),
digital_trigger_was_on(false)
{
initInstrumentStrings();
ui->setupUi(this);
Expand Down Expand Up @@ -169,6 +170,10 @@ TriggerSettings::TriggerSettings(M2kAnalogIn* libm2k_adc,
wheelEventGuard->installEventRecursively(this);

ui->mixedSignalLbl->setVisible(false);
ui->btnLogicAnalyzerTriggers->setVisible(false);

connect(ui->btnLogicAnalyzerTriggers, &QPushButton::clicked,
this, &TriggerSettings::showLogicAnalyzerTriggerSettings);
}

TriggerSettings::~TriggerSettings()
Expand Down Expand Up @@ -253,13 +258,24 @@ void TriggerSettings::enableMixedSignalView()
ui->extern_en->setDisabled(true);
ui->extern_to_en->setDisabled(true);
ui->mixedSignalLbl->setVisible(true);
ui->btnLogicAnalyzerTriggers->setVisible(true);
ui->btnLogicAnalyzerTriggers->setEnabled(true);
digital_trigger_was_on = ui->digital_controls->isEnabled();
if (digital_trigger_was_on) {
ui->digital_controls->setDisabled(true);
}
}

void TriggerSettings::disableMixedSignalView()
{
ui->extern_en->setEnabled(true);
ui->extern_to_en->setEnabled(true);
ui->mixedSignalLbl->setVisible(false);
ui->btnLogicAnalyzerTriggers->setVisible(false);
ui->btnLogicAnalyzerTriggers->setDisabled(true);
if (digital_trigger_was_on) {
ui->digital_controls->setEnabled(true);
}
}

void TriggerSettings::setDcLevelCoupled(double value)
Expand Down
3 changes: 3 additions & 0 deletions src/trigger_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace adiscope {
void levelChanged(double);
void analogTriggerEnabled(bool);
void triggerModeChanged(int);
void showLogicAnalyzerTriggerSettings();

public Q_SLOTS:
void setTriggerDelay(long long);
Expand Down Expand Up @@ -145,6 +146,8 @@ namespace adiscope {
libm2k::M2kHardwareTrigger* m_trigger;
bool m_trigger_in;

bool digital_trigger_was_on;

std::vector<std::pair<QString, libm2k::M2K_TRIGGER_OUT_SELECT>> externalTriggerOutMapping;

QList<trigg_channel_config> trigg_configs;
Expand Down
Loading