detect config is readonly, adalight and other stuff (#333)

* update lightberry sketches
update compilehowwto (windows disclaimer)
some refactoring in main cmakelists + preparation for windows compile
tune ada driver, set delayAfterConnect default to 1.5s because some arduino (e.g. mega r3) needs this
set priority min/max for grabber/network services - prevent colliding prios between webui/background stuff and grabbers/net services

* add check if config is writable. TODO do something usefull in webui

* fix indention error

* fix typo

* fix webui can't write led config

* typo

* fix cmakelists

* change methode of detecting linux
This commit is contained in:
redPanther
2016-12-14 22:45:00 +01:00
committed by GitHub
parent 5774457893
commit a724fd1535
20 changed files with 609 additions and 160 deletions

View File

@@ -12,6 +12,7 @@
#include <QStringList>
#include <QCryptographicHash>
#include <QFile>
#include <QFileInfo>
// hyperion include
#include <hyperion/Hyperion.h>
@@ -32,7 +33,7 @@
Hyperion* Hyperion::_hyperion = nullptr;
Hyperion* Hyperion::initInstance(const QJsonObject& qjsonConfig, const std::string configFile) // REMOVE jsonConfig variable when the conversion from jsonCPP to QtJSON is finished
Hyperion* Hyperion::initInstance(const QJsonObject& qjsonConfig, const QString configFile) // REMOVE jsonConfig variable when the conversion from jsonCPP to QtJSON is finished
{
if ( Hyperion::_hyperion != nullptr )
throw std::runtime_error("Hyperion::initInstance can be called only one time");
@@ -514,7 +515,7 @@ MessageForwarder * Hyperion::getForwarder()
return _messageForwarder;
}
Hyperion::Hyperion(const QJsonObject &qjsonConfig, const std::string configFile)
Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
: _ledString(createLedString(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
, _ledStringClone(createLedStringClone(qjsonConfig["leds"], createColorOrder(qjsonConfig["device"].toObject())))
, _muxer(_ledString.leds().size())
@@ -582,6 +583,7 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const std::string configFile)
Debug(_log,"configured leds: %d hw leds: %d", getLedCount(), _hwLedCount);
WarningIf(hwLedCount < getLedCount(), _log, "more leds configured than available. check 'ledCount' in 'device' section");
WarningIf(!configWriteable(), _log, "Your config is not writeable - you won't be able to use the web ui for configuration.");
// initialize hash of current config
configModified();
@@ -618,7 +620,7 @@ unsigned Hyperion::getLedCount() const
bool Hyperion::configModified()
{
bool isModified = false;
QFile f(_configFile.c_str());
QFile f(_configFile);
if (f.open(QFile::ReadOnly))
{
QCryptographicHash hash(QCryptographicHash::Sha1);
@@ -639,6 +641,14 @@ bool Hyperion::configModified()
return isModified;
}
bool Hyperion::configWriteable()
{
QFile file(_configFile);
QFileInfo fileInfo(file);
return fileInfo.isWritable() && fileInfo.isReadable();
}
void Hyperion::registerPriority(const std::string name, const int priority)
{
Info(_log, "Register new input source named '%s' for priority channel '%d'", name.c_str(), priority );

View File

@@ -476,7 +476,8 @@
"priority" :
{
"type" : "integer",
"minimum" : 0,
"minimum" : 2,
"maximum" : 2000000000,
"title" : "edt_conf_general_priority_title",
"default" : 900,
"propertyOrder" : 9
@@ -617,7 +618,8 @@
{
"type" : "integer",
"title" : "edt_conf_general_priority_title",
"minimum" : 0,
"minimum" : 2,
"maximum" : 2000000000,
"default" : 890
},
"cropLeft" :
@@ -974,7 +976,8 @@
{
"type" : "integer",
"title" : "edt_conf_general_priority_title",
"minimum" : 0,
"minimum" : 2,
"maximum" : 2000000000,
"default" : 800,
"propertyOrder" : 3
}
@@ -1014,7 +1017,8 @@
{
"type" : "integer",
"title" : "edt_conf_general_priority_title",
"minimum" : 0,
"minimum" : 2,
"maximum" : 2000000000,
"default" : 800,
"propertyOrder" : 4
},