Skip to content

Commit

Permalink
plugins/dmxusb: allow DMXUSBWidget subclasses to request a preferred …
Browse files Browse the repository at this point in the history
…output frequency

This basically reverts Open DMX to the crappy 30Hz frequency
  • Loading branch information
mcallegari committed Dec 7, 2018
1 parent 93cda87 commit fae57a2
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
8 changes: 3 additions & 5 deletions plugins/dmxusb/src/dmxusbwidget.cpp
Expand Up @@ -31,9 +31,7 @@
#include "stageprofi.h" #include "stageprofi.h"
#include "vinceusbdmx512.h" #include "vinceusbdmx512.h"


#define DEFAULT_OUTPUT_FREQUENCY 44 // 44 Hertz, according to the DMX specs DMXUSBWidget::DMXUSBWidget(DMXInterface *interface, quint32 outputLine, int frequency)

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


setOutputsNumber(1); setOutputsNumber(1);
setInputsNumber(0); setInputsNumber(0);
Expand Down Expand Up @@ -397,7 +395,7 @@ void DMXUSBWidget::setOutputFrequency(int frequency)
{ {
m_frequency = frequency; m_frequency = frequency;
// One "official" DMX frame can take (1s/44Hz) = 23ms // 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);
} }


/******************************************************************** /********************************************************************
Expand Down
4 changes: 3 additions & 1 deletion plugins/dmxusb/src/dmxusbwidget.h
Expand Up @@ -33,6 +33,8 @@
#include "qtserial-interface.h" #include "qtserial-interface.h"
#endif #endif


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

typedef struct typedef struct
{ {
/** The device line type (DMX, MIDI, etc) */ /** The device line type (DMX, MIDI, etc) */
Expand All @@ -57,7 +59,7 @@ class DMXUSBWidget
* @param interface The widget's DMXInterface instance * @param interface The widget's DMXInterface instance
* @param outputLine the specific output line this widget is going to control * @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(); virtual ~DMXUSBWidget();


Expand Down
5 changes: 3 additions & 2 deletions plugins/dmxusb/src/enttecdmxusbopen.cpp
Expand Up @@ -29,6 +29,7 @@
#define DMX_MAB 16 #define DMX_MAB 16
#define DMX_BREAK 110 #define DMX_BREAK 110
#define DMX_CHANNELS 512 #define DMX_CHANNELS 512
#define DEFAULT_OPEN_DMX_FREQUENCY 30 // crap
#define SETTINGS_CHANNELS "enttecdmxusbopen/channels" #define SETTINGS_CHANNELS "enttecdmxusbopen/channels"


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


EnttecDMXUSBPro::EnttecDMXUSBPro(DMXInterface *interface, quint32 outputLine, quint32 inputLine) EnttecDMXUSBPro::EnttecDMXUSBPro(DMXInterface *interface, quint32 outputLine, quint32 inputLine)
: QThread(NULL) : QThread(NULL)
, DMXUSBWidget(interface, outputLine) , DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_dmxKingMode(false) , m_dmxKingMode(false)
, m_inputThread(NULL) , m_inputThread(NULL)
, m_outputRunning(false) , m_outputRunning(false)
Expand Down
2 changes: 1 addition & 1 deletion plugins/dmxusb/src/euroliteusbdmxpro.cpp
Expand Up @@ -23,7 +23,7 @@
#include <QDir> #include <QDir>


EuroliteUSBDMXPro::EuroliteUSBDMXPro(DMXInterface *interface, quint32 outputLine) EuroliteUSBDMXPro::EuroliteUSBDMXPro(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine) : DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_running(false) , m_running(false)
{ {
} }
Expand Down
2 changes: 1 addition & 1 deletion plugins/dmxusb/src/nanodmx.cpp
Expand Up @@ -23,7 +23,7 @@
#include <QDir> #include <QDir>


NanoDMX::NanoDMX(DMXInterface *interface, quint32 outputLine) NanoDMX::NanoDMX(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine) : DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_running(false) , m_running(false)
{ {
} }
Expand Down
2 changes: 1 addition & 1 deletion plugins/dmxusb/src/stageprofi.cpp
Expand Up @@ -23,7 +23,7 @@
#include <QDebug> #include <QDebug>


Stageprofi::Stageprofi(DMXInterface *interface, quint32 outputLine) Stageprofi::Stageprofi(DMXInterface *interface, quint32 outputLine)
: DMXUSBWidget(interface, outputLine) : DMXUSBWidget(interface, outputLine, DEFAULT_OUTPUT_FREQUENCY)
, m_running(false) , m_running(false)
{ {
} }
Expand Down
2 changes: 1 addition & 1 deletion plugins/dmxusb/src/vinceusbdmx512.cpp
Expand Up @@ -21,7 +21,7 @@
#include "vinceusbdmx512.h" #include "vinceusbdmx512.h"


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

0 comments on commit fae57a2

Please sign in to comment.