Skip to content

Commit 0806593

Browse files
committed
Fix rendering w/o continuous output
1 parent eaa8715 commit 0806593

File tree

17 files changed

+17
-97
lines changed

17 files changed

+17
-97
lines changed

include/infinite-color-engine/InfiniteSmoothing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ private slots:
9191
bool _infoUpdate;
9292
bool _infoInput;
9393
int _coolDown;
94+
long long _lastSentFrame;
9495
};

sources/base/schema/schema-smoothing.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,9 @@
123123
"type" : "boolean",
124124
"format": "checkbox",
125125
"title" : "edt_conf_smooth_continuousOutput_title",
126-
"default" : false,
126+
"default" : true,
127127
"required" : true,
128128
"propertyOrder" : 10
129-
},
130-
"testMode" :
131-
{
132-
"type" : "boolean",
133-
"format": "checkbox",
134-
"title" : "edt_conf_smoothing_testMode_title",
135-
"default" : false,
136-
"required" : true,
137-
"propertyOrder" : 11
138129
}
139130
},
140131
"additionalProperties" : false

sources/infinite-color-engine/InfiniteSmoothing.cpp

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -61,57 +61,6 @@ namespace
6161
constexpr int64_t DEFAUL_SETTLINGTIME = 200; // settlingtime in ms
6262
constexpr double DEFAUL_UPDATEFREQUENCY = 25; // updatefrequncy in hz
6363
constexpr double MINIMAL_UPDATEFREQUENCY = 20;
64-
65-
struct TestPilot
66-
{
67-
bool active = false;
68-
long long started = 0;
69-
std::vector<float4> sequence = {
70-
{0, 0.0f, 0.0f, 0.0f}, // start from black color
71-
{2000, 1.0f, 0.0f, 0.0f}, // short (100ms) red color blink at 2.0sec
72-
{2100, 0.0f, 0.0f, 0.0f}, // return to black color
73-
{2300, 0.0f, 1.0f, 0.0f}, // short (100ms) green color blink at 2.3sec
74-
{2400, 0.0f, 0.0f, 0.0f}, // return to black color
75-
{2600, 0.0f, 0.0f, 1.0f}, // short (100ms) blue color blink at 2.6sec
76-
{2700, 0.0f, 0.0f, 0.0f}, // return to black color
77-
{3000, 0.0f, 0.0f, 1.0f}, // start moving to blue color at 3sec
78-
{3200, 0.0f, 1.0f, 0.0f}, // then turn to green color at 3.2sec
79-
{3400, 1.0f, 0.0f, 0.0f}, // then immediately turn to red color at 3.4sec and wait
80-
{4000, 0.0f, 0.0f, 1.0f}, // start moving to blue color at 4sec
81-
{4100, 1.0f, 0.0f, 0.0f}, // then turn to red color at 4.1sec
82-
{4200, 0.0f, 1.0f, 0.0f}, // the turn to green at 4.2sec and wait
83-
{6000, 0.0f, 0.0f, 0.0f}, // finally return to black color at 6sec
84-
{8000, 0.0f, 0.0f, 0.0f} // the end of the cycle at 6sec
85-
};
86-
float3 getColorAtTime(long long currentTimeMs)
87-
{
88-
long long delta = currentTimeMs - started;
89-
90-
if (!sequence.empty() && delta > static_cast<long long>(sequence.back().x)) {
91-
started = currentTimeMs;
92-
delta = 0;
93-
}
94-
95-
float3 color = { 0.0f, 0.0f, 0.0f };
96-
97-
for (size_t i = 1; i < sequence.size(); ++i) {
98-
if (delta < static_cast<long long>(sequence[i].x)) {
99-
color = { sequence[i - 1].y, sequence[i - 1].z, sequence[i - 1].w };
100-
break;
101-
}
102-
}
103-
104-
printf("Δ%4lld | incomingColors: (%d, %d, %d)", delta, (int)(color.x * 255), (int)(color.y * 255), (int)(color.z * 255));
105-
106-
return color;
107-
}
108-
};
109-
110-
TestPilot& getTestPilot()
111-
{
112-
static TestPilot testPilot;
113-
return testPilot;
114-
}
11564
}
11665

