Added some extra checks to be more tolerant for configration faults

Former-commit-id: 5061311d8116f848f36808f2c77dcff011ceb571
This commit is contained in:
johan 2013-10-16 23:19:40 +02:00
parent d50aec63f7
commit 64b9316a04
5 changed files with 379 additions and 363 deletions

View File

@ -31,7 +31,7 @@
"hsv" :
{
"saturationGain" : 1.0000,
"valuGain" : 1.5000
"valueGain" : 1.5000
},
"red" :
{

View File

@ -1 +1 @@
cf974e6aa1ff2a7194ce2b82fd5da5fa2373676a
eec9520a7c9861d27e5944da29ba31a5fcee41eb

View File

@ -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;

View File

@ -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;

View File

@ -87,6 +87,7 @@ int main(int argc, char** argv)
if (bootSequence != nullptr)
{
bootSequence->start();
std::cout << "Boot sequence created and started" << std::endl;
}
}
@ -152,7 +153,7 @@ int main(int argc, char** argv)
// run the application
int rc = app.exec();
std::cout << "Application closed" << std::endl;
std::cout << "Application closed with code " << rc << std::endl;
// Clear all colors (switchting off all leds)
hyperion.clearall();