-
-
-
-
×1000 rpm
-
-
-
-
0
-
KM/H
+
+
+
+
-
-
-
1
-
-
-
diff --git a/dashboards/gear_indicator/index.html b/dashboards/gear_indicator/index.html
index 8aef3a0..3dafb85 100644
--- a/dashboards/gear_indicator/index.html
+++ b/dashboards/gear_indicator/index.html
@@ -6,71 +6,53 @@
TurboSu - 档位
diff --git a/dashboards/speedometer/index.html b/dashboards/speedometer/index.html
index 7e82ced..7ce9227 100644
--- a/dashboards/speedometer/index.html
+++ b/dashboards/speedometer/index.html
@@ -5,21 +5,19 @@
TurboSu - 速度表
@@ -31,44 +29,28 @@ html,body{width:100%;height:100%;overflow:hidden;background:#000;color:#fff;font
diff --git a/dashboards/tachometer/index.html b/dashboards/tachometer/index.html
index b4bfed4..ed7c1b2 100644
--- a/dashboards/tachometer/index.html
+++ b/dashboards/tachometer/index.html
@@ -5,35 +5,29 @@
TurboSu - 转速表
@@ -44,28 +38,24 @@ const M={aspect_ratio:"16:9",render_mode:"contain"};
const proto=location.protocol==='https:'?'wss:':'ws:',wsUrl=proto+'//'+location.host+'/ws';
let ws,rt;
- function parseRatio(r){if(!r||r==='auto')return null;const p=r.split(':');if(p.length===2){const w=+p[0],h=+p[1];if(w>0&&h>0)return w/h;}return null;}
+ function parseRatio(r){if(!r||r==='auto')return null;const p=r.split(':');if(p.length===2){const w=+p[0],h=+p[1];return w/h}return null}
function apply(){
const ratio=parseRatio(M.aspect_ratio||'16:9'),mode=M.render_mode||'contain';
- if(!ratio){box.style.width='100vw';box.style.height='100vh';box.className='fill';return;}
+ if(!ratio){box.style.width='100vw';box.style.height='100vh';box.className='fill';return}
const vw=window.innerWidth,vh=window.innerHeight,vr=vw/vh;let cw,ch;
- switch(mode){
- case'cover':if(vr>ratio){cw=vw;ch=vw/ratio}else{ch=vh;cw=vh*ratio};box.className='cover';break;
- case'fill':box.style.width='100vw';box.style.height='100vh';box.className='fill';return;
- case'center':cw=Math.min(vw,1920);ch=cw/ratio;if(ch>vh){ch=Math.min(vh,1080);cw=ch*ratio};box.className='center';break;
- default:if(vr>ratio){ch=vh;cw=vh*ratio}else{cw=vw;ch=vw/ratio};box.className='contain';
- }
- if(mode!=='fill'){box.style.width=cw+'px';box.style.height=ch+'px';}
+ if(mode==='cover'){cw=vw;ch=vw/ratio;box.className='cover'}
+ else{box.className='contain';cw=vr>ratio?vh*ratio:vw;ch=vr>ratio?vh:vw/ratio}
+ box.style.width=cw+'px';box.style.height=ch+'px'
}
function connect(){
- ws=new WebSocket(wsUrl);ws.onopen=()=>{if(rt){clearTimeout(rt);rt=null}};
- ws.onmessage=(e)=>{try{const m=JSON.parse(e.data);if(m.type==='telemetry'){const d=m.data,rpm=d.rpm||0,max=d.max_rpm||8000,pct=Math.min(rpm/max,1);rpmV.textContent=rpm.toFixed(0);arc.setAttribute('stroke-dashoffset',314-314*pct)}}catch(e){}};
- ws.onclose=()=>{rt=setTimeout(connect,2000)};
+ ws=new WebSocket(wsUrl);ws.onopen=()=>{if(rt){clearTimeout(rt);rt=null}}
+ ws.onmessage=(e)=>{try{const m=JSON.parse(e.data);if(m.type==='telemetry'){const d=m.data,rpm=d.rpm||0,max=d.max_rpm||8000,pct=Math.min(rpm/max,1);rpmV.textContent=rpm.toFixed(0);arc.setAttribute('stroke-dashoffset',440-440*pct)}}catch(e){}}
+ ws.onclose=()=>{rt=setTimeout(connect,2000)}
}
- apply();window.addEventListener('resize',apply);connect();
+ apply();window.addEventListener('resize',apply);connect()
})();