mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Added more inline documentation.
Simplified joinedMulticastgroup. Removed non-required functions and includes. Former-commit-id: 829b5c6f89ee1e9a4789dbe18f911b05e3b5d8e1
This commit is contained in:
parent
fdb164da0a
commit
5be072be24
@ -6,9 +6,7 @@
|
|||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
//#include <iostream>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
@ -27,14 +25,7 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb(const std::string& output, bool switchOffOnBl
|
|||||||
udpSocket = new QUdpSocket(this);
|
udpSocket = new QUdpSocket(this);
|
||||||
udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
|
udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
|
||||||
|
|
||||||
if (!udpSocket->joinMulticastGroup(groupAddress))
|
joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress);
|
||||||
{
|
|
||||||
joinedMulticastgroup = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
joinedMulticastgroup = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LedDeviceAtmoOrb::write(const std::vector<ColorRgb> & ledValues) {
|
int LedDeviceAtmoOrb::write(const std::vector<ColorRgb> & ledValues) {
|
||||||
@ -113,8 +104,6 @@ void LedDeviceAtmoOrb::sendCommand(const QByteArray & bytes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int LedDeviceAtmoOrb::switchOff() {
|
int LedDeviceAtmoOrb::switchOff() {
|
||||||
|
|
||||||
// Default send color
|
|
||||||
for (unsigned int i = 0; i < orbIds.size(); i++) {
|
for (unsigned int i = 0; i < orbIds.size(); i++) {
|
||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
bytes.resize(5 + numLeds * 3);
|
bytes.resize(5 + numLeds * 3);
|
||||||
@ -139,9 +128,6 @@ int LedDeviceAtmoOrb::switchOff() {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void LedDeviceAtmoOrb::switchOn(unsigned int nLights) {
|
|
||||||
// Not implemented
|
|
||||||
}
|
|
||||||
|
|
||||||
LedDeviceAtmoOrb::~LedDeviceAtmoOrb() {
|
LedDeviceAtmoOrb::~LedDeviceAtmoOrb() {
|
||||||
delete manager;
|
delete manager;
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include <QTime>
|
|
||||||
|
|
||||||
// Leddevice includes
|
// Leddevice includes
|
||||||
#include <leddevice/LedDevice.h>
|
#include <leddevice/LedDevice.h>
|
||||||
@ -41,9 +40,6 @@ public:
|
|||||||
int lastGreen;
|
int lastGreen;
|
||||||
int lastBlue;
|
int lastBlue;
|
||||||
|
|
||||||
// Last command sent timer
|
|
||||||
QTime timer;
|
|
||||||
|
|
||||||
// Multicast status
|
// Multicast status
|
||||||
bool joinedMulticastgroup;
|
bool joinedMulticastgroup;
|
||||||
|
|
||||||
@ -60,7 +56,7 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param numLeds is the total amount of leds per Orb
|
/// @param numLeds is the total amount of leds per Orb
|
||||||
///
|
///
|
||||||
/// @param orb ids to control
|
/// @param array containing orb ids
|
||||||
///
|
///
|
||||||
LedDeviceAtmoOrb(const std::string& output, bool switchOffOnBlack =
|
LedDeviceAtmoOrb(const std::string& output, bool switchOffOnBlack =
|
||||||
false, int transitiontime = 0, int port = 49692, int numLeds = 24, std::vector<unsigned int> orbIds = std::vector<unsigned int>());
|
false, int transitiontime = 0, int port = 49692, int numLeds = 24, std::vector<unsigned int> orbIds = std::vector<unsigned int>());
|
||||||
@ -79,33 +75,49 @@ public:
|
|||||||
virtual int write(const std::vector<ColorRgb> & ledValues);
|
virtual int write(const std::vector<ColorRgb> & ledValues);
|
||||||
virtual int switchOff();
|
virtual int switchOff();
|
||||||
private:
|
private:
|
||||||
/// Array to save the lamps.
|
|
||||||
std::vector<AtmoOrbLight> lights;
|
|
||||||
|
|
||||||
/// QNetworkAccessManager object for sending requests.
|
/// QNetworkAccessManager object for sending requests.
|
||||||
QNetworkAccessManager* manager;
|
QNetworkAccessManager* manager;
|
||||||
|
|
||||||
|
/// String containing multicast group IP address
|
||||||
QString multicastGroup;
|
QString multicastGroup;
|
||||||
|
|
||||||
|
/// Switch off when detecting black
|
||||||
bool switchOffOnBlack;
|
bool switchOffOnBlack;
|
||||||
|
|
||||||
|
/// Transition time between colors (not implemented)
|
||||||
int transitiontime;
|
int transitiontime;
|
||||||
|
|
||||||
|
/// Multicast port to send data to
|
||||||
int multiCastGroupPort;
|
int multiCastGroupPort;
|
||||||
|
|
||||||
|
/// Number of leds in Orb, used to determine buffer size
|
||||||
int numLeds;
|
int numLeds;
|
||||||
|
|
||||||
|
/// QHostAddress object of multicast group IP address
|
||||||
QHostAddress groupAddress;
|
QHostAddress groupAddress;
|
||||||
|
|
||||||
|
/// QUdpSocket object used to send data over
|
||||||
QUdpSocket *udpSocket;
|
QUdpSocket *udpSocket;
|
||||||
|
|
||||||
/// Array of the light ids.
|
/// Array of the orb ids.
|
||||||
std::vector<unsigned int> orbIds;
|
std::vector<unsigned int> orbIds;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Switches the leds on.
|
/// Set Orbcolor
|
||||||
///
|
///
|
||||||
/// @param nLights the number of lights
|
/// @param orbId the orb id
|
||||||
|
///
|
||||||
|
/// @param color which color to set
|
||||||
|
///
|
||||||
|
///
|
||||||
|
/// @param commandType which type of command to send (off / smoothing / etc..)
|
||||||
///
|
///
|
||||||
void switchOn(unsigned int nLights);
|
|
||||||
|
|
||||||
// Set color
|
|
||||||
void setColor(unsigned int orbId, const ColorRgb& color, int commandType);
|
void setColor(unsigned int orbId, const ColorRgb& color, int commandType);
|
||||||
|
|
||||||
// Send color command
|
///
|
||||||
|
/// Send Orb command
|
||||||
|
///
|
||||||
|
/// @param bytes the byte array containing command to send over multicast
|
||||||
|
///
|
||||||
void sendCommand(const QByteArray & bytes);
|
void sendCommand(const QByteArray & bytes);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user