Manual input source select via json (#143)

* implement manual source select via json interface
fix schema error

* refactoring

* add visible value to all listed prios
This commit is contained in:
redPanther
2016-07-31 22:21:35 +02:00
committed by GitHub
parent 04ab2f05f7
commit 722d4eb357
14 changed files with 208 additions and 47 deletions

View File

@@ -555,6 +555,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
, _timer()
, _log(Logger::getInstance("Core"))
, _hwLedCount(_ledString.leds().size())
, _sourceAutoSelectEnabled(true)
{
if (!_raw2ledAdjustment->verifyAdjustments())
{
@@ -643,6 +644,31 @@ void Hyperion::unRegisterPriority(const std::string name)
_priorityRegister.erase(name);
}
void Hyperion::setSourceAutoSelectEnabled(bool enabled)
{
_sourceAutoSelectEnabled = enabled;
if (! _sourceAutoSelectEnabled)
{
setCurrentSourcePriority(_muxer.getCurrentPriority());
}
DebugIf( !_sourceAutoSelectEnabled, _log, "source auto select is disabled");
InfoIf(_sourceAutoSelectEnabled, _log, "set current input source to auto select");
}
bool Hyperion::setCurrentSourcePriority(int priority )
{
bool priorityValid = _muxer.hasPriority(priority);
if (priorityValid)
{
DebugIf(_sourceAutoSelectEnabled, _log, "source auto select is disabled");
_sourceAutoSelectEnabled = false;
_currentSourcePriority = priority;
Info(_log, "set current input source to priority channel %d", _currentSourcePriority);
}
return priorityValid;
}
void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms, bool clearEffects)
{
@@ -758,7 +784,8 @@ void Hyperion::clearall()
int Hyperion::getCurrentPriority() const
{
return _muxer.getCurrentPriority();
return _sourceAutoSelectEnabled || !_muxer.hasPriority(_currentSourcePriority) ? _muxer.getCurrentPriority() : _currentSourcePriority;
}
QList<int> Hyperion::getActivePriorities() const
@@ -797,8 +824,8 @@ void Hyperion::update()
_muxer.setCurrentTime(QDateTime::currentMSecsSinceEpoch());
// Obtain the current priority channel
int priority = _muxer.getCurrentPriority();
const PriorityMuxer::InputInfo & priorityInfo = _muxer.getInputInfo(priority);
int priority = _sourceAutoSelectEnabled || !_muxer.hasPriority(_currentSourcePriority) ? _muxer.getCurrentPriority() : _currentSourcePriority;
const PriorityMuxer::InputInfo & priorityInfo = _muxer.getInputInfo(priority);
// copy ledcolors to local buffer
_ledBuffer.reserve(_hwLedCount);

View File

@@ -6,10 +6,10 @@
// Hyperion includes
#include <hyperion/PriorityMuxer.h>
PriorityMuxer::PriorityMuxer(int ledCount) :
_currentPriority(LOWEST_PRIORITY),
_activeInputs(),
_lowestPriorityInfo()
PriorityMuxer::PriorityMuxer(int ledCount)
: _currentPriority(LOWEST_PRIORITY)
, _activeInputs()
, _lowestPriorityInfo()
{
_lowestPriorityInfo.priority = LOWEST_PRIORITY;
_lowestPriorityInfo.timeoutTime_ms = -1;
@@ -46,6 +46,7 @@ const PriorityMuxer::InputInfo& PriorityMuxer::getInputInfo(const int priority)
auto elemIt = _activeInputs.find(priority);
if (elemIt == _activeInputs.end())
{
std::cout << "error " << priority << std::endl;
throw std::runtime_error("HYPERION (prioritymux) ERROR: no such priority");
}
return elemIt.value();

View File

@@ -58,7 +58,10 @@
"required" : true,
"properties":
{
"channelAdjustment_enable" : "boolean",
"channelAdjustment_enable" :
{
"type" : "boolean"
},
"channelAdjustment" :
{
"type" : "array",
@@ -173,7 +176,10 @@
"additionalProperties" : false
}
},
"temperature_enable" : "boolean",
"temperature_enable" :
{
"type" : "boolean"
},
"temperature" :
{
"type" : "array",
@@ -228,7 +234,10 @@
"additionalProperties" : false
}
},
"transform_enable" : "boolean",
"transform_enable" :
{
"type" : "boolean"
},
"transform" :
{
"type" : "array",