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

@@ -2,6 +2,7 @@
LedDeviceAdalight::LedDeviceAdalight(const QJsonObject &deviceConfig)
: ProviderRs232()
, _headerSize(6)
, _ligthBerryAPA102Mode(false)
{
_deviceReady = init(deviceConfig);
@@ -18,7 +19,6 @@ bool LedDeviceAdalight::init(const QJsonObject &deviceConfig)
_ligthBerryAPA102Mode = deviceConfig["lightberry_apa102_mode"].toBool(false);
// create ledBuffer
unsigned int bufferSize = 6; // 6 bytes header
unsigned int totalLedCount = _ledCount;
if (_ligthBerryAPA102Mode)
@@ -26,25 +26,30 @@ bool LedDeviceAdalight::init(const QJsonObject &deviceConfig)
const unsigned int startFrameSize = 4;
const unsigned int bytesPerRGBLed = 4;
const unsigned int endFrameSize = std::max<unsigned int>(((_ledCount + 15) / 16), bytesPerRGBLed);
bufferSize += (_ledCount * bytesPerRGBLed) + startFrameSize + endFrameSize ;
_ledBuffer.resize(_headerSize + (_ledCount * bytesPerRGBLed) + startFrameSize + endFrameSize, 0x00);
// init constant data values
for (signed iLed=1; iLed<=_ledCount; iLed++)
{
_ledBuffer[iLed*4+_headerSize] = 0xFF;
}
Debug( _log, "Adalight driver with activated LightBerry APA102 mode");
}
else
{
totalLedCount -= 1;
bufferSize += _ledRGBCount;
_ledBuffer.resize(_headerSize + _ledRGBCount, 0x00);
}
_ledBuffer.resize(bufferSize, 0x00);
_ledBuffer[0] = 'A';
_ledBuffer[1] = 'd';
_ledBuffer[2] = 'a';
_ledBuffer[3] = (((unsigned int)(totalLedCount)) >> 8) & 0xFF; // LED count high byte
_ledBuffer[4] = ((unsigned int)(totalLedCount)) & 0xFF; // LED count low byte
_ledBuffer[3] = (totalLedCount >> 8) & 0xFF; // LED count high byte
_ledBuffer[4] = totalLedCount & 0xFF; // LED count low byte
_ledBuffer[5] = _ledBuffer[3] ^ _ledBuffer[4] ^ 0x55; // Checksum
Debug( _log, "Adalight header for %d leds: %c%c%c 0x%02x 0x%02x 0x%02x", _ledCount,
_ledBuffer[0], _ledBuffer[1], _ledBuffer[2], _ledBuffer[3], _ledBuffer[4], _ledBuffer[5]
);
_ledBuffer[0], _ledBuffer[1], _ledBuffer[2], _ledBuffer[3], _ledBuffer[4], _ledBuffer[5] );
return true;
}
@@ -56,15 +61,14 @@ int LedDeviceAdalight::write(const std::vector<ColorRgb> & ledValues)
for (signed iLed=1; iLed<=_ledCount; iLed++)
{
const ColorRgb& rgb = ledValues[iLed-1];
_ledBuffer[iLed*4+6] = 0xFF;
_ledBuffer[iLed*4+1+6] = rgb.red;
_ledBuffer[iLed*4+2+6] = rgb.green;
_ledBuffer[iLed*4+3+6] = rgb.blue;
_ledBuffer[iLed*4+7] = rgb.red;
_ledBuffer[iLed*4+8] = rgb.green;
_ledBuffer[iLed*4+9] = rgb.blue;
}
}
else
{
memcpy(6 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
memcpy(_headerSize + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
}
return writeBytes(_ledBuffer.size(), _ledBuffer.data());