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 <QtNetwork>
|
||||
#include <QNetworkReply>
|
||||
#include <QTime>
|
||||
|
||||
//#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <set>
|
||||
@ -27,14 +25,7 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb(const std::string& output, bool switchOffOnBl
|
||||
udpSocket = new QUdpSocket(this);
|
||||
udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
|
||||
|
||||
if (!udpSocket->joinMulticastGroup(groupAddress))
|
||||
{
|
||||
joinedMulticastgroup = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
joinedMulticastgroup = true;
|
||||
}
|
||||
joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress);
|
||||
}
|
||||
|
||||
int LedDeviceAtmoOrb::write(const std::vector<ColorRgb> & ledValues) {
|
||||
@ -113,8 +104,6 @@ void LedDeviceAtmoOrb::sendCommand(const QByteArray & bytes) {
|
||||
}
|
||||
|
||||
int LedDeviceAtmoOrb::switchOff() {
|
||||
|
||||
// Default send color
|
||||
for (unsigned int i = 0; i < orbIds.size(); i++) {
|
||||
QByteArray bytes;
|
||||
bytes.resize(5 + numLeds * 3);
|
||||
@ -139,9 +128,6 @@ int LedDeviceAtmoOrb::switchOff() {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void LedDeviceAtmoOrb::switchOn(unsigned int nLights) {
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
LedDeviceAtmoOrb::~LedDeviceAtmoOrb() {
|
||||
delete manager;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <QString>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QHostAddress>
|
||||
#include <QTime>
|
||||
|
||||
// Leddevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
@ -41,9 +40,6 @@ public:
|
||||
int lastGreen;
|
||||
int lastBlue;
|
||||
|
||||
// Last command sent timer
|
||||
QTime timer;
|
||||
|
||||
// Multicast status
|
||||
bool joinedMulticastgroup;
|
||||
|
||||
@ -60,7 +56,7 @@ public:
|
||||
///
|
||||
/// @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 =
|
||||
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 switchOff();
|
||||
private:
|
||||
/// Array to save the lamps.
|
||||
std::vector<AtmoOrbLight> lights;
|
||||
|
||||
/// QNetworkAccessManager object for sending requests.
|
||||
QNetworkAccessManager* manager;
|
||||
|
||||
/// String containing multicast group IP address
|
||||
QString multicastGroup;
|
||||
|
||||
/// Switch off when detecting black
|
||||
bool switchOffOnBlack;
|
||||
|
||||
/// Transition time between colors (not implemented)
|
||||
int transitiontime;
|
||||
|
||||
/// Multicast port to send data to
|
||||
int multiCastGroupPort;
|
||||
|
||||
/// Number of leds in Orb, used to determine buffer size
|
||||
int numLeds;
|
||||
|
||||
/// QHostAddress object of multicast group IP address
|
||||
QHostAddress groupAddress;
|
||||
|
||||
/// QUdpSocket object used to send data over
|
||||
QUdpSocket *udpSocket;
|
||||
|
||||
/// Array of the light ids.
|
||||
/// Array of the orb ids.
|
||||
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);
|
||||
|
||||
// Send color command
|
||||
///
|
||||
/// Send Orb command
|
||||
///
|
||||
/// @param bytes the byte array containing command to send over multicast
|
||||
///
|
||||
void sendCommand(const QByteArray & bytes);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user