From 3dae8d069c6635f67172a0ef28d2ff872ef8d88f Mon Sep 17 00:00:00 2001 From: redpanther Date: Sat, 12 Mar 2016 19:21:47 +0100 Subject: [PATCH] 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 --- src/hyperiond/hyperiond.cpp | 57 +++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 2f59c5c9..7f658e9d 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -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