| 28 | } |
| 29 | |
| 30 | void LedDeviceWrapper::createLedDevice(QJsonObject config, int smoothingInterval, bool disableOnStartup) |
| 31 | { |
| 32 | _ledDevice.reset(); |
| 33 | |
| 34 | config["smoothingRefreshTime"] = smoothingInterval; |
| 35 | |
| 36 | QThread* thread = new QThread(); |
| 37 | thread->setObjectName("LedDeviceThread"); |
| 38 | |
| 39 | _ledDevice = std::unique_ptr<LedDevice, void(*)(LedDevice*)>( |
| 40 | hyperhdr::leds::CONSTRUCT_LED_DEVICE(config), |
| 41 | [](LedDevice* oldLed) { |
| 42 | QUEUE_CALL_0(oldLed, stop); |
| 43 | hyperhdr::THREAD_REMOVER(QString("LedDevice"), oldLed->thread(), oldLed); |
| 44 | } |
| 45 | ); |
| 46 | _ledDevice->setInstanceIndex(_ownerInstance->getInstanceIndex()); |
| 47 | _ledDevice->moveToThread(thread); |
| 48 | |
| 49 | // setup thread management |
| 50 | if (!disableOnStartup) |
| 51 | connect(thread, &QThread::started, _ledDevice.get(), &LedDevice::start); |
| 52 | connect(thread, &QThread::finished, _ledDevice.get(), &LedDevice::stop); |
| 53 | connect(_ownerInstance, &HyperHdrInstance::SignalSmoothingRestarted, _ledDevice.get(), &LedDevice::smoothingRestarted, Qt::QueuedConnection); |
| 54 | connect(_ledDevice.get(), &LedDevice::SignalEnableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState, Qt::QueuedConnection); |
| 55 | |
| 56 | // start the thread |
| 57 | thread->start(); |
| 58 | } |
| 59 | |
| 60 | void LedDeviceWrapper::handleComponentState(hyperhdr::Components component, bool state) |
| 61 | { |
no test coverage detected