11766
InfiniteSmoothing::InfiniteSmoothing(const QJsonDocument& config, HyperHdrInstance* hyperhdr)
@@ -125,7 +74,8 @@ InfiniteSmoothing::InfiniteSmoothing(const QJsonDocument& config, HyperHdrInstan
12574
_interpolator(std::make_unique<InfiniteStepperInterpolator>()),
12675
_infoUpdate(true),
12776
_infoInput(true),
128-
_coolDown(0)
77+
_coolDown(SMOOTHING_COOLDOWN_PHASE),
78+
_lastSentFrame(0)
12979
{
13080
// init cfg 0 (SMOOTHING_USER_CONFIG)
13181
addConfig(DEFAUL_SETTLINGTIME, DEFAUL_UPDATEFREQUENCY);
@@ -152,7 +102,8 @@ void InfiniteSmoothing::clearQueuedColors(bool deviceEnabled, bool restarting)
152102

153103
_infoUpdate = true;
154104
_infoInput = true;
155-
_coolDown = 0;
105+
_coolDown = (deviceEnabled) ? SMOOTHING_COOLDOWN_PHASE: 0;
106+
_lastSentFrame = 0;
156107

157108
if (restarting || _interpolator == nullptr)
158109
{
@@ -219,11 +170,6 @@ void InfiniteSmoothing::handleSignalInstanceSettingsChanged(settings::type type,
219170

220171
_continuousOutput = obj["continuousOutput"].toBool(true);
221172

222-
if (getTestPilot().active = obj["testMode"].toBool(false); getTestPilot().active)
223-
{
224-
getTestPilot().started = InternalClock::now();
225-
}
226-
227173
_configurations[SMOOTHING_USER_CONFIG] = std::make_unique<SmoothingConfig>(
228174
SmoothingConfig{
229175
.pause = false,
@@ -276,39 +222,42 @@ void InfiniteSmoothing::incomingColors(std::vector<float3>&& nonlinearRgbColors)
276222
QMutexLocker locker(&_dataSynchro);
277223

278224
auto nowTime = InternalClock::now();
279-
if (getTestPilot().active)
280-
{
281-
std::fill(nonlinearRgbColors.begin(), nonlinearRgbColors.end(), getTestPilot().getColorAtTime(nowTime));
282-
}
283-
_interpolator->setTargetColors(std::move(nonlinearRgbColors), nowTime, getTestPilot().active);
225+
_interpolator->setTargetColors(std::move(nonlinearRgbColors), nowTime, false);
284226
}
285227
}
286228

287229
void InfiniteSmoothing::updateLeds()
288230
{
289231
SharedOutputColors nonlinearRgbColors;
290232
bool finished = false;
233+
long long timeNow = 0;
291234
// critical section
292235
{
293236
QMutexLocker locker(&_dataSynchro);
294237
if (!isEnabled())
295238
return;
296-
_interpolator->updateCurrentColors(InternalClock::now());
239+
240+
timeNow = InternalClock::now();
241+
_interpolator->updateCurrentColors(timeNow);
297242

298243
nonlinearRgbColors = _interpolator->getCurrentColors();
299244

300245
if (!_interpolator->isAnimationComplete())
301246
{
302247
_coolDown = SMOOTHING_COOLDOWN_PHASE;
303248
}
304-
else
249+
else if (!_continuousOutput)
305250
{
306-
finished = (!_continuousOutput) && (_coolDown <= 0 || _coolDown-- <= 0);
251+
if (_coolDown > 0)
252+
_coolDown--;
253+
else if (std::abs(timeNow - _lastSentFrame) < 1000)
254+
finished = true;
307255
}
308256
}
309257

310258
if (!nonlinearRgbColors->empty() && !finished)
311259
{
260+
_lastSentFrame = timeNow;
312261
queueColors(std::move(nonlinearRgbColors));
313262
}
314263
}
@@ -318,13 +267,6 @@ void InfiniteSmoothing::queueColors(SharedOutputColors&& nonlinearRgbLedColors)
318267
if (nonlinearRgbLedColors->empty())
319268
return;
320269

321-
if (getTestPilot().active)
322-
{
323-
const auto& color = nonlinearRgbLedColors->front();
324-
long long delta = InternalClock::now() - getTestPilot().started;
325-
printf("Δ%4lld | updateCurrentColors: (%d, %d, %d)\n", delta, (int)(color.x * 255), (int)(color.y * 255), (int)(color.z * 255));
326-
}
327-
328270
emit SignalProcessedColors(nonlinearRgbLedColors);
329271
}
330272

www/i18n/cs.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Vynásobí barevné složky RGB daným faktorem v lineárním prostoru RGB.",
13011301
"edt_conf_processing_powerLimit_title": "Omezení výstupního výkonu",
13021302
"edt_conf_processing_powerLimit_expl": "Tato funkce kontroluje, zda byl překročen celkový odběr energie pro aktuální scénu. Pokud ano, automaticky sníží jas a barvu každé LED diody. <strong>Upozorňujeme, že se nejedná o náhradu dostatečně výkonného zdroje napájení.</strong> Tato funkce je navržena pouze k omezení nadměrného jasu a nechrání vaše zařízení před poškozením v důsledku poddimenzovaného zdroje napájení. Nezaručujeme, že se tato funkce přímo projeví omezením výkonu LED diod na určitou hodnotu výkonu.",
1303-
"edt_conf_smoothing_testMode_title": "Testovací režim",
13041303
"edt_conf_smoothing_testMode_expl": "Cyklické náhlé změny barev pro testování algoritmů vyhlazování, výstup do konzole (ve Windows spusťte HyperHDR s parametrem -c).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Exponenciální nekonečný interpolátor",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "Klasická exponenciální implementace vyhlazování aktualizuje barvy LED diod směrem k cíli, rychle reaguje na velké rozdíly a zpomaluje, jak se k cíli přibližují, čímž vytváří plynulé a přirozené přechody mezi okolním osvětlením.",

www/i18n/de.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Multipliziert die RGB-Farbkomponenten mit einem bestimmten Faktor im linearen RGB-Raum.",
13011301
"edt_conf_processing_powerLimit_title": "Leistungsbegrenzung",
13021302
"edt_conf_processing_powerLimit_expl": "Diese Funktion prüft, ob die Gesamtleistungsaufnahme der aktuellen Szene überschritten wurde. Falls ja, werden Helligkeit und Farbe jeder LED automatisch reduziert. <strong>Bitte beachten Sie: Dies ist kein Ersatz für ein ausreichend leistungsstarkes Netzteil.</strong> Diese Funktion dient lediglich der Begrenzung übermäßiger Helligkeit und schützt Ihre Geräte nicht vor Schäden durch ein zu kleines Netzteil. Wir garantieren nicht, dass diese Funktion die Leistung des LED-Setups direkt auf einen bestimmten Wattwert begrenzt.",
1303-
"edt_conf_smoothing_testMode_title": "Testmodus",
13041303
"edt_conf_smoothing_testMode_expl": "Zyklische, plötzliche Farbänderungen zum Testen von Glättungsalgorithmen, Ausgabe in der Konsole (unter Windows HyperHDR mit dem Parameter -c ausführen).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Exponentieller Unendlicher Interpolator",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "Die klassische exponentielle Implementierung der Glättung aktualisiert die LED-Farben in Richtung eines Ziels. Sie reagiert schnell auf große Unterschiede und verlangsamt sich bei Annäherung an das Ziel. Dadurch entstehen sanfte, natürliche Übergänge der Umgebungsbeleuchtung.",

www/i18n/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Multiplies the RGB color components by a given factor in the linear RGB space.",
13011301
"edt_conf_processing_powerLimit_title": "Limit power output",
13021302
"edt_conf_processing_powerLimit_expl": "This feature checks whether the total power draw for the current scene has been exceeded. If so, it automatically scales down the brightness and color of each LED. <strong>Please note, this is not a substitute for a sufficiently powerful power supply.</strong> This function is only designed to limit excessive brightness and will not protect your equipment from damage due to an undersized power supply. We do not guarantee that this feature will directly translate into limiting the power of the LED setup to a specific wattage value.",
1303-
"edt_conf_smoothing_testMode_title": "Test mode",
13041303
"edt_conf_smoothing_testMode_expl": "Cyclic sudden color changes for smoothing algorithms testing, output to the console (on Windows run HyperHDR with -c parameter).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Exponential Infinite Interpolator",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "Classic exponential implementation of smoothing updates LED colors toward a target, reacting quickly to large differences and slowing as they approach the target, producing smooth, natural ambient lighting transitions.",

www/i18n/es.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Multiplica los componentes de color RGB por un factor determinado en el espacio RGB lineal.",
13011301
"edt_conf_processing_powerLimit_title": "Limitar la potencia de salida",
13021302
"edt_conf_processing_powerLimit_expl": "Esta función comprueba si se ha excedido el consumo total de energía de la escena actual. De ser así, reduce automáticamente el brillo y el color de cada LED. Tenga en cuenta que esto no sustituye a una fuente de alimentación suficientemente potente. Esta función solo está diseñada para limitar el brillo excesivo y no protege su equipo de daños causados ​​por una fuente de alimentación insuficiente. No garantizamos que esta función limite directamente la potencia de la configuración LED a un valor de potencia específico.",
1303-
"edt_conf_smoothing_testMode_title": "Modo de prueba",
13041303
"edt_conf_smoothing_testMode_expl": "Cambios de color repentinos cíclicos para probar algoritmos de suavizado; salida a la consola (en Windows, ejecute HyperHDR con el parámetro -c).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Interpolador exponencial infinito",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "La implementación exponencial clásica del suavizado actualiza los colores del LED hacia un objetivo, reaccionando rápidamente a grandes diferencias y ralentizándolos a medida que se acercan al objetivo, lo que produce transiciones de iluminación ambiental suaves y naturales.",

www/i18n/fr.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Multiplie les composantes de couleur RVB par un facteur donné dans l'espace RVB linéaire.",
13011301
"edt_conf_processing_powerLimit_title": "Limitation de la puissance de sortie",
13021302
"edt_conf_processing_powerLimit_expl": "Cette fonctionnalité vérifie si la consommation totale d'énergie pour la scène actuelle est dépassée. Si tel est le cas, elle réduit automatiquement la luminosité et la couleur de chaque LED. <strong>Veuillez noter que cela ne remplace pas une alimentation suffisamment puissante.</strong> Cette fonction est uniquement conçue pour limiter la luminosité excessive et ne protège pas votre équipement des dommages causés par une alimentation sous-dimensionnée. Nous ne garantissons pas que cette fonctionnalité se traduira directement par une limitation de la puissance de la configuration LED à une valeur spécifique.",
1303-
"edt_conf_smoothing_testMode_title": "Mode test",
13041303
"edt_conf_smoothing_testMode_expl": "Changements de couleur soudains et cycliques pour tester les algorithmes de lissage, sortie vers la console (sous Windows, exécutez HyperHDR avec le paramètre -c).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Interpolateur exponentiel infini",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "L'implémentation exponentielle classique du lissage actualise les couleurs des LED en fonction d'une cible, réagissant rapidement aux différences importantes et ralentissant à mesure qu'elles s'approchent de la cible, produisant ainsi des transitions d'éclairage ambiant fluides et naturelles.",

www/i18n/it.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Moltiplica le componenti di colore RGB per un dato fattore nello spazio RGB lineare.",
13011301
"edt_conf_processing_powerLimit_title": "Limita potenza in uscita",
13021302
"edt_conf_processing_powerLimit_expl": "Questa funzione verifica se il consumo energetico totale per la scena corrente è stato superato. In tal caso, riduce automaticamente la luminosità e il colore di ciascun LED. <strong>Nota: questa funzione non sostituisce un alimentatore sufficientemente potente.</strong> Questa funzione è progettata solo per limitare la luminosità eccessiva e non protegge l'apparecchiatura da danni dovuti a un alimentatore sottodimensionato. Non garantiamo che questa funzione si traduca direttamente nella limitazione della potenza della configurazione LED a un valore di wattaggio specifico.",
1303-
"edt_conf_smoothing_testMode_title": "Modalità test",
13041303
"edt_conf_smoothing_testMode_expl": "Cambiamenti di colore improvvisi e ciclici per testare gli algoritmi di smoothing, output sulla console (su Windows, eseguire HyperHDR con il parametro -c).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Interpolatore Esponenziale Infinito",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "L'implementazione esponenziale classica dello smoothing aggiorna i colori dei LED in base a un target, reagendo rapidamente a grandi differenze e rallentando man mano che si avvicinano al target, producendo transizioni di illuminazione ambientale fluide e naturali.",

www/i18n/nl.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,6 @@
13001300
"edt_conf_processing_scaleOutput_expl": "Vermenigvuldigt de RGB-kleurcomponenten met een bepaalde factor in de lineaire RGB-ruimte.",
13011301
"edt_conf_processing_powerLimit_title": "Beperk het uitgangsvermogen",
13021302
"edt_conf_processing_powerLimit_expl": "Deze functie controleert of het totale opgenomen vermogen voor de huidige scène is overschreden. Zo ja, dan worden de helderheid en kleur van elke LED automatisch verlaagd. <strong>Let op: dit is geen vervanging voor een voldoende krachtige voeding.</strong> Deze functie is alleen bedoeld om overmatige helderheid te beperken en beschermt uw apparatuur niet tegen schade door een te kleine voeding. We garanderen niet dat deze functie direct leidt tot het beperken van het vermogen van de LED-opstelling tot een specifiek wattage.",
1303-
"edt_conf_smoothing_testMode_title": "Testmodus",
13041303
"edt_conf_smoothing_testMode_expl": "Cyclische, plotselinge kleurveranderingen voor het testen van smoothing-algoritmen, uitvoer naar de console (in Windows: voer HyperHDR uit met de parameter -c).",
13051304
"edt_conf_enum_interpolator_ExponentialInterpolator_title": "Exponentiële oneindige interpolator",
13061305
"edt_conf_enum_interpolator_ExponentialInterpolator_expl": "De klassieke exponentiële implementatie van smoothing werkt de LED-kleuren bij in de richting van een doel, reageert snel op grote verschillen en vertraagt ​​naarmate de kleuren het doel naderen, wat zorgt voor vloeiende, natuurlijke overgangen in de omgevingsverlichting.",

0 commit comments

Comments
 (0)