MCPcopy Create free account
hub / github.com/awawa-dev/HyperHDR / createLedDevice

Method createLedDevice

sources/led-drivers/LedDeviceWrapper.cpp:30–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30void 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
60void LedDeviceWrapper::handleComponentState(hyperhdr::Components component, bool state)
61{

Callers 2

startMethod · 0.80
handleSettingsUpdateMethod · 0.80

Calls 6

CONSTRUCT_LED_DEVICEFunction · 0.85
setInstanceIndexMethod · 0.80
getInstanceIndexMethod · 0.80
resetMethod · 0.45
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected