| 217 | |
| 218 | |
| 219 | void HyperHdrInstance::handleSettingsUpdate(settings::type type, const QJsonDocument& config) |
| 220 | { |
| 221 | |
| 222 | // std::cout << config.toJson().toStdString() << std::endl; |
| 223 | |
| 224 | if (type == settings::type::COLOR) |
| 225 | { |
| 226 | const QJsonObject obj = config.object(); |
| 227 | // change in color recreate ledAdjustments |
| 228 | _ledColorCalibration = std::unique_ptr<LedCalibration>(new LedCalibration(_instIndex, static_cast<int>(_ledString.leds().size()), obj)); |
| 229 | |
| 230 | if (!_ledColorCalibration->verifyAdjustments()) |
| 231 | { |
| 232 | Warning(_log, "At least one led has no color calibration, please add all leds from your led layout to an 'LED index' field!"); |
| 233 | } |
| 234 | |
| 235 | emit SignalImageToLedsMappingChanged(_imageProcessor->getLedMappingType()); |
| 236 | } |
| 237 | else if (type == settings::type::LEDS) |
| 238 | { |
| 239 | const QJsonArray leds = config.array(); |
| 240 | |
| 241 | // ledstring, img processor, muxer, ledGridSize (effect-engine image based effects), _ledBuffer and ByteOrder of ledstring |
| 242 | _ledString = LedString::createLedString(leds, LedString::createColorOrder(getSetting(settings::type::DEVICE).object())); |
| 243 | _imageProcessor->setLedString(_ledString); |
| 244 | _ledGridSize = LedString::getLedLayoutGridSize(leds); |
| 245 | |
| 246 | std::vector<ColorRgb> color(_ledString.leds().size(), ColorRgb{ 0,0,0 }); |
| 247 | _currentLedColors = color; |
| 248 | |
| 249 | // handle hwLedCount update |
| 250 | _hwLedCount = qMax(getSetting(settings::type::DEVICE).object()["hardwareLedCount"].toInt(1), getLedCount()); |
| 251 | |
| 252 | // change in leds are also reflected in adjustment |
| 253 | _ledColorCalibration = std::unique_ptr<LedCalibration>(new LedCalibration(_instIndex, static_cast<int>(_ledString.leds().size()), getSetting(settings::type::COLOR).object())); |
| 254 | } |
| 255 | else if (type == settings::type::DEVICE) |
| 256 | { |
| 257 | QJsonObject dev = config.object(); |
| 258 | |
| 259 | // handle hwLedCount update |
| 260 | _hwLedCount = qMax(dev["hardwareLedCount"].toInt(1), getLedCount()); |
| 261 | |
| 262 | // force ledString update, if device ByteOrder changed |
| 263 | if (_ledString.colorOrder != LedString::stringToColorOrder(dev["colorOrder"].toString("rgb"))) |
| 264 | { |
| 265 | Info(_log, "New RGB order is: %s", QSTRING_CSTR(dev["colorOrder"].toString("rgb"))); |
| 266 | _ledString = LedString::createLedString(getSetting(settings::type::LEDS).array(), LedString::createColorOrder(dev)); |
| 267 | _imageProcessor->setLedString(_ledString); |
| 268 | } |
| 269 | |
| 270 | // do always reinit until the led devices can handle dynamic changes |
| 271 | dev["currentLedCount"] = _hwLedCount; // Inject led count info |
| 272 | _ledDeviceWrapper->createLedDevice(dev, _smoothing->GetSuggestedInterval(), false); |
| 273 | } |
| 274 | else if (type == settings::type::BGEFFECT || type == settings::type::FGEFFECT) |
| 275 | { |
| 276 | bool isBootEffect = (type == settings::type::FGEFFECT); |
nothing calls this directly
no test coverage detected