Permalink
Browse files

plugins/dmxusb: allow DMXUSBWidget subclasses to request a preferred …

…output frequency

This basically reverts Open DMX to the crappy 30Hz frequency
  • Loading branch information...
mcallegari committed Dec 7, 2018
1 parent 93cda87 commit fae57a2e1deb81068c5d9a5c80cc1480c9ed25a2
@@ -31,9 +31,7 @@
#include "stageprofi.h"
#include "vinceusbdmx512.h"

#define DEFAULT_OUTPUT_FREQUENCY 44 // 44 Hertz, according to the DMX specs

DMXUSBWidget::DMXUSBWidget(DMXInterface *interface, quint32 outputLine)
DMXUSBWidget::DMXUSBWidget(DMXInterface *interface, quint32 outputLine, int frequency)
: m_interface(interface)
, m_outputBaseLine(outputLine)
, m_inputBaseLine(0)
@@ -44,7 +42,7 @@ DMXUSBWidget::DMXUSBWidget(DMXInterface *interface, quint32 outputLine)
if (freqMap.contains(m_interface->serial()))
setOutputFrequency(freqMap[m_interface->serial()].toInt());
else
setOutputFrequency(DEFAULT_OUTPUT_FREQUENCY);
setOutputFrequency(frequency);

setOutputsNumber(1);
setInputsNumber(0);
@@ -397,7 +395,7 @@ void DMXUSBWidget::setOutputFrequency(int frequency)
{
m_frequency = frequency;
// One "official" DMX frame can take (1s/44Hz) = 23ms
m_frameTimeUs = (int) (floor(((double)1000 / m_frequency) + (double)0.5)) * 1000;
m_frameTimeUs = int((floor((1000.0 / double(m_frequency)) + 0.5)) * 1000.0);
}

/********************************************************************
@@ -33,6 +33,8 @@
#include "qtserial-interface.h"
#endif

#define DEFAULT_OUTPUT_FREQUENCY 44 // 44 Hertz, according to the DMX specs

typedef struct
{
/** The device line type (DMX, MIDI, etc) */
@@ -57,7 +59,7 @@ class DMXUSBWidget
* @param interface The widget's DMXInterface instance
* @param outputLine the specific output line this widget is going to control
*/
DMXUSBWidget(DMXInterface *interface, quint32 outputLine);
DMXUSBWidget(DMXInterface *interface, quint32 outputLine, int frequency);

virtual ~DMXUSBWidget();

@@ -29,6 +29,7 @@
#define DMX_MAB 16
#define DMX_BREAK 110
#define DMX_CHANNELS 512
#define DEFAULT_OPEN_DMX_FREQUENCY 30 // crap
#define SETTINGS_CHANNELS "enttecdmxusbopen/channels"

/****************************************************************************
@@ -38,7 +39,7 @@
EnttecDMXUSBOpen::EnttecDMXUSBOpen(DMXInterface *interface,
quint32 outputLine, QObject* parent)
: QThread(parent)
, DMXUSBWidget(interface, outputLine)
, DMXUSBWidget(interface, outputLine, DEFAULT_OPEN_DMX_FREQUENCY)
, m_running(false)
, m_granularity(Unknown)
{
@@ -208,7 +209,7 @@ void EnttecDMXUSBOpen::run()
framesleep:
// Sleep for the remainder of the DMX frame time
// and set granularity accordingly
int timetoSleep = m_frameTimeUs - (timer.nsecsElapsed() / 1000);
long timetoSleep = m_frameTimeUs - (timer.nsecsElapsed() / 1000);
if (timetoSleep < 0)
{
qWarning() << "DMX output is running late !";
@@ -27,7 +27,7 @@

EnttecDMXUSBPro::EnttecDMXUSBPro(DMXInterface *interface, quint32 outputLine, quint32 inputLine)
: QThread(NULL)
, DMXUSBWidget(interface, outputLine)
, DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_dmxKingMode(false)
, m_inputThread(NULL)
, m_outputRunning(false)
@@ -23,7 +23,7 @@
#include <QDir>

EuroliteUSBDMXPro::EuroliteUSBDMXPro(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine)
: DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_running(false)
{
}
@@ -23,7 +23,7 @@
#include <QDir>

NanoDMX::NanoDMX(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine)
: DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_running(false)
{
}
@@ -23,7 +23,7 @@
#include <QDebug>

Stageprofi::Stageprofi(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine)
: DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_running(false)
{
}
@@ -21,7 +21,7 @@
#include "vinceusbdmx512.h"

VinceUSBDMX512::VinceUSBDMX512(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine)
: DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
{
// TODO: Check if DMX IN is available
}

0 comments on commit fae57a2

Please sign in to comment.