Skip to content

Commit

Permalink
New JSON API method to update smoothing parameters (#352)
Browse files Browse the repository at this point in the history
* JSON API method that updates smoothing parameters

* Update lang resources

* Set smoothing on the same thread
  • Loading branch information
awawa-dev authored Mar 24, 2023
1 parent 14503f1 commit 6a6b29d
Show file tree
Hide file tree
Showing 27 changed files with 229 additions and 7 deletions.
60 changes: 59 additions & 1 deletion assets/webconfig/content/json_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,65 @@ <h4 class="bs-main-text" data-i18n="conf_helptable_expl">Explanation</h4>
</div>
</div>
</div>

<div class="card card-default col-12 col-xl-11 col-xxl-10 text-start">
<div class="card-header"><i class="fa fa-podcast fa-fw"></i><span data-i18n="json_api_smoothing"></span></div>
<div class="card-body" >
<div class="w-100" >
<div class="row">
<div class="col-12 col-lg-6">
<div class="row">
<div class="col-12 text-start">
<div class="callout callout-info">
<h4 class="bs-main-text" data-i18n="conf_helptable_expl">Explanation</h4>
<span data-i18n="json_api_smoothing_expl"></span>
</div>
</div>
</div>
<div class="row">
<div class="col-8 text-start">
<div class="form-check">
<input class="form-check-input" type="radio" name="api_smoothing_target" id="api_smoothing_target_all_id" value="all">
<label class="form-check-label" for="api_smoothing_target_all_id" data-i18n="json_api_all_instances"></label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="api_smoothing_target" id="api_smoothing_target_single_id" value="single">
<label class="form-check-label" for="api_smoothing_target_single_id" data-i18n="json_api_single_instance"></label>
</div>
</div>
</div>
<div class="row mt-2">
<div class="col-8 text-start">
<div class="input-group">
<span class="input-group-text mb-1" data-i18n="edt_conf_smooth_time_ms_title"></span>
<input class="form-control mb-1" type="number" id="json_api_smoothing_time" value="">
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="form-group">
<textarea class="form-control" id="smoothingControl_json" rows="8" placeholder="JSON output" readonly></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer">
<div class="d-flex flex-row-reverse bd-highlight mb-3">
<div class="ms-2">
<button type="button" name="smoothingControlButtons" onclick='CopyLink($("#smoothingControl_json"))' class="disabled btn btn-primary"><span data-i18n="json_api_copy_link">Copy link</span></button>
</div>
<div class="ms-2">
<button type="button" name="smoothingControlButtons" onclick='CopyJson($("#smoothingControl_json"))' class="disabled btn btn-secondary"><span data-i18n="json_api_copy_json">Copy json</span></button>
</div>
<div class="ms-2">
<button type="button" name="smoothingControlButtons" onclick='RunIt($("#smoothingControl_json"))' class="disabled btn btn-danger"><span data-i18n="json_api_run_it">Run it</span></button>
</div>
</div>
</div>
</div>
</div>
<script>
$.getScript("/js/json_api.js");
</script>
</script>
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Jasná priorita z efektů a přednastavených barev.",
"json_api_hdr": "Režim HDR",
"json_api_hdr_expl": "Zapnutí/vypnutí mapování tónu HDR pro USB grabber. „Border mode“ funguje pouze pro stream MJPEG.",
"json_api_smoothing": "Vyhlazující ovládání",
"json_api_smoothing_expl": "Metoda umožňuje volatilní modifikaci vyhlazovacích parametrů pro všechny nebo jednotlivé instance.",
"json_api_all_instances": "Všechny případy",
"json_api_single_instance": "Jediná instance",
"led_editor_context_move": "Přestěhovat se",
"led_editor_context_properties": "Vlastnosti",
"led_editor_context_delete": "Vymazat",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Klare Priorität von Effekten und voreingestellten Farben.",
"json_api_hdr": "HDR-Modus",
"json_api_hdr_expl": "Schalten Sie das HDR-Tone-Mapping für den USB-Grabber ein/aus. Der 'Grenzmodus' funktioniert nur für MJPEG-Streams.",
"json_api_smoothing": "Glättungssteuerung",
"json_api_smoothing_expl": "Das Verfahren ermöglicht eine flüchtige Modifikation von Glättungsparametern für alle oder einzelne Instanzen.",
"json_api_all_instances": "Alle Instanzen",
"json_api_single_instance": "Einzelne Instanz",
"led_editor_context_move": "Bewegen",
"led_editor_context_properties": "Eigenschaften",
"led_editor_context_delete": "Löschen",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,10 @@
"edt_conf_mqtt_ssl_ignore_errors_expl" : "Ignore all SSL errors such as self-signed certificates etc. Use with caution.",
"json_api_flatbuffers_user_lut" : "Flatbuffers LUT filename",
"json_api_hdr_expl" : "Turn on/off HDR tone mapping. You can also pass the name of the user LUT file in the user HyperHDR home folder to be used for Flatbuffers tone mapping.",
"json_api_smoothing" : "Smoothing control",
"json_api_smoothing_expl" : "The method allows for volatile modification of smoothing parameters for all or single instances.",
"json_api_all_instances" : "All instances",
"json_api_single_instance" : "Single instance",
"led_editor_context_move": "Move",
"led_editor_context_properties": "Properties",
"led_editor_context_delete": "Delete",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Prioridad clara de efectos y colores preestablecidos.",
"json_api_hdr": "Modo HDR",
"json_api_hdr_expl": "Activa / desactiva el mapeo de tonos HDR para capturador USB. El 'modo de borde' funciona solo para la transmisión MJPEG.",
"json_api_smoothing": "Control de suavizado",
"json_api_smoothing_expl": "El método permite la modificación volátil de los parámetros de suavizado para todos los casos o para uno solo.",
"json_api_all_instances": "Todas las instancias",
"json_api_single_instance": "Única instancia",
"led_editor_context_move": "Muevete",
"led_editor_context_properties": "Propiedades",
"led_editor_context_delete": "Borrar",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Effacer la priorité des effets et des couleurs prédéfinies.",
"json_api_hdr": "Mode HDR",
"json_api_hdr_expl": "Activez/désactivez le mappage de tonalité HDR pour la capture USB. Le « mode frontière » ne fonctionne que pour le flux MJPEG.",
"json_api_smoothing": "Contrôle du lissage",
"json_api_smoothing_expl": "Le procédé permet une modification volatile des paramètres de lissage pour toutes les instances ou une seule.",
"json_api_all_instances": "Toutes les occurrences",
"json_api_single_instance": "Seule instance",
"led_editor_context_move": "Déplacer",
"led_editor_context_properties": "Propriétés",
"led_editor_context_delete": "Effacer",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Cancella priorità dagli effetti e dai colori preimpostati.",
"json_api_hdr": "Modalità HDR",
"json_api_hdr_expl": "Attiva/disattiva la mappatura dei toni HDR per USB grabber. La 'Modalità bordo' funziona solo per il flusso MJPEG.",
"json_api_smoothing": "Controllo del livellamento",
"json_api_smoothing_expl": "Il metodo consente la modifica volatile dei parametri di livellamento per tutte o singole istanze.",
"json_api_all_instances": "Tutte le istanze",
"json_api_single_instance": "Singola istanza",
"led_editor_context_move": "Spostare",
"led_editor_context_properties": "Proprietà",
"led_editor_context_delete": "Elimina",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Duidelijke prioriteit van effecten en vooraf ingestelde kleuren.",
"json_api_hdr": "HDR-modus",
"json_api_hdr_expl": "Schakel HDR-toontoewijzing voor USB-grabber in/uit. 'Border-modus' werkt alleen voor MJPEG-stream.",
"json_api_smoothing": "Vloeiende controle",
"json_api_smoothing_expl": "De methode maakt een vluchtige wijziging van afvlakkingsparameters voor alle of enkele instanties mogelijk.",
"json_api_all_instances": "Alle instanties",
"json_api_single_instance": "Enkele instantie",
"led_editor_context_move": "Beweging",
"led_editor_context_properties": "Eigendommen",
"led_editor_context_delete": "Verwijderen",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Wyczyść priorytet efektów i wstępnie ustawionych kolorów.",
"json_api_hdr": "Tryb HDR",
"json_api_hdr_expl": "Włącz/wyłącz mapowanie tonów HDR dla grabbera USB. „Tryb graniczny” działa tylko dla strumienia MJPEG.",
"json_api_smoothing": "Kontrola wygładzania",
"json_api_smoothing_expl": "Metoda pozwala na lotną modyfikację parametrów wygładzania dla wszystkich lub pojedynczych instancji.",
"json_api_all_instances": "Wszystkie instancje",
"json_api_single_instance": "Pojedyncza instancja",
"led_editor_context_move": "Przenosić",
"led_editor_context_properties": "Właściwości",
"led_editor_context_delete": "Usuwać",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Ștergeți prioritatea de la efecte și culori prestabilite.",
"json_api_hdr": "Mod HDR",
"json_api_hdr_expl": "Activați / dezactivați maparea tonurilor HDR pentru dispozitivul de captare USB. „Modul de frontieră” funcționează numai pentru fluxul MJPEG.",
"json_api_smoothing": "Control de netezire",
"json_api_smoothing_expl": "Metoda permite modificarea volatilă a parametrilor de netezire pentru toate cazurile sau pentru o singură instanță.",
"json_api_all_instances": "Toate cazurile",
"json_api_single_instance": "O singură instanță",
"led_editor_context_move": "Mutare",
"led_editor_context_properties": "Proprietăți",
"led_editor_context_delete": "Șterge",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,10 @@
"json_api_clear": "Очистить приоритет",
"json_api_clear_expl": "Очистите приоритет от эффектов и предустановленных цветов.",
"json_api_hdr": "Режим HDR",
"json_api_smoothing": "Сглаживание",
"json_api_smoothing_expl": "Метод допускает изменчивую модификацию параметров сглаживания для всех или отдельных экземпляров.",
"json_api_all_instances": "Все экземпляры",
"json_api_single_instance": "Один экземпляр",
"json_api_components_expl_multi": "Вы можете запускать несколько команд с помощью одной ссылки. Максимальная длина - 2048 символов. Все они будут выполнены, но вы получите только один ответ (просмотрите журналы для всего вывода). Просто поместите содержимое <code>request</code> ваших ссылок в формат (обратите внимание на первый символ '?' И следующие символы '&'):<br><code>http://IP:PORT/json-rpc?request=request1&request=request2&request=request3...</code>",
"edt_conf_stream_autoResume_title": "Авто возобновление",
"edt_conf_stream_autoResume_expl": "Попробуйте перезапустить захват видео, если видеопоток остановился. Используйте с осторожностью, так как это не лекарство от аппаратных проблем граббера.",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Tydlig prioritet från effekter och förinställda färger.",
"json_api_hdr": "HDR -läge",
"json_api_hdr_expl": "Slå på/av HDR -tonmappning för USB -gripare. \"Gränsläge\" fungerar endast för MJPEG -ström.",
"json_api_smoothing": "Utjämnande kontroll",
"json_api_smoothing_expl": "Metoden möjliggör flyktig modifiering av utjämningsparametrar för alla eller enstaka instanser.",
"json_api_all_instances": "Alla instanser",
"json_api_single_instance": "Enstaka instans",
"led_editor_context_move": "Flytta",
"led_editor_context_properties": "Egenskaper",
"led_editor_context_delete": "Radera",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Efektlerden ve önceden ayarlanmış renklerden önceliği temizleyin.",
"json_api_hdr": "HDR modu",
"json_api_hdr_expl": "USB yakalayıcı için HDR ton eşlemesini açın/kapatın. 'Sınır modu' yalnızca MJPEG akışı için çalışır.",
"json_api_smoothing": "Yumuşatma kontrolü",
"json_api_smoothing_expl": "Yöntem, tüm veya tek örnekler için yumuşatma parametrelerinin geçici olarak değiştirilmesine izin verir.",
"json_api_all_instances": "Tüm örnekler",
"json_api_single_instance": "Tek örnek",
"led_editor_context_move": "Hareket",
"led_editor_context_properties": "Özellikleri",
"led_editor_context_delete": "Silmek",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "Ưu tiên rõ ràng khỏi các hiệu ứng và màu đặt trước.",
"json_api_hdr": "Chế độ HDR",
"json_api_hdr_expl": "Bật / tắt ánh xạ giai điệu HDR cho bộ lấy USB. 'Chế độ viền' chỉ hoạt động cho luồng MJPEG.",
"json_api_smoothing": "kiểm soát làm mịn",
"json_api_smoothing_expl": "Phương pháp này cho phép sửa đổi không ổn định các tham số làm mịn cho tất cả hoặc các trường hợp đơn lẻ.",
"json_api_all_instances": "Tất cả các trường hợp",
"json_api_single_instance": "Trường hợp duy nhất",
"led_editor_context_move": "Di chuyển",
"led_editor_context_properties": "Đặc tính",
"led_editor_context_delete": "Xóa bỏ",
Expand Down
4 changes: 4 additions & 0 deletions assets/webconfig/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,10 @@
"json_api_clear_expl": "清除效果和预设颜色的优先级。",
"json_api_hdr": "HDR模式",
"json_api_hdr_expl": "打开/关闭 USB 采集卡的 HDR 色调映射。 “边框模式”仅适用于 MJPEG 流。",
"json_api_smoothing": "平滑控制",
"json_api_smoothing_expl": "该方法允许对所有或单个实例的平滑参数进行可变修改。",
"json_api_all_instances": "所有实例",
"json_api_single_instance": "单实例",
"led_editor_context_move": "移动",
"led_editor_context_properties": "特性",
"led_editor_context_delete": "删除",
Expand Down
39 changes: 37 additions & 2 deletions assets/webconfig/js/json_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ function BuildHdrJson()

var state = $('input[name="hdrModeState"]:checked').val();
var flatbufferUserLut = $('#flatbuffersUserLut').val();
var finJson = componentHdr.replace("{0}", state).replace("{1}", flatbufferUserLut);
var finJson = (flatbufferUserLut.length > 0) ? componentHdr.replace("{0}", state).replace("{1}", flatbufferUserLut) :
componentHdr.replace("{0},", state).replace('"flatbuffers_user_lut_filename":"{1}"', "");

$("#hdrMode_json").html(finJson);
}
Expand Down Expand Up @@ -591,4 +592,38 @@ function BuildVControlJson()
}

