백라이트 즉시 적용 동작 개선
This commit is contained in:
+48
-16
@@ -70,6 +70,9 @@
|
||||
fanApplying: false,
|
||||
fanApplyTimer: null,
|
||||
fanApplyPending: null,
|
||||
touchRuntimeApplying: false,
|
||||
touchRuntimeTimer: null,
|
||||
touchRuntimePending: null,
|
||||
latestFanPwm: 0,
|
||||
fanCauseTick: 0,
|
||||
dmesgOpen: false,
|
||||
@@ -208,8 +211,6 @@
|
||||
touchBacklight: 'Backlight',
|
||||
touchBrightness: 'Brightness',
|
||||
touchBacklightEnabled: 'Backlight power',
|
||||
touchRuntimeSave: 'Apply brightness now',
|
||||
touchRuntimeSaved: 'Brightness applied.',
|
||||
touchDisplayOverlay: 'Manual overlay',
|
||||
touchDisplayAutoDetect: 'Auto detect',
|
||||
touchDisplayEnabled: 'LCD output',
|
||||
@@ -384,8 +385,6 @@
|
||||
touchBacklight: '백라이트',
|
||||
touchBrightness: '밝기',
|
||||
touchBacklightEnabled: '백라이트 전원',
|
||||
touchRuntimeSave: '밝기 즉시 적용',
|
||||
touchRuntimeSaved: '밝기를 적용했습니다.',
|
||||
touchDisplayOverlay: '수동 overlay',
|
||||
touchDisplayAutoDetect: '자동 감지',
|
||||
touchDisplayEnabled: 'LCD 출력',
|
||||
@@ -768,10 +767,6 @@
|
||||
${numberField('touch_sizex', t('touchSizeX'), config.touch_sizex || 800, 100, 4096)}
|
||||
${numberField('touch_sizey', t('touchSizeY'), config.touch_sizey || 480, 100, 4096)}
|
||||
</div>
|
||||
<div class="settings-inline-actions">
|
||||
<button id="touchDisplaySave" class="btn" type="button">${escapeHtml(t('touchDisplaySave'))}</button>
|
||||
<span class="settings-note">/boot/firmware/config.txt, /boot/firmware/cmdline.txt</span>
|
||||
</div>
|
||||
${backlight.available ? `
|
||||
<div class="touch-runtime-box">
|
||||
<h4>${escapeHtml(t('touchBacklight'))}</h4>
|
||||
@@ -784,12 +779,12 @@
|
||||
</div>
|
||||
${checkboxField('backlight_enabled', t('touchBacklightEnabled'), backlight.enabled !== false).replaceAll('data-display-key', 'data-display-runtime-key')}
|
||||
</div>
|
||||
<div class="settings-inline-actions">
|
||||
<button id="touchRuntimeSave" class="btn secondary" type="button">${escapeHtml(t('touchRuntimeSave'))}</button>
|
||||
<span class="settings-note">${escapeHtml(backlight.path || '')}</span>
|
||||
</div>
|
||||
</div>
|
||||
` : ''}
|
||||
<div class="settings-inline-actions">
|
||||
<button id="touchDisplaySave" class="btn" type="button">${escapeHtml(t('touchDisplaySave'))}</button>
|
||||
<span class="settings-note">/boot/firmware/config.txt, /boot/firmware/cmdline.txt</span>
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
}
|
||||
@@ -907,13 +902,29 @@
|
||||
});
|
||||
});
|
||||
$('#touchDisplaySave', els.settingsBody)?.addEventListener('click', saveTouchDisplaySettings);
|
||||
$('#touchRuntimeSave', els.settingsBody)?.addEventListener('click', saveTouchDisplayRuntime);
|
||||
const brightnessSlider = els.settingsBody.querySelector('[data-display-runtime-key="brightness"]');
|
||||
const brightnessValue = $('#touchBrightnessValue', els.settingsBody);
|
||||
brightnessSlider?.addEventListener('input', () => {
|
||||
if (brightnessValue) {
|
||||
brightnessValue.textContent = `${brightnessSlider.value} / ${brightnessSlider.max}`;
|
||||
}
|
||||
scheduleTouchDisplayRuntimeApply();
|
||||
});
|
||||
brightnessSlider?.addEventListener('change', scheduleTouchDisplayRuntimeApply);
|
||||
const backlightToggle = els.settingsBody.querySelector('[data-display-runtime-key="backlight_enabled"]');
|
||||
backlightToggle?.addEventListener('change', () => {
|
||||
if (!backlightToggle.checked && brightnessSlider) {
|
||||
brightnessSlider.value = '0';
|
||||
if (brightnessValue) {
|
||||
brightnessValue.textContent = `0 / ${brightnessSlider.max}`;
|
||||
}
|
||||
} else if (backlightToggle.checked && brightnessSlider && Number(brightnessSlider.value) <= 0) {
|
||||
brightnessSlider.value = brightnessSlider.max || '255';
|
||||
if (brightnessValue) {
|
||||
brightnessValue.textContent = `${brightnessSlider.value} / ${brightnessSlider.max}`;
|
||||
}
|
||||
}
|
||||
scheduleTouchDisplayRuntimeApply();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -972,6 +983,9 @@
|
||||
? (input.checked ? '1' : '0')
|
||||
: input.value;
|
||||
});
|
||||
if (values.backlight_enabled === '0') {
|
||||
values.brightness = '0';
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -994,18 +1008,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function saveTouchDisplayRuntime() {
|
||||
function scheduleTouchDisplayRuntimeApply(values = currentTouchDisplayRuntimeValues()) {
|
||||
clearTimeout(state.touchRuntimeTimer);
|
||||
state.touchRuntimeTimer = setTimeout(() => {
|
||||
applyTouchDisplayRuntime(values);
|
||||
}, 150);
|
||||
}
|
||||
|
||||
async function applyTouchDisplayRuntime(values = currentTouchDisplayRuntimeValues()) {
|
||||
if (state.touchRuntimeApplying) {
|
||||
state.touchRuntimePending = values;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
state.touchRuntimeApplying = true;
|
||||
const data = await api('touch_display_runtime_save', {
|
||||
runtime: JSON.stringify(currentTouchDisplayRuntimeValues()),
|
||||
runtime: JSON.stringify(values),
|
||||
});
|
||||
state.settingsDirty = false;
|
||||
state.touchRuntimeApplying = false;
|
||||
render(data);
|
||||
renderSettings(data.settings, { force: true });
|
||||
notice(t('touchRuntimeSaved'), 'success');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
notice(e.message || t('settingsSaveFailed'), 'error');
|
||||
} finally {
|
||||
state.touchRuntimeApplying = false;
|
||||
const pending = state.touchRuntimePending;
|
||||
state.touchRuntimePending = null;
|
||||
if (pending) applyTouchDisplayRuntime(pending);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user