From 5064db0032704caf1ff54e63b40e9f2589e80e4f Mon Sep 17 00:00:00 2001 From: AskaEth Date: Mon, 27 Jul 2026 08:24:25 +0800 Subject: [PATCH] fix: G-force uses acceleration_z for longitudinal axis --- dashboards/g_force/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dashboards/g_force/index.html b/dashboards/g_force/index.html index ef7d2e4..5bd5af9 100644 --- a/dashboards/g_force/index.html +++ b/dashboards/g_force/index.html @@ -54,7 +54,7 @@ const M={aspect_ratio:"1:1",render_mode:"contain"}; ctx.beginPath();ctx.arc(cx,cy,r/limit,0,Math.PI*2);ctx.setLineDash([4,8]);ctx.strokeStyle='rgba(255,255,255,.08)';ctx.lineWidth=1;ctx.stroke();ctx.setLineDash([]); // G dot - const x=Math.max(-limit,Math.min(limit,ax/G)),y=Math.max(-limit,Math.min(limit,-ay/G)); + const x=Math.max(-limit,Math.min(limit,ax/G)),y=Math.max(-limit,Math.min(limit,-az/G)); const dx=cx+(x/limit)*r,dy=cy+(y/limit)*r; ctx.beginPath();ctx.arc(dx,dy,Math.max(6,r/25),0,Math.PI*2); const i=Math.sqrt(x*x+y*y)/limit; @@ -74,13 +74,13 @@ const M={aspect_ratio:"1:1",render_mode:"contain"}; // numbers ctx.fillStyle='rgba(255,255,255,.25)';ctx.font=`${Math.max(14,W/40)|0}px sans-serif`;ctx.textAlign='center'; ctx.fillText('Lat ' + (ax/G).toFixed(2) + 'G', cx, cy-r-20); - ctx.fillText('Long ' + (-ay/G).toFixed(2) + 'G', cx, cy+r+30); + ctx.fillText('Long ' + (-az/G).toFixed(2) + 'G', cx, cy+r+30); ctx.fillText('L', cx-r-14, cy+4);ctx.fillText('R', cx+r+14, cy+4); - ctx.fillText('B', cx, cy-r-4);ctx.fillText('F', cx, cy+r+18); + ctx.fillText('Brake', cx, cy-r-10);ctx.fillText('Accel', cx, cy+r+24); } function cn(){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'){ax=m.data.acceleration_x||0;ay=m.data.acceleration_y||0;az=m.data.acceleration_z||0;draw()}}catch(e){}} + ws.onmessage=(e)=>{try{const m=JSON.parse(e.data);if(m.type==='telemetry'){ax=m.data.acceleration_x||0;az=m.data.acceleration_z||0;draw()}}catch(e){}} ws.onclose=()=>{rt=setTimeout(cn,2000)}} apply();window.addEventListener('resize',()=>{apply()});cn()