Skip to content

Commit

Permalink
plugins/dmxusb: reworked to have asynchronous output unrelated to cor…
Browse files Browse the repository at this point in the history
…e clock frequency

Output frequency can now be adjusted from the configuration dialog
For now Enttec Open and Enttec Pro are async
  • Loading branch information
mcallegari committed Aug 9, 2018
1 parent 2878f20 commit 90c2733
Show file tree
Hide file tree
Showing 11 changed files with 558 additions and 311 deletions.
16 changes: 16 additions & 0 deletions plugins/dmxusb/src/dmxinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,20 @@ void DMXInterface::storeTypeMap(const QMap <QString,QVariant> map)
settings.setValue(SETTINGS_TYPE_MAP, map);
}

QMap<QString, QVariant> DMXInterface::frequencyMap()
{
QMap <QString,QVariant> typeMap;
QSettings settings;
QVariant var(settings.value(SETTINGS_FREQ_MAP));
if (var.isValid() == true)
typeMap = var.toMap();
return typeMap;
}

void DMXInterface::storeFrequencyMap(const QMap<QString, QVariant> map)
{
QSettings settings;
settings.setValue(SETTINGS_FREQ_MAP, map);
}


11 changes: 10 additions & 1 deletion plugins/dmxusb/src/dmxinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QtCore>

#define SETTINGS_TYPE_MAP "qlcftdi/typemap"
#define SETTINGS_FREQ_MAP "qlcftdi/freqmap"

