Hyperion Light 2 (#1428)

* Hyperion Light - Have EffectEngine as component

* Hyperion light - Build switches for LED Devices (Serial, Network)

* Fix file uri generation

* Fix missing guard for Windows

* Fix file uri generation

* Update jsonschema and checkschema

* Allow to provide cmake build args to docker build
This commit is contained in:
LordGrey
2022-02-11 20:36:15 +01:00
committed by GitHub
parent 9e4b58d5c6
commit 5078688dc8
47 changed files with 1920 additions and 938 deletions

View File

@@ -30,7 +30,6 @@ add_executable(${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME}
effectengine
commandline
hyperion-utils
ssdp
@@ -45,6 +44,10 @@ if (ENABLE_AMLOGIC)
)
endif()
if(ENABLE_EFFECTENGINE)
target_link_libraries(${PROJECT_NAME} effectengine)
endif()
if(APPLE)
install ( TARGETS ${PROJECT_NAME} DESTINATION "." COMPONENT "hyperion_remote" )
elseif(NOT WIN32)

View File

@@ -12,6 +12,8 @@
#include <QHostInfo>
#include <QUrl>
#include "HyperionConfig.h"
// hyperion-remote includes
#include "JsonConnection.h"
@@ -106,6 +108,7 @@ void JsonConnection::setImage(QImage &image, int priority, int duration)
parseReply(reply);
}
#if defined(ENABLE_EFFECTENGINE)
void JsonConnection::setEffect(const QString &effectName, const QString & effectArgs, int priority, int duration)
{
Debug(_log, "Start effect: %s", QSTRING_CSTR(effectName));
@@ -185,6 +188,7 @@ void JsonConnection::deleteEffect(const QString &effectName)
// parse reply message
parseReply(reply);
}
#endif
QString JsonConnection::getServerInfoString()
{

View File

@@ -49,6 +49,7 @@ public:
///
void setImage(QImage &image, int priority, int duration);
#if defined(ENABLE_EFFECTENGINE)
///
/// Start the given effect
///
@@ -74,6 +75,7 @@ public:
/// @param effectName The name of the effect
///
void deleteEffect(const QString &effectName);
#endif
///
/// Retrieve entire serverinfo as String

View File

@@ -100,11 +100,13 @@ int main(int argc, char * argv[])
IntOption & argDuration = parser.add<IntOption> ('d', "duration" , "Specify how long the LEDs should be switched on in milliseconds [default: infinity]");
ColorsOption & argColor = parser.add<ColorsOption> ('c', "color" , "Set all LEDs to a constant color (either RRGGBB hex getColors or a color name. The color may be repeated multiple time like: RRGGBBRRGGBB)");
ImageOption & argImage = parser.add<ImageOption> ('i', "image" , "Set the LEDs to the colors according to the given image file");
#if defined(ENABLE_EFFECTENGINE)
Option & argEffect = parser.add<Option> ('e', "effect" , "Enable the effect with the given name");
Option & argEffectFile = parser.add<Option> (0x0, "effectFile" , "Arguments to use in combination with --createEffect");
Option & argEffectArgs = parser.add<Option> (0x0, "effectArgs" , "Arguments to use in combination with the specified effect. Should be a JSON object string.", "");
Option & argCreateEffect = parser.add<Option> (0x0, "createEffect" , "Write a new JSON Effect configuration file.\nFirst parameter = Effect name.\nSecond parameter = Effect file (--effectFile).\nLast parameter = Effect arguments (--effectArgs.)", "");
Option & argDeleteEffect = parser.add<Option> (0x0, "deleteEffect" , "Delete a custom created JSON Effect configuration file.");
#endif
BooleanOption & argServerInfo = parser.add<BooleanOption>('l', "list" , "List server info and active effects with priority and duration");
BooleanOption & argSysInfo = parser.add<BooleanOption>('s', "sysinfo" , "show system info");
BooleanOption & argClear = parser.add<BooleanOption>('x', "clear" , "Clear data for the priority channel provided by the -p option");
@@ -160,7 +162,10 @@ int main(int argc, char * argv[])
|| parser.isSet(argBacklightThreshold) || parser.isSet(argBacklightColored);
// check that exactly one command was given
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage),
#if defined(ENABLE_EFFECTENGINE)
parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
#endif
parser.isSet(argServerInfo), parser.isSet(argSysInfo),parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argOff), parser.isSet(argOn), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
parser.isSet(argMapping),parser.isSet(argVideoMode) });
@@ -169,9 +174,11 @@ int main(int argc, char * argv[])
qWarning() << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:";
showHelp(argColor);
showHelp(argImage);
#if defined(ENABLE_EFFECTENGINE)
showHelp(argEffect);
showHelp(argCreateEffect);
showHelp(argDeleteEffect);
#endif
showHelp(argServerInfo);
showHelp(argSysInfo);
showHelp(argClear);
@@ -247,6 +254,7 @@ int main(int argc, char * argv[])
{
connection.setImage(argImage.getImage(parser), argPriority.getInt(parser), argDuration.getInt(parser));
}
#if defined(ENABLE_EFFECTENGINE)
else if (parser.isSet(argEffect))
{
connection.setEffect(argEffect.value(parser), argEffectArgs.value(parser), argPriority.getInt(parser), argDuration.getInt(parser));
@@ -259,6 +267,7 @@ int main(int argc, char * argv[])
{
connection.deleteEffect(argDeleteEffect.value(parser));
}
#endif
else if (parser.isSet(argServerInfo))
{
std::cout << "Server info:\n" << connection.getServerInfoString().toStdString() << std::endl;

View File

@@ -4,13 +4,15 @@ else()
project(hyperiond)
endif()
if (NOT CMAKE_VERSION VERSION_LESS "3.12")
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
include_directories(${Python3_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS}/..)
else()
find_package (PythonLibs ${PYTHON_VERSION_STRING} EXACT) # Maps PythonLibs to the PythonInterp version of the main cmake
include_directories(${PYTHON_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}/..)
endif()
if(ENABLE_EFFECTENGINE)
if (NOT CMAKE_VERSION VERSION_LESS "3.12")
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
include_directories(${Python3_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS}/..)
else()
find_package (PythonLibs ${PYTHON_VERSION_STRING} EXACT) # Maps PythonLibs to the PythonInterp version of the main cmake
include_directories(${PYTHON_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}/..)
endif()
endif ()
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Gui Widgets REQUIRED)
@@ -47,12 +49,10 @@ endif(WIN32)
target_link_libraries(${PROJECT_NAME}
commandline
hyperion
effectengine
jsonserver
webserver
ssdp
database
python
resources
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
@@ -60,12 +60,15 @@ target_link_libraries(${PROJECT_NAME}
Qt${QT_VERSION_MAJOR}::Widgets
)
if (NOT CMAKE_VERSION VERSION_LESS "3.12")
target_link_libraries( ${PROJECT_NAME} ${Python3_LIBRARIES} )
else()
target_link_libraries( ${PROJECT_NAME} ${PYTHON_LIBRARIES} )
endif()
if(ENABLE_EFFECTENGINE)
target_link_libraries(${PROJECT_NAME} effectengine python)
if (NOT CMAKE_VERSION VERSION_LESS "3.12")
target_link_libraries( ${PROJECT_NAME} ${Python3_LIBRARIES} )
else()
target_link_libraries( ${PROJECT_NAME} ${PYTHON_LIBRARIES} )
endif()
endif ()
if(ENABLE_FLATBUF_SERVER)
target_link_libraries(${PROJECT_NAME} flatbufserver)

View File

@@ -53,11 +53,13 @@
// NetOrigin checks
#include <utils/NetOrigin.h>
#if defined(ENABLE_EFFECTENGINE)
// Init Python
#include <python/PythonInit.h>
// EffectFileHandler
#include <effectengine/EffectFileHandler.h>
#endif
#ifdef ENABLE_CEC
#include <cec/CECHandler.h>
@@ -73,7 +75,9 @@ HyperionDaemon::HyperionDaemon(const QString& rootPath, QObject* parent, bool lo
, _bonjourBrowserWrapper(new BonjourBrowserWrapper())
#endif
, _netOrigin(new NetOrigin(this))
#if defined(ENABLE_EFFECTENGINE)
, _pyInit(new PythonInit())
#endif
, _webserver(nullptr)
, _sslWebserver(nullptr)
, _jsonServer(nullptr)
@@ -113,9 +117,11 @@ HyperionDaemon::HyperionDaemon(const QString& rootPath, QObject* parent, bool lo
createCecHandler();
#if defined(ENABLE_EFFECTENGINE)
// init EffectFileHandler
EffectFileHandler* efh = new EffectFileHandler(rootPath, getSetting(settings::EFFECTS), this);
connect(this, &HyperionDaemon::settingsChanged, efh, &EffectFileHandler::handleSettingsUpdate);
#endif
// connect and apply settings for AuthManager
connect(this, &HyperionDaemon::settingsChanged, _authManager, &AuthManager::handleSettingsUpdate);
@@ -160,7 +166,9 @@ HyperionDaemon::HyperionDaemon(const QString& rootPath, QObject* parent, bool lo
HyperionDaemon::~HyperionDaemon()
{
delete _settingsManager;
#if defined(ENABLE_EFFECTENGINE)
delete _pyInit;
#endif
}
void HyperionDaemon::setVideoMode(VideoMode mode)

View File

@@ -73,7 +73,9 @@ class JsonServer;
class BonjourBrowserWrapper;
class WebServer;
class SettingsManager;
#if defined(ENABLE_EFFECTENGINE)
class PythonInit;
#endif
class SSDPHandler;
class FlatBufferServer;
class ProtoServer;
@@ -168,7 +170,9 @@ private:
AuthManager* _authManager;
BonjourBrowserWrapper* _bonjourBrowserWrapper;
NetOrigin* _netOrigin;
#if defined(ENABLE_EFFECTENGINE)
PythonInit* _pyInit;
#endif
WebServer* _webserver;
WebServer* _sslWebserver;
JsonServer* _jsonServer;

View File

@@ -192,7 +192,9 @@ int main(int argc, char** argv)
#endif
parser.add<BooleanOption> (0x0, "desktop", "Show systray on desktop");
parser.add<BooleanOption> (0x0, "service", "Force hyperion to start as console service");
#if defined(ENABLE_EFFECTENGINE)
Option & exportEfxOption = parser.add<Option> (0x0, "export-effects", "Export effects to given path");
#endif
/* Internal options, invisible to help */
BooleanOption & waitOption = parser.addHidden<BooleanOption> (0x0, "wait-hyperion", "Do not exit if other Hyperion instances are running, wait them to finish");
@@ -275,6 +277,7 @@ int main(int argc, char** argv)
return 0;
}
#if defined(ENABLE_EFFECTENGINE)
if (parser.isSet(exportEfxOption))
{
Q_INIT_RESOURCE(EffectEngine);
@@ -311,6 +314,7 @@ int main(int argc, char** argv)
Error(log, "Can not export to %s",exportEfxOption.getCString(parser));
return 1;
}
#endif
int rc = 1;
bool readonlyMode = false;

View File

@@ -15,8 +15,10 @@
#include <utils/ColorRgb.h>
#include <utils/Process.h>
#if defined(ENABLE_EFFECTENGINE)
#include <effectengine/EffectDefinition.h>
#include <effectengine/Effect.h>
#endif
#include <webserver/WebServer.h>
#include <hyperion/PriorityMuxer.h>
@@ -91,8 +93,10 @@ void SysTray::createTrayIcon()
clearAction->setIcon(QPixmap(":/clear.svg"));
connect(clearAction, &QAction::triggered, this, &SysTray::clearEfxColor);
const std::list<EffectDefinition> efxs = _hyperion->getEffects();
_trayIconMenu = new QMenu(this);
#if defined(ENABLE_EFFECTENGINE)
const std::list<EffectDefinition> efxs = _hyperion->getEffects();
_trayIconEfxMenu = new QMenu(_trayIconMenu);
_trayIconEfxMenu->setTitle(tr("Effects"));
_trayIconEfxMenu->setIcon(QPixmap(":/effects.svg"));
@@ -122,6 +126,7 @@ void SysTray::createTrayIcon()
_trayIconEfxMenu->addAction(efxAction);
}
}
#endif
#ifdef _WIN32
autorunAction = new QAction(tr("&Disable autostart"), this);
@@ -135,7 +140,9 @@ void SysTray::createTrayIcon()
_trayIconMenu->addAction(settingsAction);
_trayIconMenu->addSeparator();
_trayIconMenu->addAction(colorAction);
#if defined(ENABLE_EFFECTENGINE)
_trayIconMenu->addMenu(_trayIconEfxMenu);
#endif
_trayIconMenu->addAction(clearAction);
_trayIconMenu->addSeparator();
_trayIconMenu->addAction(restartAction);
@@ -175,7 +182,7 @@ void SysTray::setColor(const QColor & color)
{
std::vector<ColorRgb> rgbColor{ ColorRgb{ (uint8_t)color.red(), (uint8_t)color.green(), (uint8_t)color.blue() } };
_hyperion->setColor(PriorityMuxer::FG_PRIORITY,rgbColor, Effect::ENDLESS);
_hyperion->setColor(PriorityMuxer::FG_PRIORITY,rgbColor, PriorityMuxer::ENDLESS);
}
void SysTray::showColorDialog()
@@ -228,11 +235,13 @@ void SysTray::settings() const
#endif
}
#if defined(ENABLE_EFFECTENGINE)
void SysTray::setEffect()
{
QString efxName = qobject_cast<QAction*>(sender())->text();
_hyperion->setEffect(efxName, PriorityMuxer::FG_PRIORITY, Effect::ENDLESS);
_hyperion->setEffect(efxName, PriorityMuxer::FG_PRIORITY, PriorityMuxer::ENDLESS);
}
#endif
void SysTray::clearEfxColor()
{

View File

@@ -25,7 +25,9 @@ public slots:
void setColor(const QColor & color);
void closeEvent(QCloseEvent *event);
void settings() const;
#if defined(ENABLE_EFFECTENGINE)
void setEffect();
#endif
void clearEfxColor();
void setAutorunState();
@@ -66,7 +68,9 @@ private:
QSystemTrayIcon *_trayIcon;
QMenu *_trayIconMenu;
#if defined(ENABLE_EFFECTENGINE)
QMenu *_trayIconEfxMenu;
#endif
QColorDialog _colorDlg;
HyperionDaemon *_hyperiond;
Hyperion *_hyperion;