mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Added some extra checks to be more tolerant for configration faults
Former-commit-id: 5061311d8116f848f36808f2c77dcff011ceb571
This commit is contained in:
@@ -71,6 +71,16 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
|
||||
led.minY_frac = std::max(0.0, std::min(1.0, vscanConfig["minimum"].asDouble()));
|
||||
led.maxY_frac = std::max(0.0, std::min(1.0, vscanConfig["maximum"].asDouble()));
|
||||
|
||||
// Fix if the user swapped min and max
|
||||
if (led.minX_frac > led.maxX_frac)
|
||||
{
|
||||
std::swap(led.minX_frac, led.maxX_frac);
|
||||
}
|
||||
if (led.minY_frac > led.maxY_frac)
|
||||
{
|
||||
std::swap(led.minY_frac, led.maxY_frac);
|
||||
}
|
||||
|
||||
ledString.leds().push_back(led);
|
||||
}
|
||||
return ledString;
|
||||
|
@@ -85,6 +85,11 @@ void ImageToLedsMap::getMeanLedColor(const RgbImage & image, std::vector<RgbColo
|
||||
|
||||
RgbColor ImageToLedsMap::calcMeanColor(const RgbImage & image, const std::vector<unsigned> & colors) const
|
||||
{
|
||||
if (colors.size() == 0)
|
||||
{
|
||||
return RgbColor::BLACK;
|
||||
}
|
||||
|
||||
// Accumulate the sum of each seperate color channel
|
||||
uint_fast16_t cummRed = 0;
|
||||
uint_fast16_t cummGreen = 0;
|
||||
|
Reference in New Issue
Block a user