mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
UI and Web updates (#1421)
* Stop Web-Capture when priority changes * Remote control UI: Treat duration=0 as endless * Stop Web-Capture on non-Image events changes * LED Matrix Layout - Support vertical cabling direction * Additional Yeelight models * Treat http headers case insensitive * Update change log * Treat http headers case insensitive (consider Qt version) * API - Consider provided format when setImage * UI - Support Boblight configuration per LED instance * Support multiple Boblight clients with different priorities * Update changelog * Simplify isGUI rules allowing for QT only builds * Sysinfo: Fix indents * LED-Devices: Show warning, if get properties failed * Qt-Grabber: Fixed position handling of multiple monitors * LED layout: Remove indention limitations * Yeelight: Test YLTD003 * hyperion-remote: Provide image filename to muxer/UI * Refactor PriorityMuxer and related * Temp: Build under Windows 2019 * Yeelight: Remove YLTD003 as it is not working without additional changes * Test Windows-latest with out removing redistributables/new MSVC * correct workflows * correct CI script * Build Windows with Qt 5.15.2 * Priority Muxer: Updates after testing * Fix Typo * Update BGHandler * QTGrabber - Reactivate windows code to avoid cursor issues * Emit prioritiesChanged when autoselect was changed by user Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -55,11 +55,7 @@ BoblightClientConnection::BoblightClientConnection(Hyperion* hyperion, QTcpSocke
|
||||
|
||||
BoblightClientConnection::~BoblightClientConnection()
|
||||
{
|
||||
// clear the current channel
|
||||
if (_priority != 0 && _priority >= BOBLIGHT_MIN_PRIORITY && _priority <= BOBLIGHT_MAX_PRIORITY)
|
||||
_hyperion->clear(_priority);
|
||||
|
||||
delete _socket;
|
||||
_socket->deleteLater();
|
||||
}
|
||||
|
||||
void BoblightClientConnection::readData()
|
||||
@@ -117,9 +113,10 @@ QString BoblightClientConnection::readMessage(const char* data, const size_t siz
|
||||
|
||||
void BoblightClientConnection::socketClosed()
|
||||
{
|
||||
// clear the current channel
|
||||
if (_priority >= BOBLIGHT_MIN_PRIORITY && _priority <= BOBLIGHT_MAX_PRIORITY)
|
||||
{
|
||||
_hyperion->clear(_priority);
|
||||
}
|
||||
|
||||
emit connectionClosed(this);
|
||||
}
|
||||
@@ -205,40 +202,58 @@ void BoblightClientConnection::handleMessage(const QString& message)
|
||||
{
|
||||
bool rc;
|
||||
const int prio = static_cast<int>(parseUInt(messageParts[2], &rc));
|
||||
if (rc && prio != _priority)
|
||||
if (rc)
|
||||
{
|
||||
if (_priority != 0 && _hyperion->getPriorityInfo(_priority).componentId == hyperion::COMP_BOBLIGHTSERVER)
|
||||
_hyperion->clear(_priority);
|
||||
int currentPriority = _hyperion->getCurrentPriority();
|
||||
|
||||
if (prio < BOBLIGHT_MIN_PRIORITY || prio > BOBLIGHT_MAX_PRIORITY)
|
||||
if (prio == currentPriority)
|
||||
{
|
||||
_priority = BOBLIGHT_DEFAULT_PRIORITY;
|
||||
while (_hyperion->getActivePriorities().contains(_priority))
|
||||
{
|
||||
_priority += 1;
|
||||
}
|
||||
|
||||
// warn against invalid priority
|
||||
Warning(_log, "The priority %i is not in the priority range of [%d-%d]. Priority %i is used instead.",
|
||||
prio, BOBLIGHT_MIN_PRIORITY, BOBLIGHT_MAX_PRIORITY, _priority);
|
||||
// register new priority (previously modified)
|
||||
_hyperion->registerInput(_priority, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
|
||||
Error(_log, "The priority %i is already in use onther component of type [%s]", prio, componentToString(_hyperion->getPriorityInfo(currentPriority).componentId));
|
||||
_socket->close();
|
||||
}
|
||||
else
|
||||
{
|
||||
// register new priority
|
||||
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
|
||||
_priority = prio;
|
||||
}
|
||||
if (prio < BOBLIGHT_MIN_PRIORITY || prio > BOBLIGHT_MAX_PRIORITY)
|
||||
{
|
||||
_priority = BOBLIGHT_DEFAULT_PRIORITY;
|
||||
while (_hyperion->getActivePriorities().contains(_priority))
|
||||
{
|
||||
_priority += 1;
|
||||
}
|
||||
|
||||
return;
|
||||
// warn against invalid priority
|
||||
Warning(_log, "The priority %i is not in the priority range of [%d-%d]. Priority %i is used instead.",
|
||||
prio, BOBLIGHT_MIN_PRIORITY, BOBLIGHT_MAX_PRIORITY, _priority);
|
||||
// register new priority (previously modified)
|
||||
_hyperion->registerInput(_priority, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_clientAddress));
|
||||
}
|
||||
else
|
||||
{
|
||||
// register new priority
|
||||
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_clientAddress));
|
||||
_priority = prio;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (messageParts[0] == "sync")
|
||||
{
|
||||
if (_priority >= BOBLIGHT_MIN_PRIORITY && _priority <= BOBLIGHT_MAX_PRIORITY)
|
||||
_hyperion->setInput(_priority, _ledColors); // send current color values to hyperion
|
||||
{
|
||||
int currentPriority = _hyperion->getCurrentPriority();
|
||||
if ( _priority != currentPriority)
|
||||
{
|
||||
// register this connection's priority
|
||||
_hyperion->registerInput(_priority, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_clientAddress));
|
||||
}
|
||||
|
||||
if (_priority >= BOBLIGHT_MIN_PRIORITY && _priority <= BOBLIGHT_MAX_PRIORITY)
|
||||
{
|
||||
_hyperion->setInput(_priority, _ledColors); // send current color values to hyperion
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -387,6 +402,14 @@ uint8_t BoblightClientConnection::parseByte(const QString& s, bool *ok) const
|
||||
return static_cast<uint8_t>(qBound(LO, int(HI * d), HI)); // qBound args are in order min, value, max; see: https://doc.qt.io/qt-5/qtglobal.html#qBound
|
||||
}
|
||||
|
||||
void BoblightClientConnection::sendMessage(const QByteArray &message)
|
||||
{
|
||||
if (_socket->isOpen())
|
||||
{
|
||||
_socket->write(message);
|
||||
}
|
||||
}
|
||||
|
||||
void BoblightClientConnection::sendLightMessage()
|
||||
{
|
||||
char buffer[256];
|
||||
|
@@ -36,6 +36,13 @@ public:
|
||||
///
|
||||
~BoblightClientConnection() override;
|
||||
|
||||
///
|
||||
/// Get the Boblight client's IP-address
|
||||
///
|
||||
/// @returns IP-address as QString
|
||||
///
|
||||
QString getClientAddress() { return _clientAddress; }
|
||||
|
||||
signals:
|
||||
///
|
||||
/// Signal which is emitted when the connection is being closed
|
||||
@@ -67,7 +74,7 @@ private:
|
||||
///
|
||||
/// @param message The boblight message to send
|
||||
///
|
||||
void sendMessage(const QByteArray &message) { _socket->write(message); };
|
||||
void sendMessage(const QByteArray &message);
|
||||
|
||||
///
|
||||
/// Send a lights message the to connected client
|
||||
|
@@ -22,9 +22,12 @@ BoblightServer::BoblightServer(Hyperion* hyperion,const QJsonDocument& config)
|
||||
, _server(new QTcpServer(this))
|
||||
, _openConnections()
|
||||
, _priority(0)
|
||||
, _log(Logger::getInstance("BOBLIGHT"))
|
||||
, _log(nullptr)
|
||||
, _port(0)
|
||||
{
|
||||
QString subComponent = _hyperion->property("instance").toString();
|
||||
_log= Logger::getInstance("BOBLIGHT", subComponent);
|
||||
|
||||
Debug(_log, "Instance created");
|
||||
|
||||
// listen for component change
|
||||
@@ -49,7 +52,7 @@ void BoblightServer::start()
|
||||
if (NetUtils::portAvailable(_port, _log))
|
||||
_server->listen(QHostAddress::Any, _port);
|
||||
|
||||
Info(_log, "Started on port %d", _port);
|
||||
Info(_log, "Started on port: %d", _port);
|
||||
|
||||
_hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
|
||||
}
|
||||
@@ -92,11 +95,9 @@ uint16_t BoblightServer::getPort() const
|
||||
void BoblightServer::newConnection()
|
||||
{
|
||||
QTcpSocket * socket = _server->nextPendingConnection();
|
||||
|
||||
if (socket != nullptr)
|
||||
{
|
||||
Info(_log, "new connection");
|
||||
_hyperion->registerInput(_priority, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(socket->peerAddress().toString()));
|
||||
Info(_log, "New connection from %s ", QSTRING_CSTR(QString("Boblight@%1").arg(socket->peerAddress().toString())));
|
||||
BoblightClientConnection * connection = new BoblightClientConnection(_hyperion, socket, _priority);
|
||||
_openConnections.insert(connection);
|
||||
|
||||
@@ -107,7 +108,7 @@ void BoblightServer::newConnection()
|
||||
|
||||
void BoblightServer::closedConnection(BoblightClientConnection *connection)
|
||||
{
|
||||
Debug(_log, "connection closed");
|
||||
Debug(_log, "Connection closed for %s", QSTRING_CSTR(QString("Boblight@%1").arg(connection->getClientAddress())));
|
||||
_openConnections.remove(connection);
|
||||
|
||||
// schedule to delete the connection object
|
||||
|
Reference in New Issue
Block a user