@@ -58,8 +58,9 @@ const unsigned DEFAULT_OUTPUTDEPLAY = 0; // in frames
5858
5959using namespace hyperion ;
6060
61- LinearColorSmoothing::LinearColorSmoothing (const QJsonDocument &config, Hyperion *hyperion)
61+ LinearColorSmoothing::LinearColorSmoothing (const QJsonObject &config, Hyperion *hyperion)
6262 : QObject(hyperion)
63+ , _smoothConfig(config)
6364 , _log(nullptr )
6465 , _hyperion(hyperion)
6566 , _prioMuxer(_hyperion->getMuxerInstance ())
@@ -79,8 +80,6 @@ LinearColorSmoothing::LinearColorSmoothing(const QJsonDocument &config, Hyperion
7980
8081 // init cfg (default)
8182 updateConfig (SmoothingConfigID::SYSTEM, DEFAULT_SETTLINGTIME, DEFAULT_UPDATEFREQUENCY, DEFAULT_OUTPUTDEPLAY);
82- handleSettingsUpdate (settings::SMOOTHING, config);
83-
8483 // add pause on cfg 1
8584 SmoothingCfg cfg {true , 0 , 0 };
8685 _cfgList.append (std::move (cfg));
@@ -103,6 +102,8 @@ void LinearColorSmoothing::start()
103102 QObject::connect (_hyperion, &Hyperion::compStateChangeRequest, this , &LinearColorSmoothing::componentStateChange);
104103 QObject::connect (_prioMuxer.get (), &PriorityMuxer::prioritiesChanged, this , &LinearColorSmoothing::handlePriorityUpdate);
105104 connect (_timer.get (), &QTimer::timeout, this , &LinearColorSmoothing::updateLeds);
105+
106+ updateSettings (_smoothConfig);
106107}
107108
108109void LinearColorSmoothing::stop ()
@@ -116,21 +117,17 @@ void LinearColorSmoothing::stop()
116117 Info (_log, " LinearColorSmoothing stopped" );
117118}
118119
119- void LinearColorSmoothing::handleSettingsUpdate (settings::type type, const QJsonDocument &config)
120+ void LinearColorSmoothing::updateSettings ( const QJsonObject &config)
120121{
121- if (type == settings::type::SMOOTHING)
122- {
123- QJsonObject obj = config.object ();
124-
125- setEnable (obj[" enable" ].toBool (_enabled));
122+ setEnable (config[" enable" ].toBool (_enabled));
126123 _enabledSystemCfg = _enabled;
127124
128- int64_t settlingTime_ms = static_cast <int64_t >(obj [SETTINGS_KEY_SETTLING_TIME].toInt (DEFAULT_SETTLINGTIME));
129- int _updateInterval_ms =static_cast <int >(MS_PER_MICRO / obj [SETTINGS_KEY_UPDATE_FREQUENCY].toDouble (DEFAULT_UPDATEFREQUENCY));
125+ int64_t settlingTime_ms = static_cast <int64_t >(config [SETTINGS_KEY_SETTLING_TIME].toInt (DEFAULT_SETTLINGTIME));
126+ int _updateInterval_ms =static_cast <int >(MS_PER_MICRO / config [SETTINGS_KEY_UPDATE_FREQUENCY].toDouble (DEFAULT_UPDATEFREQUENCY));
130127
131128 SmoothingCfg cfg (false , settlingTime_ms, _updateInterval_ms);
132129
133- const QString typeString = obj [SETTINGS_KEY_SMOOTHING_TYPE].toString ();
130+ const QString typeString = config [SETTINGS_KEY_SMOOTHING_TYPE].toString ();
134131
135132 if (typeString == SETTINGS_KEY_DECAY) {
136133 cfg._type = SmoothingType::Decay;
@@ -140,11 +137,11 @@ void LinearColorSmoothing::handleSettingsUpdate(settings::type type, const QJson
140137 }
141138
142139 cfg._pause = false ;
143- cfg._outputDelay = static_cast <unsigned >(obj [SETTINGS_KEY_OUTPUT_DELAY].toInt (DEFAULT_OUTPUTDEPLAY));
140+ cfg._outputDelay = static_cast <unsigned >(config [SETTINGS_KEY_OUTPUT_DELAY].toInt (DEFAULT_OUTPUTDEPLAY));
144141
145- cfg._interpolationRate = obj [SETTINGS_KEY_INTERPOLATION_RATE].toDouble (DEFAULT_UPDATEFREQUENCY);
146- cfg._dithering = obj [SETTINGS_KEY_DITHERING].toBool (false );
147- cfg._decay = obj [SETTINGS_KEY_DECAY].toDouble (1.0 );
142+ cfg._interpolationRate = config [SETTINGS_KEY_INTERPOLATION_RATE].toDouble (DEFAULT_UPDATEFREQUENCY);
143+ cfg._dithering = config [SETTINGS_KEY_DITHERING].toBool (false );
144+ cfg._decay = config [SETTINGS_KEY_DECAY].toDouble (1.0 );
148145
149146 _cfgList[SmoothingConfigID::SYSTEM] = cfg;
150147 DebugIf (_enabled,_log," %s" , QSTRING_CSTR (getConfig (SmoothingConfigID::SYSTEM)));
@@ -154,6 +151,13 @@ void LinearColorSmoothing::handleSettingsUpdate(settings::type type, const QJson
154151 {
155152 selectConfig (SmoothingConfigID::SYSTEM, true );
156153 }
154+ }
155+
156+ void LinearColorSmoothing::handleSettingsUpdate (settings::type type, const QJsonDocument &config)
157+ {
158+ if (type == settings::type::SMOOTHING)
159+ {
160+ updateSettings (config.object ());
157161 }
158162}
159163
@@ -533,7 +537,7 @@ void LinearColorSmoothing::clearRememberedFrames()
533537
534538void LinearColorSmoothing::queueColors (const std::vector<ColorRgb> &ledColors)
535539{
536- assert (ledColors.size () > 0 );
540+ assert (! ledColors.empty () );
537541
538542 if (_outputDelay == 0 )
539543 {
0 commit comments