chealup of udp device. (#153)

left over unneeded spi include
variable cleanup
This commit is contained in:
penfold42 2016-08-06 16:58:41 +10:00 committed by redPanther
parent 817dabae8c
commit d90a36d911
2 changed files with 12 additions and 17 deletions

View File

@ -15,13 +15,13 @@
// Local Hyperion includes // Local Hyperion includes
#include "LedUdpDevice.h" #include "LedUdpDevice.h"
LedUdpDevice::LedUdpDevice(const std::string& outputDevice, const unsigned baudrate, const int latchTime_ns) : LedUdpDevice::LedUdpDevice(const std::string& output, const unsigned baudrate, const int latchTime_ns) :
mDeviceName(outputDevice), _target(output),
mBaudRate_Hz(baudrate), _BaudRate_Hz(baudrate),
mLatchTime_ns(latchTime_ns) _LatchTime_ns(latchTime_ns)
{ {
udpSocket = new QUdpSocket(); udpSocket = new QUdpSocket();
QString str = QString::fromStdString(mDeviceName); QString str = QString::fromStdString(_target);
QStringList _list = str.split(":"); QStringList _list = str.split(":");
if (_list.size() != 2) { if (_list.size() != 2) {
Error( _log, "Error parsing hostname:port"); Error( _log, "Error parsing hostname:port");
@ -56,12 +56,12 @@ int LedUdpDevice::writeBytes(const unsigned size, const uint8_t * data)
qint64 retVal = udpSocket->writeDatagram((const char *)data,size,_address,_port); qint64 retVal = udpSocket->writeDatagram((const char *)data,size,_address,_port);
if (retVal >= 0 && mLatchTime_ns > 0) if (retVal >= 0 && _LatchTime_ns > 0)
{ {
// The 'latch' time for latching the shifted-value into the leds // The 'latch' time for latching the shifted-value into the leds
timespec latchTime; timespec latchTime;
latchTime.tv_sec = 0; latchTime.tv_sec = 0;
latchTime.tv_nsec = mLatchTime_ns; latchTime.tv_nsec = _LatchTime_ns;
// Sleep to latch the leds (only if write succesfull) // Sleep to latch the leds (only if write succesfull)
nanosleep(&latchTime, NULL); nanosleep(&latchTime, NULL);

View File

@ -2,9 +2,6 @@
#include <QUdpSocket> #include <QUdpSocket>
// Linux-SPI includes
#include <linux/spi/spidev.h>
// Hyperion includes // Hyperion includes
#include <leddevice/LedDevice.h> #include <leddevice/LedDevice.h>
#include <utils/Logger.h> #include <utils/Logger.h>
@ -50,15 +47,13 @@ protected:
int writeBytes(const unsigned size, const uint8_t *data); int writeBytes(const unsigned size, const uint8_t *data);
private: private:
/// The name of the output device /// The UDP destination as "host:port"
const std::string mDeviceName; const std::string _target;
/// The used baudrate of the output device /// The used baudrate of the output device for rate limiting
const int mBaudRate_Hz; const int _BaudRate_Hz;
/// The time which the device should be untouched after a write /// The time which the device should be untouched after a write
const int mLatchTime_ns; const int _LatchTime_ns;
/// The File Identifier of the opened output device (or -1 if not opened)
int mFid;
/// ///
QUdpSocket *udpSocket; QUdpSocket *udpSocket;
QHostAddress _address; QHostAddress _address;