///////////////////////////////////////////////////////////////////////////////////////////////
});

var smoothingControl =
`{
"command":"smoothing",
"subcommand":"{0}",
"time":{1}
}`;

$('input[name="api_smoothing_target"], #json_api_smoothing_time').change(
function(){
BuildSmoothingJson();
});

$('#json_api_smoothing_time').keyup(
function(){
BuildSmoothingJson();
});

function BuildSmoothingJson()
{
if ($("input[name='api_smoothing_target']:checked").val() && !isNaN($("#json_api_smoothing_time").val()) && $("#json_api_smoothing_time").val() >= 25)
{
$('button[name="smoothingControlButtons"]').each(function(i, obj) {
$(this).removeClass('disabled');
});

var target = $('input[name="api_smoothing_target"]:checked').val();
var time = $('#json_api_smoothing_time').val();
var finJson = smoothingControl.replace("{0}", target).replace("{1}", time);

$("#smoothingControl_json").html(finJson);
}
}

});
2 changes: 2 additions & 0 deletions include/api/JsonAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ private slots:

void handleBenchmarkCommand(const QJsonObject& message, const QString& command, int tan);

void handleSmoothingCommand(const QJsonObject& message, const QString& command, int tan);

void handleTunnel(const QJsonObject& message, const QString& command, int tan);

