Added skeleton for effect engine development

Former-commit-id: e1fb69fd4de4b8968075660e3ba7f7add021c152
This commit is contained in:
johan
2013-11-24 16:10:48 +01:00
parent 333cecdca8
commit 5454ddb375
19 changed files with 304 additions and 12 deletions

View File

@@ -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()
{

View File

@@ -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
///

View File

@@ -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();

View File

@@ -6,6 +6,7 @@ target_link_libraries(hyperiond
bootsequence
hyperion
xbmcvideochecker
effectengine
jsonserver
protoserver
boblightserver)

View File

@@ -26,6 +26,9 @@
// XBMC Video checker includes
#include <xbmcvideochecker/XBMCVideoChecker.h>
// Effect engine includes
#include <effectengine/EffectEngine.h>
// JsonServer includes
#include <jsonserver/JsonServer.h>
@@ -150,6 +153,13 @@ int main(int argc, char** argv)
}
#endif
// Create the effect engine
EffectEngine * effectEngine = nullptr;
if (true)
{
effectEngine = new EffectEngine(&hyperion);
}
// Create Json server if configuration is present
JsonServer * jsonServer = nullptr;
if (config.isMember("jsonServer"))
@@ -187,8 +197,10 @@ int main(int argc, char** argv)
delete dispmanx;
#endif
delete xbmcVideoChecker;
delete effectEngine;
delete jsonServer;
delete protoServer;
delete boblightServer;
// leave application
return rc;