class DMXInterface
{
Expand Down Expand Up @@ -112,12 +113,20 @@ class DMXInterface

/**
* Get a map of [serial = type] bindings that tells which serials should
* be used to force the plugin to use pro/open method on which widget.
* be used to force the plugin to use pro/open method on which widget
*/
static QMap <QString,QVariant> typeMap();

static void storeTypeMap(const QMap <QString,QVariant> map);

/**
* Get a map of [serial = frequency] bindings that tells which
* output frequency should be used on a specifi serail number
*/
static QMap <QString,QVariant> frequencyMap();

static void storeFrequencyMap(const QMap <QString,QVariant> map);

/************************************************************************
* DMX/Serial Interface Methods
************************************************************************/
Expand Down
3 changes: 1 addition & 2 deletions plugins/dmxusb/src/dmxusb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,14 @@ void DMXUSB::writeUniverse(quint32 universe, quint32 output, const QByteArray &d

bool DMXUSB::openInput(quint32 input, quint32 universe)
{
Q_UNUSED(universe)
if (input < quint32(m_inputs.size()))
{
DMXUSBWidget *widget = m_inputs.at(input);
if (widget->type() == DMXUSBWidget::ProRXTX ||
widget->type() == DMXUSBWidget::ProMk2 ||
widget->type() == DMXUSBWidget::UltraPro)
{
EnttecDMXUSBPro* pro = (EnttecDMXUSBPro*) widget;
EnttecDMXUSBPro *pro = static_cast<EnttecDMXUSBPro*>(widget);
connect(pro, SIGNAL(valueChanged(quint32,quint32,quint32,uchar)),
this, SIGNAL(valueChanged(quint32,quint32,quint32,uchar)));
}
Expand Down
43 changes: 38 additions & 5 deletions plugins/dmxusb/src/dmxusbconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QTreeWidget>
#include <QSettings>
#include <QComboBox>
#include <QSpinBox>
#include <QLayout>
#include <QDebug>
#include <QTimer>
Expand All @@ -35,6 +36,7 @@
#define COL_NAME 0
#define COL_SERIAL 1
#define COL_TYPE 2
#define COL_FREQ 3
#define PROP_SERIAL "serial"

DMXUSBConfig::DMXUSBConfig(DMXUSB* plugin, QWidget* parent)
Expand All @@ -49,7 +51,7 @@ DMXUSBConfig::DMXUSBConfig(DMXUSB* plugin, QWidget* parent)
setWindowTitle(plugin->name());

QStringList header;
header << tr("Name") << tr("Serial") << QString("Mode");
header << tr("Name") << tr("Serial") << QString("Mode") << QString("Frequency");
m_tree->setHeaderLabels(header);
m_tree->setSelectionMode(QAbstractItemView::NoSelection);

Expand Down Expand Up @@ -81,7 +83,7 @@ DMXUSBConfig::~DMXUSBConfig()

void DMXUSBConfig::slotTypeComboActivated(int index)
{
QComboBox* combo = qobject_cast<QComboBox*> (QObject::sender());
QComboBox *combo = qobject_cast<QComboBox*> (QObject::sender());
Q_ASSERT(combo != NULL);

QVariant var = combo->property(PROP_SERIAL);
Expand All @@ -96,6 +98,22 @@ void DMXUSBConfig::slotTypeComboActivated(int index)
QTimer::singleShot(0, this, SLOT(slotRefresh()));
}

void DMXUSBConfig::slotFrequencyValueChanged(int value)
{
QSpinBox *spin = qobject_cast<QSpinBox*> (QObject::sender());
Q_ASSERT(spin != NULL);

QVariant var = spin->property(PROP_SERIAL);
if (var.isValid() == true)
{
QMap <QString,QVariant> frequencyMap(DMXInterface::frequencyMap());
frequencyMap[var.toString()] = value;
DMXInterface::storeFrequencyMap(frequencyMap);
}

QTimer::singleShot(0, this, SLOT(slotRefresh()));
}

void DMXUSBConfig::slotRefresh()
{
m_plugin->rescanWidgets();
Expand All @@ -104,17 +122,18 @@ void DMXUSBConfig::slotRefresh()
QListIterator <DMXUSBWidget*> it(m_plugin->widgets());
while (it.hasNext() == true)
{
DMXUSBWidget* widget = it.next();
QTreeWidgetItem* item = new QTreeWidgetItem(m_tree);
DMXUSBWidget *widget = it.next();
QTreeWidgetItem *item = new QTreeWidgetItem(m_tree);
item->setText(COL_NAME, widget->uniqueName());
item->setText(COL_SERIAL, widget->serial());
m_tree->setItemWidget(item, COL_TYPE, createTypeCombo(widget));
m_tree->setItemWidget(item, COL_FREQ, createFrequencySpin(widget));
}

m_tree->header()->resizeSections(QHeaderView::ResizeToContents);
}

QComboBox* DMXUSBConfig::createTypeCombo(DMXUSBWidget *widget)
QComboBox *DMXUSBConfig::createTypeCombo(DMXUSBWidget *widget)
{
Q_ASSERT(widget != NULL);
QComboBox* combo = new QComboBox;
Expand All @@ -133,3 +152,17 @@ QComboBox* DMXUSBConfig::createTypeCombo(DMXUSBWidget *widget)

return combo;
}

QSpinBox *DMXUSBConfig::createFrequencySpin(DMXUSBWidget *widget)
{
Q_ASSERT(widget != NULL);
QSpinBox *spin = new QSpinBox;
spin->setProperty(PROP_SERIAL, widget->serial());
spin->setRange(1, 60);
spin->setValue(widget->outputFrequency());
spin->setSuffix("Hz");

connect(spin, SIGNAL(valueChanged(int)), this, SLOT(slotFrequencyValueChanged(int)));

return spin;
}
7 changes: 5 additions & 2 deletions plugins/dmxusb/src/dmxusbconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,24 @@ class DMXUSB;
class QPushButton;
class QTreeWidget;
class QComboBox;
class QSpinBox;

class DMXUSBConfig : public QDialog
{
Q_OBJECT

public:
DMXUSBConfig(DMXUSB *plugin, QWidget* parent = 0);
DMXUSBConfig(DMXUSB *plugin, QWidget *parent = 0);
~DMXUSBConfig();

private slots:
void slotTypeComboActivated(int index);
void slotFrequencyValueChanged(int value);
void slotRefresh();

private:
QComboBox* createTypeCombo(DMXUSBWidget* widget);
QComboBox *createTypeCombo(DMXUSBWidget *widget);
QSpinBox *createFrequencySpin(DMXUSBWidget *widget);

private:
DMXUSB* m_plugin;
Expand Down

0 comments on commit 90c2733

Please sign in to comment.