@sailingrotevista/rotevista-dash 7.0.24 → 7.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/app.js +21 -3
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -419,8 +419,9 @@ function processIncomingData(path, val, source, timeMs) {
419
419
  const variation = store.raw["navigation.magneticVariation"] || 0; // Legge la declinazione magnetica del GPS
420
420
  const calculatedTrueHdg = (val + variation + 2 * Math.PI) % (2 * Math.PI);
421
421
 
422
- // Registriamo il valore calcolato come Prua Vera temporanea
422
+ // Registriamo il valore calcolato come Prua Vera temporanea e aggiorniamo il timestamp per evitare i timeout del watchdog
423
423
  store.raw["navigation.headingTrue"] = calculatedTrueHdg;
424
+ store.timestamps["navigation.headingTrue"] = now; // (AGGIUNTO - RISOLVE IL LOCKOUT)
424
425
  safePush(store.smoothBuf.hdg, calculatedTrueHdg, now);
425
426
  safePush(store.longBuf.hdg, calculatedTrueHdg, now);
426
427
  }
@@ -436,6 +437,7 @@ function processIncomingData(path, val, source, timeMs) {
436
437
  const sog = store.raw["navigation.speedOverGround"] || 0;
437
438
  if (!hasCompass && sog > 0.77) { // 0.77 m/s = 1.5 nodi
438
439
  store.raw["navigation.headingTrue"] = val;
440
+ store.timestamps["navigation.headingTrue"] = now; // (AGGIUNTO - RISOLVE IL LOCKOUT COG)
439
441
  safePush(store.smoothBuf.hdg, val, now);
440
442
  safePush(store.longBuf.hdg, val, now);
441
443
  }
@@ -514,11 +516,27 @@ function updateWindTrend() {
514
516
  // Abbiamo eseguito una vera strambata stabile e siamo usciti dalla zona di poppa secca!
515
517
  lastGybeSide = currentTack;
516
518
 
519
+ // Estraggo i dati correnti di vento reale (TWS), velocità (SOG) e l'angolo TWA smorzato
520
+ const twsKts = store.raw["environment.wind.speedTrue"] ? msToKts(store.raw["environment.wind.speedTrue"]) : 0;
521
+ const sogKts = msToKts(store.raw["navigation.speedOverGround"] || 0);
522
+ const twaDeg = Math.abs(smoothedTwaDeg);
523
+
524
+ // RILEVAMENTO AERODINAMICO MOTORE IN POPPA:
525
+ // Se siamo di poppa (TWA > 135°) e la velocità della barca supera il 75% della velocità del vento reale,
526
+ // è fisicamente impossibile essere a vela pura. Siamo a motore o in motorsailing.
527
+ const isMotoringDownwind = (twaDeg > 135) && (sogKts > (twsKts * 0.75));
528
+
529
+ // L'allarme strambata acustico è reale e attivo solo se:
530
+ // 1. C'è vento significativo (> 7.0 nodi)
531
+ // 2. La barca è in movimento (> 1.0 nodi)
532
+ // 3. NON siamo a motore/motorsailing (isMotoringDownwind è falso)
533
+ const isGybeDangerous = twsKts > 7.0 && sogKts > 1.0 && !isMotoringDownwind;
534
+
517
535
  // Attivazione allarme acustico con blocco temporale di sicurezza (60 secondi)
518
- if (isNavigating && (now - lastGybeAlarmTime > 60000)) {
536
+ if (isGybeDangerous && (now - lastGybeAlarmTime > 60000)) {
519
537
  lastGybeAlarmTime = now;
520
538
  playGybeAlarm();
521
- console.log(`⚠️ GYBE ALARM TRIGGERED: Tack switched to ${currentTack} (TWA: ${smoothedTwaDeg.toFixed(1)}°)`);
539
+ console.log(`⚠️ GYBE ALARM TRIGGERED: Tack switched to ${currentTack} (TWA: ${twaDeg.toFixed(1)}°, TWS: ${twsKts.toFixed(1)}kts, SOG: ${sogKts.toFixed(1)}kts)`);
522
540
  }
523
541
  }
524
542
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailingrotevista/rotevista-dash",
3
- "version": "7.0.24",
3
+ "version": "7.0.27",
4
4
  "description": "Wind Dashboard with navigation and course aids",
5
5
  "main": "index.js",
6
6
  "publishConfig": {