2013-07-26 22:38:34 +02:00
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
// JsonSchema includes
|
|
|
|
#include <utils/jsonschema/JsonFactory.h>
|
|
|
|
|
|
|
|
// hyperion includes
|
|
|
|
#include <hyperion/LedString.h>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
std::string homeDir = getenv("RASPILIGHT_HOME");
|
|
|
|
|
|
|
|
const std::string schemaFile = homeDir + "/hyperion.schema.json";
|
|
|
|
const std::string configFile = homeDir + "/hyperion.config.json";
|
|
|
|
|
|
|
|
Json::Value config;
|
|
|
|
if (JsonFactory::load(schemaFile, configFile, config) < 0)
|
|
|
|
{
|
|
|
|
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Json::Value& deviceConfig = config["device"];
|
2013-08-13 12:03:00 +02:00
|
|
|
if (deviceConfig.empty())
|
|
|
|
{
|
|
|
|
std::cout << "Missing DEVICE configuration 'device'" << std::endl;
|
|
|
|
}
|
2013-07-26 22:38:34 +02:00
|
|
|
const Json::Value& ledConfig = config["leds"];
|
2013-08-13 12:03:00 +02:00
|
|
|
if (ledConfig.empty())
|
|
|
|
{
|
|
|
|
std::cout << "Missing LEDS configuration 'leds'" << std::endl;
|
|
|
|
}
|
2013-07-26 22:38:34 +02:00
|
|
|
|
2013-08-13 12:03:00 +02:00
|
|
|
const Json::Value& colorConfig = config["color"];
|
|
|
|
if (colorConfig.empty())
|
|
|
|
{
|
|
|
|
std::cout << "Missing COLORS configuration 'colors'" << std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cout << "COLOR CONFIGURATION: " << colorConfig.toStyledString() << std::endl;
|
2013-07-26 22:38:34 +02:00
|
|
|
|
2013-08-13 12:03:00 +02:00
|
|
|
const Json::Value& redConfig = colorConfig["red"];
|
|
|
|
double redGamma = redConfig["gamma"].asDouble();
|
|
|
|
std::cout << "RED GAMMA = " << redGamma << std::endl;
|
|
|
|
std::cout << "RED GAMMA = " << colorConfig["red.gamma"].asDouble() << std::endl;
|
|
|
|
}
|
2013-07-26 22:38:34 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|