transmit 창 메세지 리스트 저장불러오기 기능 추가, monitor 창 canspeed 유지기능 추가
This commit is contained in:
49
index.h
49
index.h
@@ -238,6 +238,7 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
<option value="3" selected>1 Mbps</option>
|
||||
</select>
|
||||
<button onclick="setCanSpeed()">Apply</button>
|
||||
<span id="speed-status" style="color: #11998e; font-size: 0.85em; font-weight: 600;"></span>
|
||||
</div>
|
||||
<div class="control-row">
|
||||
<button onclick="refreshFiles()">Refresh Files</button>
|
||||
@@ -274,21 +275,40 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
let canMessages = {};
|
||||
let messageOrder = [];
|
||||
|
||||
// CAN 속도 설정 저장 및 복원
|
||||
// CAN 속도 이름 매핑
|
||||
const speedNames = ['125 Kbps', '250 Kbps', '500 Kbps', '1 Mbps'];
|
||||
|
||||
// CAN 속도 설정 저장
|
||||
function saveCanSpeed() {
|
||||
const speed = document.getElementById('can-speed').value;
|
||||
try {
|
||||
localStorage.setItem('canSpeed', speed);
|
||||
} catch(e) {}
|
||||
console.log('Saved CAN speed:', speedNames[speed]);
|
||||
} catch(e) {
|
||||
console.error('Failed to save CAN speed:', e);
|
||||
}
|
||||
}
|
||||
|
||||
// CAN 속도 설정 복원
|
||||
function loadCanSpeed() {
|
||||
try {
|
||||
const savedSpeed = localStorage.getItem('canSpeed');
|
||||
if (savedSpeed !== null) {
|
||||
document.getElementById('can-speed').value = savedSpeed;
|
||||
console.log('Restored CAN speed:', speedNames[savedSpeed]);
|
||||
|
||||
// 복원되었음을 표시
|
||||
const statusSpan = document.getElementById('speed-status');
|
||||
if (statusSpan) {
|
||||
statusSpan.textContent = '(Restored: ' + speedNames[savedSpeed] + ')';
|
||||
setTimeout(() => {
|
||||
statusSpan.textContent = '';
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
} catch(e) {}
|
||||
} catch(e) {
|
||||
console.error('Failed to load CAN speed:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function initWebSocket() {
|
||||
@@ -461,7 +481,25 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
|
||||
function setCanSpeed() {
|
||||
const speed = document.getElementById('can-speed').value;
|
||||
const speedName = speedNames[speed];
|
||||
|
||||
ws.send(JSON.stringify({cmd: 'setSpeed', speed: parseInt(speed)}));
|
||||
|
||||
// 설정 저장
|
||||
saveCanSpeed();
|
||||
|
||||
// 적용 완료 표시
|
||||
const statusSpan = document.getElementById('speed-status');
|
||||
if (statusSpan) {
|
||||
statusSpan.textContent = '✓ Applied: ' + speedName;
|
||||
statusSpan.style.color = '#11998e';
|
||||
|
||||
setTimeout(() => {
|
||||
statusSpan.textContent = '';
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
console.log('CAN speed set to:', speedName);
|
||||
}
|
||||
|
||||
function refreshFiles() {
|
||||
@@ -480,6 +518,11 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||
window.location.href = '/download?file=' + encodeURIComponent(filename);
|
||||
}
|
||||
|
||||
// 페이지 로드 시 저장된 CAN speed 복원
|
||||
window.addEventListener('load', function() {
|
||||
loadCanSpeed();
|
||||
});
|
||||
|
||||
initWebSocket();
|
||||
setTimeout(() => { refreshFiles(); }, 2000);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user