Show max FPS hint in target editor, fix gradient sharing for multi-target

- Add dynamic "Hardware max ≈ N fps" recommendation below FPS slider,
  computed from LED count (WLED: protocol timing) or baud rate (serial).
  Reuses shared _computeMaxFps from devices.js with named constants.
- Fix gradient looking different across targets sharing the same stream:
  configure() now uses max LED count across all consumers; _fit_to_device
  uses np.interp linear interpolation instead of truncate/tile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-22 01:27:57 +03:00
parent 27575930b8
commit 1d5f542603
7 changed files with 66 additions and 20 deletions

View File

@@ -12,7 +12,7 @@ import { API_BASE, getHeaders, fetchWithAuth, escapeHtml } from '../core/api.js'
import { t } from '../core/i18n.js';
import { showToast, showConfirm } from '../core/ui.js';
import { Modal } from '../core/modal.js';
import { createDeviceCard, attachDeviceListeners, fetchDeviceBrightness } from './devices.js';
import { createDeviceCard, attachDeviceListeners, fetchDeviceBrightness, _computeMaxFps } from './devices.js';
import { createKCTargetCard, connectKCWebSocket, disconnectKCWebSocket } from './kc-targets.js';
import { createColorStripCard } from './color-strips.js';
@@ -93,6 +93,23 @@ function _autoGenerateTargetName() {
document.getElementById('target-editor-name').value = `${deviceName} \u00b7 ${cssName}`;
}
function _updateFpsRecommendation() {
const el = document.getElementById('target-editor-fps-rec');
const deviceSelect = document.getElementById('target-editor-device');
const device = _targetEditorDevices.find(d => d.id === deviceSelect.value);
if (!device || !device.led_count) {
el.style.display = 'none';
return;
}
const fps = _computeMaxFps(device.baud_rate, device.led_count, device.device_type);
if (fps !== null) {
el.textContent = t('targets.fps.rec', { fps, leds: device.led_count });
el.style.display = '';
} else {
el.style.display = 'none';
}
}
function _updateStandbyVisibility() {
const deviceSelect = document.getElementById('target-editor-device');
const standbyGroup = document.getElementById('target-editor-standby-group');
@@ -167,12 +184,13 @@ export async function showTargetEditor(targetId = null) {
// Auto-name generation
_targetNameManuallyEdited = !!targetId;
document.getElementById('target-editor-name').oninput = () => { _targetNameManuallyEdited = true; };
deviceSelect.onchange = () => { _updateStandbyVisibility(); _autoGenerateTargetName(); };
deviceSelect.onchange = () => { _updateStandbyVisibility(); _updateFpsRecommendation(); _autoGenerateTargetName(); };
cssSelect.onchange = () => _autoGenerateTargetName();
if (!targetId) _autoGenerateTargetName();
// Show/hide standby interval based on selected device capabilities
_updateStandbyVisibility();
_updateFpsRecommendation();
targetEditorModal.snapshot();
targetEditorModal.open();