///
Expand Down
2 changes: 2 additions & 0 deletions include/base/HyperHdrIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class HyperHdrIManager : public QObject
bool areInstancesReady();

public slots:
void setSmoothing(int time);

bool isCEC();

void setSignalStateByCEC(bool enable);
Expand Down
1 change: 1 addition & 0 deletions include/base/HyperHdrInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class HyperHdrInstance : public QObject

public slots:

void setSmoothing(int time);
void identifyLed(const QJsonObject& params);

bool getReadOnlyMode() { return _readOnlyMode; };
Expand Down
2 changes: 2 additions & 0 deletions include/base/LinearSmoothing.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public slots:
/// @return The index of the cfg which can be passed to selectConfig()
///
unsigned updateConfig(unsigned cfgID, int settlingTime_ms, double ledUpdateFrequency_hz, bool directModee);

void updateCurrentConfig(int settlingTime_ms);
private:

/**
Expand Down
28 changes: 28 additions & 0 deletions sources/api/JSONRPC_schema/schema-smoothing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"type":"object",
"required":true,
"properties":
{
"command":
{
"type" : "string",
"required" : true,
"enum" : ["smoothing"]
},
"subcommand": {
"type" : "string",
"required" : true,
"enum" : ["all", "single"]
},
"tan" : {
"type" : "integer"
},
"time": {
"type" : "integer",
"minimum" : 25,
"maximum" : 5000,
"required": true
}
},
"additionalProperties": false
}
2 changes: 1 addition & 1 deletion sources/api/JSONRPC_schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"command": {
"type" : "string",
"required" : true,
"enum": [ "color", "tunnel", "benchmark", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "load-db", "save-db", "logging", "performance-counters", "lut-calibration", "signal-calibration", "processing", "sysinfo", "videomodehdr", "video-crop", "videomode", "authorize", "instance", "leddevice", "transform", "correction", "temperature", "help", "video-controls" ]
"enum": [ "color", "tunnel", "smoothing", "benchmark", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "load-db", "save-db", "logging", "performance-counters", "lut-calibration", "signal-calibration", "processing", "sysinfo", "videomodehdr", "video-crop", "videomode", "authorize", "instance", "leddevice", "transform", "correction", "temperature", "help", "video-controls" ]
}
}
}
7 changes: 4 additions & 3 deletions sources/api/JSONRPC_schemas.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
<file alias="schema-instance">JSONRPC_schema/schema-instance.json</file>
<file alias="schema-leddevice">JSONRPC_schema/schema-leddevice.json</file>
<file alias="schema-benchmark">JSONRPC_schema/schema-benchmark.json</file>
<file alias="schema-tunnel">JSONRPC_schema/schema-tunnel.json</file>
<file alias="schema-performance-counters">JSONRPC_schema/schema-performance-counters.json</file>
<!-- The following schemas are derecated but used to ensure backward compatibility with Classic remote control-->
<file alias="schema-tunnel">JSONRPC_schema/schema-tunnel.json</file>
<file alias="schema-performance-counters">JSONRPC_schema/schema-performance-counters.json</file>
<file alias="schema-smoothing">JSONRPC_schema/schema-smoothing.json</file>
<!-- The following schemas are derecated but used to ensure backward compatibility with Classic remote control-->
<file alias="schema-transform">JSONRPC_schema/schema-classic.json</file>
<file alias="schema-correction">JSONRPC_schema/schema-classic.json</file>
<file alias="schema-temperature">JSONRPC_schema/schema-classic.json</file>
Expand Down
Loading

0 comments on commit 6a6b29d

Please sign in to comment.