2929#include " PrismatikMath.hpp"
3030#include " Settings.hpp"
3131
32+ void AbstractLedDevice::setSmoothSlowdown (int value) {
33+ m_softSmoothSteps = value;
34+ setColors (m_colorsSaved);
35+ }
36+
3237void AbstractLedDevice::setGamma (double value) {
3338 m_gamma = value;
3439 setColors (m_colorsSaved);
@@ -55,6 +60,21 @@ void AbstractLedDevice::updateWBAdjustments(const QList<WBAdjustment> &coefs) {
5560 setColors (m_colorsSaved);
5661}
5762
63+ void AbstractLedDevice::setUsbPowerLedDisabled (bool ) {
64+ // Default implementation: not supported / unused
65+ emit commandCompleted (true );
66+ }
67+
68+ void AbstractLedDevice::setRefreshDelay (int ) {
69+ // Default implementation: not supported / unused
70+ emit commandCompleted (true );
71+ }
72+
73+ void AbstractLedDevice::setColorDepth (int ) {
74+ // Default implementation: not supported / unused
75+ emit commandCompleted (true );
76+ }
77+
5878void AbstractLedDevice::updateDeviceSettings ()
5979{
6080 using namespace SettingsScope ;
@@ -63,6 +83,7 @@ void AbstractLedDevice::updateDeviceSettings()
6383 setLuminosityThreshold (Settings::getLuminosityThreshold ());
6484 setMinimumLuminosityThresholdEnabled (Settings::isMinimumLuminosityEnabled ());
6585 updateWBAdjustments (Settings::getLedCoefs ());
86+ setSmoothSlowdown (Settings::getDeviceSmooth ());
6687}
6788
6889/* !
@@ -119,3 +140,48 @@ void AbstractLedDevice::applyColorModifications(const QList<QRgb> &inColors, QLi
119140 }
120141
121142}
143+
144+ void AbstractLedDevice::setColors (const QList<QRgb> & colors) {
145+ if (m_softSmoothSteps == 0 ) {
146+ setColorsUnsmoothed (colors);
147+ } else {
148+ if (m_colorsSaved.size () != colors.size ()) {
149+ for (int i = 0 ; i < colors.size (); i++) {
150+ m_colorsSaved.append (0 );
151+ }
152+ }
153+
154+ m_softSmoothIndex = 0 ;
155+ m_colorsSmoothStart = m_colorsSaved;
156+ m_colorsSmoothEnd = colors;
157+
158+ setColorsUnsmoothed (m_colorsSaved);
159+
160+ if (!m_softSmoothTimer) {
161+ m_softSmoothTimer = new QTimer (this );
162+ connect (m_softSmoothTimer, SIGNAL (timeout ()), this , SLOT (softSmoothTimerTick ()));
163+ m_softSmoothTimer->setInterval (20 );
164+ }
165+ if (!m_softSmoothTimer->isActive ()) {
166+ m_softSmoothTimer->start ();
167+ }
168+ }
169+ }
170+
171+ void AbstractLedDevice::softSmoothTimerTick () {
172+ for (int i = 0 ; i < m_colorsSmoothStart.size (); i++) {
173+ QColor start = m_colorsSmoothStart[i];
174+ QColor end = m_colorsSmoothEnd[i];
175+ m_colorsSaved[i] = qRgb (
176+ start.red () + (end.red () - start.red ()) * ((float )m_softSmoothIndex) / m_softSmoothSteps,
177+ start.green () + (end.green () - start.green ()) * ((float )m_softSmoothIndex) / m_softSmoothSteps,
178+ start.blue () + (end.blue () - start.blue ()) * ((float )m_softSmoothIndex) / m_softSmoothSteps);
179+ }
180+
181+ setColorsUnsmoothed (m_colorsSaved);
182+
183+ if (m_softSmoothIndex == m_softSmoothSteps) {
184+ m_softSmoothTimer->stop ();
185+ }
186+ m_softSmoothIndex++;
187+ }
0 commit comments