@sailingrotevista/rotevista-dash 6.1.2 → 6.1.4
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.
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/app.js +62 -19
- package/index.js +46 -18
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sailing Rotevista
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# @sailingrotevista/rotevista-dash
|
|
2
|
+
|
|
3
|
+
## Sailing Dashboard Pro (v6.0)
|
|
4
|
+
|
|
5
|
+
A tactical marine dashboard and advanced monitoring system for sailboats, designed to run as a Web App (PWA) fully integrated into the **Signal K** ecosystem. Specifically optimized for precision rendering on boat tablets (such as iPads and Samsung Galaxy Tab Active) and built to run efficiently on low-resource gateways like the **Victron Cerbo GX** (running Venus OS Large) or Raspberry Pi.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Core Features
|
|
10
|
+
|
|
11
|
+
### 📈 Server-Side RAM-Buffered History
|
|
12
|
+
Unlike traditional dashboards that store history in the volatile memory of the client browser (wiping it whenever the screen locks or the browser reloads), this dashboard performs continuous background logging in RAM directly within the Signal K server process. Upon startup, the client instantly loads up to 60 minutes of pre-populated history via a fast JSON API endpoint, ensuring fully drawn, stable charts from the very first second the page is opened.
|
|
13
|
+
|
|
14
|
+
### 🔋 Extreme Low-Power Architecture (Battery Saver)
|
|
15
|
+
Engineered for long-range cruising without overheating your mobile devices or draining the boat's house batteries:
|
|
16
|
+
* **Event-Driven SVG Redraw:** Complex SVG chart elements are not redrawn on a blind timer. Instead, they are redrawn *only* when a new historical data point is appended to the buffer (reducing the browser's active SVG layout and paint cycles by **93%**).
|
|
17
|
+
* **Virtual-DOM Text Protection (`safeSetText`):** Digital text readouts are updated only if their numerical value has actually changed since the previous second, bypassing expensive browser style and layout calculations (*reflow/repaint*).
|
|
18
|
+
* **Zero-Overhead Analog Needles:** Pointers (AWA, TWA, Leeway) snap instantly to their new positions at 1Hz instead of forcing continuous 60fps style interpolations, allowing the tablet's GPU to rest in a low-power idle state.
|
|
19
|
+
|
|
20
|
+
### 🧭 Weather Compass & True Wind Direction (TWD) Trends
|
|
21
|
+
* **Tactical Trend (Short-term):** Instantly detects lift or header shifts by comparing the 2-second moving average of True Wind Angle (TWA) with the 10-second average.
|
|
22
|
+
* **Strategic Trend (Long-term):** Flashing green (CW) and red (CCW) dots on the TWD mini-compass indicate meteorological wind rotations, comparing the last 1 minute of wind with a stable strategic baseline of **15 minutes** under sail or **60 minutes** at anchor.
|
|
23
|
+
* **Absolute UTC Epoch Snapping:** Time windows on both the server and any connected clients are locked to absolute UTC second boundaries (00, 10, 20, 30, 40, 50). This eliminates phase offsets and ensures identical tactical trends across all devices on the boat.
|
|
24
|
+
|
|
25
|
+
### 🛡️ Shallow Water Alarms & Geometric Safety Lines
|
|
26
|
+
* Automatically draws high-visibility dashed safety lines across the depth chart background to indicate **Warning (Yellow, e.g. 3.5m)** and **Danger (Red, e.g. 2.5m)** thresholds.
|
|
27
|
+
* **Non-Scaling Vector Effects:** By using `vector-effect="non-scaling-stroke"`, these lines and the active depth curve remain perfectly sharp, thin, and professional regardless of whether the widget is small or zoomed to full screen.
|
|
28
|
+
* **Adaptive 0-Baseline:** In shallow water, the chart minimum is locked to 0 for keel safety; in deep water, the scale floats freely (e.g., 98m to 102m) to reveal the fine contour details of the seabed.
|
|
29
|
+
|
|
30
|
+
### 🔌 Smart Source Locking (Zero-Config)
|
|
31
|
+
An intelligent background algorithm assigns priority scores to active hardware sources on your boat (e.g. Yacht Devices N2K GPS vs a generic USB GPS) and locks onto the highest-quality sensor, switching to a backup only if a signal dropout occurs.
|
|
32
|
+
|
|
33
|
+
### ⏰ Sleep & Power-Save Watchdog
|
|
34
|
+
Detects when the tablet is unlocked or the browser wakes up a tab from *Power Save* mode, automatically closing orphaned WebSockets, reconnecting, and downloading the latest server-logged history in milliseconds to resume fluid, gap-free operation.
|
|
35
|
+
|
|
36
|
+
### 🎮 Smart Local Development Auto-Detection
|
|
37
|
+
The dashboard automatically detects if it is running locally on your Mac/PC via the `file://` protocol or on `localhost`. In this mode, it still connects to your boat's Cerbo GX over Wi-Fi to stream real-time data, but **bypasses the server's configuration, preserving your local `CONFIG` edits** so you can test scales, alarms, and steps instantly.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## System Requirements
|
|
42
|
+
|
|
43
|
+
* **Server:** Signal K Node Server (v1.20.0 or higher) installed on a Victron Cerbo GX, Raspberry Pi, or onboard PC.
|
|
44
|
+
* **Client:** Any modern PWA-compliant browser supporting ES6 (Safari on iPadOS/iOS, Samsung Internet, Chrome on Android, Chrome/Safari on macOS/Windows).
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Signal K Data Requirements
|
|
49
|
+
|
|
50
|
+
### Required Foundational Paths
|
|
51
|
+
To derive, calculate, and display the entire suite of tactical data, the dashboard must receive the following raw paths from your boat's NMEA network:
|
|
52
|
+
|
|
53
|
+
* `navigation.speedThroughWater` (STW - Speed through water)
|
|
54
|
+
* `navigation.speedOverGround` (SOG - Speed over ground)
|
|
55
|
+
* `navigation.courseOverGroundTrue` (COG - Course over ground)
|
|
56
|
+
* `navigation.headingTrue` (True Heading - *If missing, the system automatically falls back to Magnetic Heading*)
|
|
57
|
+
* `environment.wind.speedApparent` (AWS - Apparent wind speed)
|
|
58
|
+
* `environment.wind.angleApparent` (AWA - Apparent wind angle)
|
|
59
|
+
* `environment.depth.belowTransducer` (Depth below keel/transducer)
|
|
60
|
+
* `navigation.position` (GPS Latitude and Longitude - used for hemisphere detection and CSV logging)
|
|
61
|
+
|
|
62
|
+
### Optional / Native Fallback Paths (Surgically Supported)
|
|
63
|
+
The dashboard operates on a **"Native First, Fallback Second"** architecture. If any of the following calculated paths are transmitted natively by your boat's instruments, the dashboard will utilize them directly to preserve their calibration. If they are missing, the system silently activates its own local vector formulas:
|
|
64
|
+
|
|
65
|
+
* `environment.wind.speedTrue` (**Optional** - Native True Wind Speed in m/s; falls back to local calculation if missing)
|
|
66
|
+
* `environment.wind.directionTrue` (**Optional** - Native True Wind Direction in radians; falls back to local calculation if missing)
|
|
67
|
+
* `navigation.headingMagnetic` (**Optional** - Magnetic Heading; automatically used if True Heading is missing on the network)
|
|
68
|
+
* `navigation.magneticVariation` (**Optional** - Magnetic Variation; used to calibrate the Magnetic Heading fallback to True)
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
The dashboard is distributed as a standard Signal K Node Server plugin and Web App.
|
|
75
|
+
|
|
76
|
+
### Installation via Signal K App Store (Recommended)
|
|
77
|
+
1. Access your Signal K admin panel (`http://<boat-ip>:3000`).
|
|
78
|
+
2. Navigate to **App Store** -> **Available**.
|
|
79
|
+
3. Search for `@sailingrotevista/rotevista-dash` and click **Install**.
|
|
80
|
+
4. Go to **Plugins Config**, activate the **Rotevista Dash Configuration** plugin, and configure your boat's safety thresholds (Draft, alarm offsets, and strategic chart timelines).
|
|
81
|
+
5. Click **Save**. The Signal K server will restart, apply the configurations, and initiate background history logging in RAM.
|
|
82
|
+
|
|
83
|
+
### Accessing the Dashboard
|
|
84
|
+
Once installed, the dashboard is accessible on your local network by typing into your tablet or computer browser:
|
|
85
|
+
```text
|
|
86
|
+
http://<boat-ip>:3000/@sailingrotevista/rotevista-dash/
|
|
87
|
+
For the best experience in the cockpit, tap your browser's share button and select "Add to Home Screen" to run it as a standalone, distraction-free application.
|
|
88
|
+
|
|
89
|
+
License
|
|
90
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
package/app.js
CHANGED
|
@@ -317,34 +317,61 @@ function updateLeewayDisplay(deg) {
|
|
|
317
317
|
ui.leewayVal.textContent = `LEEWAY: ${deg.toFixed(1)}°`;
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
/**
|
|
321
|
+
* computeTrueWind: Calcola TWS, TWA e TWD strategico.
|
|
322
|
+
* Gestisce il fallback separato (Split-Fallback) in caso di dati parzialmente nativi di bordo.
|
|
323
|
+
*/
|
|
323
324
|
function computeTrueWind() {
|
|
324
325
|
const aws = store.raw["environment.wind.speedApparent"], awa = store.raw["environment.wind.angleApparent"];
|
|
325
326
|
const stw = store.raw["navigation.speedThroughWater"] || 0, sog = store.raw["navigation.speedOverGround"] || 0;
|
|
326
327
|
const hdg = store.raw["navigation.headingTrue"] || 0, cog = store.raw["navigation.courseOverGroundTrue"] || 0;
|
|
327
328
|
if (aws === undefined || awa === undefined) return;
|
|
328
329
|
|
|
329
|
-
const tw_water_x = aws * Math.cos(awa) - stw, tw_water_y = aws * Math.sin(awa);
|
|
330
|
-
const tws_water = Math.sqrt(tw_water_x * tw_water_x + tw_water_y * tw_water_y);
|
|
331
|
-
|
|
332
|
-
const drift = (cog - hdg + Math.PI * 3) % (2 * Math.PI) - Math.PI;
|
|
333
|
-
const tw_ground_x = aws * Math.cos(awa) - sog * Math.cos(drift), tw_ground_y = aws * Math.sin(awa) - sog * Math.sin(drift);
|
|
334
|
-
const tws_ground = Math.sqrt(tw_ground_x * tw_ground_x + tw_ground_y * tw_ground_y);
|
|
335
|
-
|
|
336
330
|
// Usiamo il tempo esatto di arrivo del pacchetto del vento per la coerenza dei buffer
|
|
337
331
|
const now = store.timestamps["environment.wind.speedApparent"] || Date.now();
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
332
|
+
|
|
333
|
+
// ==========================================================================
|
|
334
|
+
// 1. GESTIONE TWS (NATIVO vs FALLBACK)
|
|
335
|
+
// ==========================================================================
|
|
336
|
+
const hasNativeTws = store.timestamps["environment.wind.speedTrue"] && (Date.now() - store.timestamps["environment.wind.speedTrue"] < 5000);
|
|
337
|
+
let tws_water = 0;
|
|
338
|
+
|
|
339
|
+
if (hasNativeTws) {
|
|
340
|
+
// Se la barca invia il TWS nativo, usiamo direttamente quello
|
|
341
|
+
tws_water = store.raw["environment.wind.speedTrue"] ? msToKts(store.raw["environment.wind.speedTrue"]) : 0;
|
|
342
|
+
} else {
|
|
343
|
+
// Altrimenti eseguiamo il calcolo vettoriale tattico sull'acqua
|
|
344
|
+
tws_water = Math.sqrt(aws * aws + stw * stw - 2 * aws * stw * Math.cos(awa));
|
|
345
|
+
store.raw["environment.wind.speedTrue"] = tws_water;
|
|
346
|
+
|
|
347
|
+
if (tws_water > 0.05) {
|
|
348
|
+
const twa = Math.atan2(aws * Math.sin(awa), aws * Math.cos(awa) - stw);
|
|
349
|
+
store.raw["environment.wind.angleTrueWater"] = twa;
|
|
350
|
+
safePush(store.smoothBuf.twa, twa, now);
|
|
351
|
+
safePush(store.longBuf.twa, twa, now);
|
|
352
|
+
}
|
|
343
353
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
354
|
+
|
|
355
|
+
// ==========================================================================
|
|
356
|
+
// 2. GESTIONE TWD (NATIVO vs FALLBACK)
|
|
357
|
+
// ==========================================================================
|
|
358
|
+
const hasNativeTwd = store.timestamps["environment.wind.directionTrue"] && (Date.now() - store.timestamps["environment.wind.directionTrue"] < 5000);
|
|
359
|
+
|
|
360
|
+
if (hasNativeTwd) {
|
|
361
|
+
// Se il TWD è nativo della centralina, lo lasciamo scorrere passivamente
|
|
362
|
+
} else {
|
|
363
|
+
// Altrimenti calcoliamo lo scarroccio e ricaviamo il TWD geografico sul fondo
|
|
364
|
+
const drift = (cog - hdg + Math.PI * 3) % (2 * Math.PI) - Math.PI;
|
|
365
|
+
const tw_ground_x = aws * Math.cos(awa) - sog * Math.cos(drift);
|
|
366
|
+
const tw_ground_y = aws * Math.sin(awa) - sog * Math.sin(drift);
|
|
367
|
+
const tws_ground = Math.sqrt(tw_ground_x * tw_ground_x + tw_ground_y * tw_ground_y);
|
|
368
|
+
|
|
369
|
+
if (tws_ground > 0.05) {
|
|
370
|
+
let twd = (hdg + Math.atan2(tw_ground_y, tw_ground_x) + 2 * Math.PI) % (2 * Math.PI);
|
|
371
|
+
store.raw["environment.wind.directionTrue"] = twd;
|
|
372
|
+
safePush(store.smoothBuf.twd, twd, now);
|
|
373
|
+
safePush(store.longBuf.twd, twd, now); // Alimenta la bussola meteo strategica!
|
|
374
|
+
}
|
|
348
375
|
}
|
|
349
376
|
}
|
|
350
377
|
|
|
@@ -414,10 +441,26 @@ function processIncomingData(path, val, source, timeMs) {
|
|
|
414
441
|
safePush(store.smoothBuf.awa, val, now);
|
|
415
442
|
safePush(store.longBuf.awa, val, now);
|
|
416
443
|
}
|
|
444
|
+
|
|
445
|
+
// --- GESTIONE PRUA VERA / MAGNETICA CON AUTODIVIAZIONE ---
|
|
417
446
|
if (path === "navigation.headingTrue") {
|
|
418
447
|
safePush(store.smoothBuf.hdg, val, now);
|
|
419
448
|
safePush(store.longBuf.hdg, val, now);
|
|
420
449
|
}
|
|
450
|
+
else if (path === "navigation.headingMagnetic") {
|
|
451
|
+
// Se non abbiamo ricevuto una prua vera negli ultimi 5 secondi, convertiamo quella magnetica!
|
|
452
|
+
const hasTrueHdg = store.timestamps["navigation.headingTrue"] && (now - store.timestamps["navigation.headingTrue"] < 5000);
|
|
453
|
+
if (!hasTrueHdg) {
|
|
454
|
+
const variation = store.raw["navigation.magneticVariation"] || 0; // Legge la declinazione magnetica del GPS
|
|
455
|
+
const calculatedTrueHdg = (val + variation + 2 * Math.PI) % (2 * Math.PI);
|
|
456
|
+
|
|
457
|
+
// Registriamo il valore calcolato come Prua Vera temporanea
|
|
458
|
+
store.raw["navigation.headingTrue"] = calculatedTrueHdg;
|
|
459
|
+
safePush(store.smoothBuf.hdg, calculatedTrueHdg, now);
|
|
460
|
+
safePush(store.longBuf.hdg, calculatedTrueHdg, now);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
421
464
|
if (path === "navigation.courseOverGroundTrue") {
|
|
422
465
|
safePush(store.smoothBuf.cog, val, now);
|
|
423
466
|
safePush(store.longBuf.cog, val, now);
|
package/index.js
CHANGED
|
@@ -21,6 +21,9 @@ module.exports = function (app) {
|
|
|
21
21
|
let graphTempBuf = { stw: [], sog: [], depth: [], tws: [], vmg: [], aws: [], twd: [] };
|
|
22
22
|
let lastUpdates = { stw: 0, sog: 0, depth: 0, tws: 0, vmg: 0, aws: 0, twd: 0 };
|
|
23
23
|
let raw = {};
|
|
24
|
+
// Memoria temporale per rilevare la presenza di sensori nativi sul Cerbo
|
|
25
|
+
let lastNativeTwsTime = 0;
|
|
26
|
+
let lastNativeTwdTime = 0;
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* plugin.start: Inizializza il plugin.
|
|
@@ -61,6 +64,8 @@ module.exports = function (app) {
|
|
|
61
64
|
{ path: 'environment.wind.speedApparent' },
|
|
62
65
|
{ path: 'environment.wind.angleApparent' },
|
|
63
66
|
{ path: 'navigation.headingTrue' },
|
|
67
|
+
{ path: 'navigation.headingMagnetic' },
|
|
68
|
+
{ path: 'navigation.magneticVariation' },
|
|
64
69
|
{ path: 'navigation.courseOverGroundTrue' }
|
|
65
70
|
]
|
|
66
71
|
};
|
|
@@ -98,14 +103,17 @@ module.exports = function (app) {
|
|
|
98
103
|
app.debug(msg);
|
|
99
104
|
};
|
|
100
105
|
|
|
101
|
-
|
|
106
|
+
/**
|
|
102
107
|
* processIncomingDelta: Decodifica i dati dei sensori in Knots/Meters ed esegue l'aggregazione
|
|
108
|
+
* Gestisce l'architettura "Nativo Prima, Fallback Dopo" per il vento reale.
|
|
103
109
|
*/
|
|
104
110
|
function processIncomingDelta(path, val) {
|
|
105
111
|
if (val === null || val === undefined) return;
|
|
106
112
|
raw[path] = val;
|
|
107
113
|
|
|
108
|
-
|
|
114
|
+
const now = Date.now();
|
|
115
|
+
|
|
116
|
+
// 1. Cattura dei dati nativi (Se presenti, li scrive direttamente nello storico)
|
|
109
117
|
if (path === 'navigation.speedThroughWater') {
|
|
110
118
|
manageHistory('stw', val * 1.94384);
|
|
111
119
|
}
|
|
@@ -118,8 +126,24 @@ module.exports = function (app) {
|
|
|
118
126
|
else if (path === 'environment.wind.speedApparent') {
|
|
119
127
|
manageHistory('aws', val * 1.94384);
|
|
120
128
|
}
|
|
129
|
+
else if (path === 'environment.wind.speedTrue') {
|
|
130
|
+
lastNativeTwsTime = now; // Rilevato TWS nativo della centralina!
|
|
131
|
+
manageHistory('tws', val * 1.94384);
|
|
132
|
+
}
|
|
133
|
+
// --- DECODIFICA PRUA MAGNETICA SERVER-SIDE ---
|
|
134
|
+
else if (path === 'navigation.headingMagnetic') {
|
|
135
|
+
const hasTrueHdg = raw['navigation.headingTrue'] !== undefined;
|
|
136
|
+
if (!hasTrueHdg) {
|
|
137
|
+
const variation = raw['navigation.magneticVariation'] || 0;
|
|
138
|
+
raw['navigation.headingTrue'] = (val + variation + 2 * Math.PI) % (2 * Math.PI);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (path === 'environment.wind.directionTrue') {
|
|
142
|
+
lastNativeTwdTime = now; // Rilevato TWD nativo della centralina!
|
|
143
|
+
manageHistory('twd', val);
|
|
144
|
+
}
|
|
121
145
|
|
|
122
|
-
// Calcolo combinato
|
|
146
|
+
// 2. Calcolo combinato di FALLBACK (Si attiva solo se la centralina non invia TWS/TWD nativi)
|
|
123
147
|
const aws = raw["environment.wind.speedApparent"];
|
|
124
148
|
const awa = raw["environment.wind.angleApparent"];
|
|
125
149
|
const stw = raw["navigation.speedThroughWater"] || 0;
|
|
@@ -128,25 +152,29 @@ module.exports = function (app) {
|
|
|
128
152
|
const cog = raw["navigation.courseOverGroundTrue"] || 0;
|
|
129
153
|
|
|
130
154
|
if (aws !== undefined && awa !== undefined) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const tws = Math.sqrt(tw_water_x * tw_water_x + tw_water_y * tw_water_y);
|
|
155
|
+
const awsKts = aws * 1.94384;
|
|
156
|
+
const stwKts = stw * 1.94384;
|
|
157
|
+
const tw_water_x = awsKts * Math.cos(awa) - stwKts;
|
|
158
|
+
const tw_water_y = awsKts * Math.sin(awa);
|
|
136
159
|
|
|
160
|
+
// Calcoliamo il TWS di fallback solo se non abbiamo visto dati nativi negli ultimi 5 secondi
|
|
161
|
+
if (now - lastNativeTwsTime > 5000) {
|
|
162
|
+
const tws = Math.sqrt(tw_water_x * tw_water_x + tw_water_y * tw_water_y);
|
|
137
163
|
manageHistory('tws', tws);
|
|
164
|
+
}
|
|
138
165
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
166
|
+
const twa = Math.atan2(tw_water_y, tw_water_x);
|
|
167
|
+
|
|
168
|
+
// La VMG viene sempre calcolata a livello server poiché raramente è nativa
|
|
169
|
+
const vmg = Math.abs(stwKts * Math.cos(twa));
|
|
170
|
+
manageHistory('vmg', vmg);
|
|
171
|
+
|
|
172
|
+
// Calcoliamo il TWD di fallback solo se non abbiamo visto dati nativi negli ultimi 5 secondi
|
|
173
|
+
if (hdg !== undefined && (now - lastNativeTwdTime > 5000)) {
|
|
174
|
+
const twd = (hdg + twa + 2 * Math.PI) % (2 * Math.PI);
|
|
175
|
+
manageHistory('twd', twd);
|
|
149
176
|
}
|
|
177
|
+
}
|
|
150
178
|
}
|
|
151
179
|
|
|
152
180
|
/**
|