mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
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:
@@ -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 );
|
||||
|
Reference in New Issue
Block a user