fix bootsequence.

if boot duration not 0 then boot prio is set to 0 to avoid start of grabber overrules boot efx
cleanup bootseq code


Former-commit-id: 85c9f099bd9a2e8d695117a24164d8ce81ad2a36
This commit is contained in:
redpanther 2016-03-12 19:21:47 +01:00
parent e9e43e2ba0
commit 3dae8d069c
1 changed files with 26 additions and 31 deletions

View File

@ -127,47 +127,42 @@ int main(int argc, char** argv)
// Get the parameters for the bootsequence
const std::string effectName = effectConfig["effect"].asString();
const unsigned duration_ms = effectConfig["duration_ms"].asUInt();
const int priority = effectConfig.get("priority",990).asInt();
const int priority = (duration_ms != 0) ? 0 : effectConfig.get("priority",990).asInt();
const int bootcolor_priority = (priority > 990) ? priority+1 : 990;
// clear the leds
ColorRgb boot_color = ColorRgb::BLACK;
hyperion.setColor(bootcolor_priority, boot_color, 0, false);
// start boot effect
if ( ! effectName.empty() )
{
int result;
std::cout << "Boot sequence '" << effectName << "' ";
if (effectConfig.isMember("args"))
{
std::cout << " (with user defined arguments) ";
const Json::Value effectConfigArgs = effectConfig["args"];
result = hyperion.setEffect(effectName, effectConfigArgs, priority, duration_ms);
}
else
{
result = hyperion.setEffect(effectName, priority, duration_ms);
}
std::cout << ((result == 0) ? "started" : "failed") << std::endl;
}
// static color
if ( ! effectConfig["color"].isNull() && effectConfig["color"].isArray() && effectConfig["color"].size() == 3 )
{
ColorRgb boot_color = {
boot_color = {
(uint8_t)effectConfig["color"][0].asUInt(),
(uint8_t)effectConfig["color"][1].asUInt(),
(uint8_t)effectConfig["color"][2].asUInt()
};
hyperion.setColor(bootcolor_priority, boot_color, 0, false);
}
else
{
hyperion.setColor(bootcolor_priority, ColorRgb::BLACK, duration_ms, false);
}
if (effectConfig.isMember("args"))
{
const Json::Value effectConfigArgs = effectConfig["args"];
if (hyperion.setEffect(effectName, effectConfigArgs, priority, duration_ms) == 0)
{
std::cout << "Boot sequence(" << effectName << ") with user-defined arguments created and started" << std::endl;
}
else
{
std::cout << "Failed to start boot sequence: " << effectName << " with user-defined arguments" << std::endl;
}
}
else
{
if (hyperion.setEffect(effectName, priority, duration_ms) == 0)
{
std::cout << "Boot sequence(" << effectName << ") created and started" << std::endl;
}
else
{
std::cout << "Failed to start boot sequence: " << effectName << std::endl;
}
}
hyperion.setColor(bootcolor_priority, boot_color, 0, false);
}
// create XBMC video checker if the configuration is present