diff --git a/src/channeloutput/processors/BrightnessOutputProcessor.cpp b/src/channeloutput/processors/BrightnessOutputProcessor.cpp index 4004acf0e..071139d24 100644 --- a/src/channeloutput/processors/BrightnessOutputProcessor.cpp +++ b/src/channeloutput/processors/BrightnessOutputProcessor.cpp @@ -26,6 +26,7 @@ #include "../../log.h" #include "BrightnessOutputProcessor.h" +#include "OutputProcessor.h" BrightnessOutputProcessor::BrightnessOutputProcessor(const Json::Value& config) { description = config["desription"].asString(); @@ -35,33 +36,10 @@ BrightnessOutputProcessor::BrightnessOutputProcessor(const Json::Value& config) brightness = config["brightness"].asInt(); gamma = config["gamma"].asFloat(); - if (config.isMember("model")) { - model = config["model"].asString(); - if (model != "<Use Start Channel>") { - auto m_model = PixelOverlayManager::INSTANCE.getModel(model); - if (!m_model) { - LogErr(VB_CHANNELOUT, "Invalid Pixel Overlay Model: '%s'\n", model.c_str()); - } else { - int m_channel = m_model->getChannelCount(); - LogDebug(VB_CHANNELOUT, "Before Model applied Brightness: %d-%d => Brightness:%d Gamma: %f Model: %s model\n", - start, start + count - 1, - brightness, gamma, model.c_str(),m_channel); - int offset = start; - start = m_model->getStartChannel() + start + 1; - if (count > m_channel) { - count = m_channel - offset; - LogWarn(VB_CHANNELOUT, "Output processor tried to go past end channel of model. Restricting to %d channels\n", count); - } else if (count < m_channel) { - LogInfo(VB_CHANNELOUT, "Output processor tried to use less channels (%d) than overlay model has (%d). This may be intentional\n",count, m_channel); - } - } - } - } else { - model = ""; - } + ProcessModelConfig(config, model, start, count); LogInfo(VB_CHANNELOUT, "Brightness: %d-%d => Brightness:%d Gamma: %f Model: %s\n", - start, start + count - 1, + start + 1, start + count, brightness, gamma, model.c_str()); float bf = brightness; @@ -77,9 +55,6 @@ BrightnessOutputProcessor::BrightnessOutputProcessor(const Json::Value& config) } table[x] = round(f); } - - // channel numbers need to be 0 based - --start; } BrightnessOutputProcessor::~BrightnessOutputProcessor() { diff --git a/src/channeloutput/processors/ColorOrderOutputProcessor.cpp b/src/channeloutput/processors/ColorOrderOutputProcessor.cpp index bf18ae41d..6f751b548 100644 --- a/src/channeloutput/processors/ColorOrderOutputProcessor.cpp +++ b/src/channeloutput/processors/ColorOrderOutputProcessor.cpp @@ -22,12 +22,11 @@ ColorOrderOutputProcessor::ColorOrderOutputProcessor(const Json::Value& config) start = config["start"].asInt(); count = config["count"].asInt(); order = config["colorOrder"].asInt(); - LogInfo(VB_CHANNELOUT, "Color Order: %d-%d => %d\n", - start, start + (count * 3) - 1, - order); + ProcessModelConfig(config, model, start, count); - //channel numbers need to be 0 based - --start; + LogInfo(VB_CHANNELOUT, "Color Order: %d-%d => %d, Model: %s\n", + start + 1, start + (count * 3), + order, model.c_str()); } ColorOrderOutputProcessor::~ColorOrderOutputProcessor() { diff --git a/src/channeloutput/processors/ColorOrderOutputProcessor.h b/src/channeloutput/processors/ColorOrderOutputProcessor.h index 540077001..ba12e13a2 100644 --- a/src/channeloutput/processors/ColorOrderOutputProcessor.h +++ b/src/channeloutput/processors/ColorOrderOutputProcessor.h @@ -30,4 +30,5 @@ class ColorOrderOutputProcessor : public OutputProcessor { int start; int count; int order; + std::string model; }; diff --git a/src/channeloutput/processors/HoldValueOutputProcessor.cpp b/src/channeloutput/processors/HoldValueOutputProcessor.cpp index 9ebe3e9da..bc3278b91 100644 --- a/src/channeloutput/processors/HoldValueOutputProcessor.cpp +++ b/src/channeloutput/processors/HoldValueOutputProcessor.cpp @@ -21,11 +21,10 @@ HoldValueOutputProcessor::HoldValueOutputProcessor(const Json::Value& config) { active = config["active"].asInt() ? true : false; start = config["start"].asInt(); count = config["count"].asInt(); - LogInfo(VB_CHANNELOUT, "Hold Channel Values: %d-%d\n", - start, start + count - 1); + ProcessModelConfig(config, model, start, count); - // channel numbers need to be 0 based - --start; + LogInfo(VB_CHANNELOUT, "Hold Channel Values: %d-%d, Model: %S\n", + start + 1, start + count, model.c_str()); lastValues = new unsigned char[count]; } diff --git a/src/channeloutput/processors/HoldValueOutputProcessor.h b/src/channeloutput/processors/HoldValueOutputProcessor.h index 43d563c7e..85f99dd85 100644 --- a/src/channeloutput/processors/HoldValueOutputProcessor.h +++ b/src/channeloutput/processors/HoldValueOutputProcessor.h @@ -30,4 +30,5 @@ class HoldValueOutputProcessor : public OutputProcessor { int start; int count; unsigned char* lastValues; + std::string model; }; diff --git a/src/channeloutput/processors/OutputProcessor.cpp b/src/channeloutput/processors/OutputProcessor.cpp index 708db799d..73cbc53d0 100644 --- a/src/channeloutput/processors/OutputProcessor.cpp +++ b/src/channeloutput/processors/OutputProcessor.cpp @@ -24,6 +24,8 @@ #include "RemapOutputProcessor.h" #include "SetValueOutputProcessor.h" #include "ThreeToFourOutputProcessor.h" +#include "../../overlays/PixelOverlay.h" +#include "../../overlays/PixelOverlayModel.h" OutputProcessors::OutputProcessors() { } @@ -132,3 +134,34 @@ OutputProcessor::OutputProcessor() : OutputProcessor::~OutputProcessor() { } + +void ProcessModelConfig(const Json::Value& config, std::string& model, int& start, int& count) { + if (config.isMember("model")) { + model = config["model"].asString(); + if (model != "") { + auto m_model = PixelOverlayManager::INSTANCE.getModel(model); + if (!m_model) { + LogErr(VB_CHANNELOUT, "Invalid Pixel Overlay Model: '%s'\n", model.c_str()); + } else { + int m_channel = m_model->getChannelCount(); + LogDebug(VB_CHANNELOUT, "Before Model applied: %d-%d => Model: %s model\n", + start, start + count - 1, + model.c_str(), m_channel); + + int offset = start; + start = m_model->getStartChannel() + start - 1; + + if (count > m_channel) { + count = m_channel - offset; + LogWarn(VB_CHANNELOUT, "Output processor for Model: %s tried to go past end channel of model. Restricting to %d channels\n", model.c_str(), count); + } else if (count < m_channel) { + LogInfo(VB_CHANNELOUT, "Output processor for Model: %s is using less channels (%d) than overlay model has (%d). This may be intentional\n", + model.c_str(), count, m_channel); + } + } + } + } else { + model = ""; + --start; + } +} diff --git a/src/channeloutput/processors/OutputProcessor.h b/src/channeloutput/processors/OutputProcessor.h index 8e7c30d6c..4d53b5030 100644 --- a/src/channeloutput/processors/OutputProcessor.h +++ b/src/channeloutput/processors/OutputProcessor.h @@ -72,3 +72,5 @@ class OutputProcessors { mutable std::mutex processorsLock; std::list processors; }; + +void ProcessModelConfig(const Json::Value& config, std::string& model, int& start, int& count); diff --git a/src/channeloutput/processors/OverrideZeroOutputProcessor.cpp b/src/channeloutput/processors/OverrideZeroOutputProcessor.cpp index fa09d917a..f3fc71891 100644 --- a/src/channeloutput/processors/OverrideZeroOutputProcessor.cpp +++ b/src/channeloutput/processors/OverrideZeroOutputProcessor.cpp @@ -22,11 +22,9 @@ OverrideZeroOutputProcessor::OverrideZeroOutputProcessor(const Json::Value& conf start = config["start"].asInt(); count = config["count"].asInt(); value = config["value"].asInt(); - LogInfo(VB_CHANNELOUT, "Override Zero Channel Range: %d-%d Value: %d\n", - start, start + count - 1, value); - - //channel numbers need to be 0 based - --start; + ProcessModelConfig(config, model, start, count); + LogInfo(VB_CHANNELOUT, "Override Zero Channel Range: %d-%d Value: %d, Model: %s\n", + start + 1, start + count, value, model.c_str()); } OverrideZeroOutputProcessor::~OverrideZeroOutputProcessor() { diff --git a/src/channeloutput/processors/OverrideZeroOutputProcessor.h b/src/channeloutput/processors/OverrideZeroOutputProcessor.h index 36455d194..41864c29a 100644 --- a/src/channeloutput/processors/OverrideZeroOutputProcessor.h +++ b/src/channeloutput/processors/OverrideZeroOutputProcessor.h @@ -30,4 +30,5 @@ class OverrideZeroOutputProcessor : public OutputProcessor { int start; int count; unsigned char value; + std::string model; }; diff --git a/src/channeloutput/processors/RemapOutputProcessor.cpp b/src/channeloutput/processors/RemapOutputProcessor.cpp index d69218f90..addc96f53 100644 --- a/src/channeloutput/processors/RemapOutputProcessor.cpp +++ b/src/channeloutput/processors/RemapOutputProcessor.cpp @@ -15,6 +15,7 @@ #include "../../log.h" #include "RemapOutputProcessor.h" +#include "OutputProcessor.h" RemapOutputProcessor::RemapOutputProcessor(const Json::Value& config) { description = config["desription"].asString(); @@ -24,13 +25,15 @@ RemapOutputProcessor::RemapOutputProcessor(const Json::Value& config) { count = config["count"].asInt(); loops = config["loops"].asInt(); reverse = config["reverse"].asInt(); + + ProcessModelConfig(config, model, sourceChannel, count); + LogInfo(VB_CHANNELOUT, "Remapped Channels: %d-%d => %d-%d (%d total channels copied in %d loop(s))\n", - sourceChannel, sourceChannel + count - 1, + sourceChannel + 1, sourceChannel + count, destChannel, destChannel + (count * loops) - 1, (count * loops), loops); // channel numbers need to be 0 based --destChannel; - --sourceChannel; } RemapOutputProcessor::RemapOutputProcessor(int src, int dst, int c, int l, int r) { diff --git a/src/channeloutput/processors/RemapOutputProcessor.h b/src/channeloutput/processors/RemapOutputProcessor.h index 13cadfb59..b5aafdb43 100644 --- a/src/channeloutput/processors/RemapOutputProcessor.h +++ b/src/channeloutput/processors/RemapOutputProcessor.h @@ -37,4 +37,5 @@ class RemapOutputProcessor : public OutputProcessor { int count; int loops; int reverse; + std::string model; }; diff --git a/src/channeloutput/processors/SetValueOutputProcessor.cpp b/src/channeloutput/processors/SetValueOutputProcessor.cpp index 384addaf8..8b0cebb8e 100644 --- a/src/channeloutput/processors/SetValueOutputProcessor.cpp +++ b/src/channeloutput/processors/SetValueOutputProcessor.cpp @@ -22,12 +22,10 @@ SetValueOutputProcessor::SetValueOutputProcessor(const Json::Value& config) { start = config["start"].asInt(); count = config["count"].asInt(); value = config["value"].asInt(); - LogInfo(VB_CHANNELOUT, "Set Channel Value: %d-%d => %d\n", - start, start + count - 1, - value); - - //channel numbers need to be 0 based - --start; + ProcessModelConfig(config, model, start, count); + LogInfo(VB_CHANNELOUT, "Set Channel Value: %d-%d => %d, Model: %s\n", + start + 1, start + count, + value, model.c_str()); } SetValueOutputProcessor::~SetValueOutputProcessor() { diff --git a/src/channeloutput/processors/SetValueOutputProcessor.h b/src/channeloutput/processors/SetValueOutputProcessor.h index 8fd222e90..5b51f12a5 100644 --- a/src/channeloutput/processors/SetValueOutputProcessor.h +++ b/src/channeloutput/processors/SetValueOutputProcessor.h @@ -30,4 +30,5 @@ class SetValueOutputProcessor : public OutputProcessor { int start; int count; int value; + std::string model; }; diff --git a/src/channeloutput/processors/ThreeToFourOutputProcessor.cpp b/src/channeloutput/processors/ThreeToFourOutputProcessor.cpp index b5bed7f04..f2a9914e6 100644 --- a/src/channeloutput/processors/ThreeToFourOutputProcessor.cpp +++ b/src/channeloutput/processors/ThreeToFourOutputProcessor.cpp @@ -24,9 +24,11 @@ ThreeToFourOutputProcessor::ThreeToFourOutputProcessor(const Json::Value& config order = config["colorOrder"].asInt(); algorithm = config["algorithm"].asInt(); + ProcessModelConfig(config, model, start, count); - //channel numbers need to be 0 based - --start; + LogInfo(VB_CHANNELOUT, "ThreeToFour: %d-%d, Model: %s\n", + start + 1, start + count, + model.c_str()); } ThreeToFourOutputProcessor::~ThreeToFourOutputProcessor() { diff --git a/src/channeloutput/processors/ThreeToFourOutputProcessor.h b/src/channeloutput/processors/ThreeToFourOutputProcessor.h index 8510cea24..463e80c17 100644 --- a/src/channeloutput/processors/ThreeToFourOutputProcessor.h +++ b/src/channeloutput/processors/ThreeToFourOutputProcessor.h @@ -31,4 +31,5 @@ class ThreeToFourOutputProcessor : public OutputProcessor { int count; int order; int algorithm; + std::string model; }; diff --git a/www/outputprocessors.php b/www/outputprocessors.php index bb5ad2fd0..5a38e9046 100644 --- a/www/outputprocessors.php +++ b/www/outputprocessors.php @@ -21,9 +21,20 @@ function outputOption(val, def) { function HTMLForOutputProcessorConfig(output, models) { var html = ""; var type = output.type; + if (type != "Fold") { + html += "Model:  "; + } if (type == "Remap") { - html += "Source Channel:  " + html += "Start Channel:  " + "Destination:  " + "Count:  " + "Loops:  " @@ -42,15 +53,6 @@ function HTMLForOutputProcessorConfig(output, models) { html += ">RGBW Pixels"; html += ""; } else if (type == "Brightness") { - html += "Model:  "; html += "Start Channel:  " + "Channel Count:  " + "Brightness: " @@ -89,7 +91,7 @@ function HTMLForOutputProcessorConfig(output, models) { + "Channel Count:  " + "Value: "; } else if (type == "Fold") { - html += "Source Channel:  " + html += "Start Channel:  " + "Count:  " + "Node: