mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Added skeleton for effect engine development
Former-commit-id: e1fb69fd4de4b8968075660e3ba7f7add021c152
This commit is contained in:
@@ -102,6 +102,27 @@ void JsonConnection::setImage(QImage image, int priority, int duration)
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setEffect(const std::string &effectName, int priority, int duration)
|
||||
{
|
||||
std::cout << "Start effect " << effectName << std::endl;
|
||||
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "effect";
|
||||
command["priority"] = priority;
|
||||
Json::Value & effect = command["effect"];
|
||||
effect["name"] = effectName;
|
||||
if (duration > 0)
|
||||
{
|
||||
command["duration"] = duration;
|
||||
}
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
QString JsonConnection::getServerInfo()
|
||||
{
|
||||
|
@@ -52,6 +52,15 @@ public:
|
||||
///
|
||||
void setImage(QImage image, int priority, int duration);
|
||||
|
||||
///
|
||||
/// Start the given effect
|
||||
///
|
||||
/// @param effect The name of the effect
|
||||
/// @param priority The priority
|
||||
/// @param duration The duration in milliseconds
|
||||
///
|
||||
void setEffect(const std::string & effectName, int priority, int duration);
|
||||
|
||||
///
|
||||
/// Retrieve a list of all occupied priority channels
|
||||
///
|
||||
|
@@ -42,6 +42,7 @@ int main(int argc, char * argv[])
|
||||
IntParameter & argDuration = parameters.add<IntParameter> ('d', "duration" , "Specify how long the leds should be switched on in millseconds [default: infinity]");
|
||||
ColorParameter & argColor = parameters.add<ColorParameter> ('c', "color" , "Set all leds to a constant color (either RRGGBB hex value or a color name)");
|
||||
ImageParameter & argImage = parameters.add<ImageParameter> ('i', "image" , "Set the leds to the colors according to the given image file");
|
||||
StringParameter & argEffect = parameters.add<StringParameter> ('e', "effect" , "Enable the effect with the given name");
|
||||
SwitchParameter<> & argServerInfo = parameters.add<SwitchParameter<> >('l', "list" , "List server info");
|
||||
SwitchParameter<> & argClear = parameters.add<SwitchParameter<> >('x', "clear" , "Clear data for the priority channel provided by the -p option");
|
||||
SwitchParameter<> & argClearAll = parameters.add<SwitchParameter<> >(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
@@ -73,12 +74,13 @@ int main(int argc, char * argv[])
|
||||
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
||||
|
||||
// check that exactly one command was given
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform});
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform});
|
||||
if (commandCount != 1)
|
||||
{
|
||||
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
||||
std::cerr << " " << argColor.usageLine() << std::endl;
|
||||
std::cerr << " " << argImage.usageLine() << std::endl;
|
||||
std::cerr << " " << argEffect.usageLine() << std::endl;
|
||||
std::cerr << " " << argServerInfo.usageLine() << std::endl;
|
||||
std::cerr << " " << argClear.usageLine() << std::endl;
|
||||
std::cerr << " " << argClearAll.usageLine() << std::endl;
|
||||
@@ -104,6 +106,10 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
connection.setImage(argImage.getValue(), argPriority.getValue(), argDuration.getValue());
|
||||
}
|
||||
else if (argEffect.isSet())
|
||||
{
|
||||
connection.setEffect(argEffect.getValue(), argPriority.getValue(), argDuration.getValue());
|
||||
}
|
||||
else if (argServerInfo.isSet())
|
||||
{
|
||||
QString info = connection.getServerInfo();
|
||||
|
Reference in New Issue
Block a user