@@ -391,9 +391,9 @@ const d=new DataView(buf);
391391const ax=d.getFloat32(7,1),ay=d.getFloat32(11,1),wz=d.getFloat32(19,1),sp=d.getFloat32(51,1),mo=d.getUint8(55);
392392const lat=d.getFloat32(56,1),lon=d.getFloat32(60,1),gpsOk=d.getUint8(64);
393393const latg=ay/9.81,lng=-ax/9.81,yaw=Math.abs(wz*57.3);
394- // EMA filter for smooth speed display (like car speedometer)
395- speed_ema=0.4 *sp+(1-0.4 )*speed_ema;
396- const dspd=speed_ema<3 ?0:Math.round(speed_ema);
394+ // EMA filter - alpha=0.7 for responsive yet smooth display
395+ speed_ema=0.7 *sp+(1-0.7 )*speed_ema;
396+ const dspd=speed_ema<1 ?0:Math.round(speed_ema);
397397$('mode').textContent=M[mo]||'IDLE';$('mode').className='mode-val '+(C[mo]||'m-idle');$('icon').textContent=I[mo]||'●';
398398$('spd').textContent=dspd;$('latg').textContent=latg.toFixed(2);$('lng').textContent=lng.toFixed(2);
399399$('yaw').textContent=yaw.toFixed(0);
@@ -414,12 +414,8 @@ cnt++;
414414if(rec)data.push({t:Date.now(),sp,ax,ay,wz,mo,latg,lng,lat,lon,gpsOk});
415415}
416416
417- // HTTP polling - interval optimized for WiFi latency
418- let polling=0,skips=0;
417+ // HTTP polling - self-scheduling for maximum throughput
419418async function poll(){
420- if(polling){skips++;return} // Skip if previous poll still running
421- polling=1;
422- const start=Date.now();
423419try{
424420const r=await fetch('/api/telemetry');
425421const j=await r.json();
@@ -430,8 +426,8 @@ for(let i=0;i<b.length;i++)a[i]=b.charCodeAt(i);
430426process(a.buffer);
431427$('dot').className='dot on';$('stxt').textContent='HTTP';
432428}
433- }catch(e){$('dot').className='dot';$('stxt').textContent='Offline'}
434- polling=0;
429+ setTimeout(poll,5); // Immediately schedule next poll
430+ }catch(e){$('dot').className='dot';$('stxt').textContent='Offline';setTimeout(poll,500)} // Retry slower on error
435431}
436432
437433// Reset button: resets G max, speed max, timer, and triggers calibration
@@ -570,8 +566,8 @@ selectPreset('city');
570566}
571567}
572568
573- // Load settings, then start polling (40ms interval accounts for WiFi/HTTP overhead )
574- loadCfg().then(()=>setInterval( poll,40 ));
569+ // Load settings, then start polling (self-scheduling for max throughput )
570+ loadCfg().then(()=>poll( ));
575571</script></body></html>"# ;
576572
577573impl TelemetryServer {
0 commit comments