Skip to content

Commit

Permalink
iio-widget-factory
Browse files Browse the repository at this point in the history
  • Loading branch information
adisuciu committed Jun 25, 2024
1 parent 5eb42f0 commit 854eb82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 10 additions & 5 deletions plugins/adc/src/time/grdevicecomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <widgets/menusectionwidget.h>
#include <widgets/menuheader.h>
#include <iio-widgets/iiowidget.h>
#include <iio-widgets/iiowidgetfactory.h>
#include <iio-widgets/iiowidgetbuilder.h>

using namespace scopy;
using namespace scopy::adc;
Expand Down Expand Up @@ -34,11 +34,16 @@ QWidget *GRDeviceComponent::createAttrMenu(QWidget *parent)
{
MenuSectionCollapseWidget *attr =
new MenuSectionCollapseWidget("ATTRIBUTES", MenuCollapseSection::MHCW_NONE, parent);
QList<IIOWidget *> attrWidgets = IIOWidgetFactory::buildAllAttrsForDevice(m_src->iioDev());

QList<IIOWidget *> attrWidgets = IIOWidgetBuilder().device(m_src->iioDev()).buildAll();
const struct iio_context *ctx = iio_device_get_context(m_src->iioDev());
attrWidgets.append(IIOWidgetFactory::buildSingle(
IIOWidgetFactory::ComboUi | IIOWidgetFactory::TriggerData,
{.context = const_cast<iio_context *>(ctx), .device = m_src->iioDev(), .data = "Triggers"}));
attrWidgets.append(IIOWidgetBuilder()
.context(const_cast<iio_context *>(ctx))
.device(m_src->iioDev())
.attribute("Triggers")
.uiStrategy(IIOWidgetBuilder::UIS::ComboUi)
.dataStrategy(IIOWidgetBuilder::DS::TriggerData)
.buildSingle());

auto layout = new QVBoxLayout();
layout->setSpacing(10);
Expand Down
11 changes: 8 additions & 3 deletions plugins/adc/src/time/grtimechannelcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <gr-util/grsignalpath.h>

#include <iio-widgets/iiowidget.h>
#include <iio-widgets/iiowidgetfactory.h>
#include <iio-widgets/iiowidgetbuilder.h>
#include <timeplotcomponentchannel.h>
#include <gui/widgets/menuplotchannelcurvestylecontrol.h>

Expand Down Expand Up @@ -66,7 +66,10 @@ QWidget *GRTimeChannelComponent::createYAxisMenu(QWidget *parent)
m_scaleWidget = nullptr;
if(m_scaleAvailable) {
cb->addItem(m_unit, YMODE_SCALE);
m_scaleWidget = IIOWidgetFactory::buildAttrForChannel(m_src->channel(), m_src->scaleAttribute(), this);
m_scaleWidget = IIOWidgetBuilder()
.channel(m_src->channel())
.attribute(m_src->scaleAttribute())
.buildSingle();
}

m_yCtrl = new MenuPlotAxisRangeControl(m_plotChannelCmpt->m_timePlotYAxis, m_yaxisMenu);
Expand Down Expand Up @@ -173,7 +176,7 @@ QWidget *GRTimeChannelComponent::createAttrMenu(QWidget *parent)
{
MenuSectionCollapseWidget *section =
new MenuSectionCollapseWidget("ATTRIBUTES", MenuCollapseSection::MHCW_NONE, parent);
QList<IIOWidget *> attrWidgets = IIOWidgetFactory::buildAllAttrsForChannel(m_src->channel());
QList<IIOWidget *> attrWidgets = IIOWidgetBuilder().channel(m_src->channel()).buildAll();

auto layout = new QVBoxLayout();
layout->setSpacing(10);
Expand Down Expand Up @@ -264,6 +267,8 @@ void GRTimeChannelComponent::setYModeHelper(YMode mode)
ymax = (1 << (fmt->bits));
}

scale = scale / 1000.0; // target value is in mV

ymin = ymin * scale;
ymax = ymax * scale;

Expand Down

0 comments on commit 854eb82

Please sign in to comment.