diff options
author | Determinant <[email protected]> | 2024-08-29 12:11:12 -0700 |
---|---|---|
committer | Determinant <[email protected]> | 2024-08-29 12:11:12 -0700 |
commit | bdc574873a4fa6931c9f791c3e464421006cf92a (patch) | |
tree | 943900d8f775312596b0fb30188f6e24b826b893 | |
parent | ea672a5d4c7d781ca986f5e0df3b5cb2e1acd135 (diff) |
...
-rwxr-xr-x | app.mjs | 56 | ||||
-rw-r--r-- | profile.yaml | 45 |
2 files changed, 66 insertions, 35 deletions
@@ -257,10 +257,19 @@ const formatDisplayText = (formatter, values) => { return values[0].toFixed(0).toString(); }; +const formatDisplayColor = (color, values) => { + if (color) { + return Function("$d", `"use strict"; return(\`${color}\`);`)(values); + } + return "#fff"; +}; + const renderAttitudeIndicator = (c, display, values) => { const pitch = values[0]; const roll = values[1]; - const cdi = values[2]; + const src = display.src[values[2]]; + const cdi = src ? values[src.def] : null; + const received = src ? values[src.received] : null; const bg = "black"; const fg = "white"; const w = c.canvas.width; @@ -341,19 +350,21 @@ const renderAttitudeIndicator = (c, display, values) => { } c.stroke(); - // draw CDI diamond - const cdi_y = y0 + 13 * cdi; - const cdi_h = 7; - const cdi_w = 4; - c.fillStyle = "lightgreen"; - c.strokeStyle = "black"; - c.beginPath(); - c.moveTo(vdef_x, cdi_y + cdi_h); - c.lineTo(vdef_x - cdi_w, cdi_y); - c.lineTo(vdef_x, cdi_y - cdi_h); - c.lineTo(vdef_x + cdi_w, cdi_y); - c.stroke(); - c.fill(); + if (received != 0) { + // draw CDI diamond + const cdi_y = y0 + 13 * cdi; + const cdi_h = 7; + const cdi_w = 4; + c.fillStyle = "#2dfe54"; + c.strokeStyle = "black"; + c.beginPath(); + c.moveTo(vdef_x, cdi_y + cdi_h); + c.lineTo(vdef_x - cdi_w, cdi_y); + c.lineTo(vdef_x, cdi_y - cdi_h); + c.lineTo(vdef_x + cdi_w, cdi_y); + c.stroke(); + c.fill(); + } }; const renderTextGauge = (c, display, values) => { @@ -381,9 +392,9 @@ const renderTextGauge = (c, display, values) => { size: display.size, size2: display.size2, size3: display.size3, - color_fg: display.color_fg, - color_fg2: display.color_fg2, - color_fg3: display.color_fg3, + color_fg: formatDisplayColor(display.color_fg, values), + color_fg2: formatDisplayColor(display.color_fg2, values), + color_fg3: formatDisplayColor(display.color_fg3, values), }); }; @@ -671,6 +682,7 @@ const renderHSI = (c, display, values) => { const src = display.navs[values[2]]; const crs = src ? deg2Rad(values[src.crs]) : null; let def = src ? Math.min(Math.max(values[src.def], -3), 3) : null; + const received = src ? values[src.received] : null; if (isNaN(def)) { def = 0; } @@ -701,7 +713,7 @@ const renderHSI = (c, display, values) => { const bug_y0 = -(r - 8); c.stroke(); c.rotate(hdg_bug); - c.fillStyle = "blue"; + c.fillStyle = "cyan"; c.beginPath(); c.moveTo(0, bug_y1); c.lineTo(-bug_w, -(r + 1)); @@ -726,12 +738,14 @@ const renderHSI = (c, display, values) => { c.stroke(); c.beginPath(); - const cdi_x = 13 * def; c.lineWidth = 3; c.strokeStyle = src.color ? src.color : "magenta"; - c.moveTo(cdi_x, -(cdi_r - 1)); - c.lineTo(cdi_x, cdi_r - 1); + if (received != 0) { + const cdi_x = 13 * def; + c.moveTo(cdi_x, -(cdi_r - 1)); + c.lineTo(cdi_x, cdi_r - 1); + } c.moveTo(0, -r); c.lineTo(0, -(cdi_r + 1)); diff --git a/profile.yaml b/profile.yaml index 8b97e75..1b46a99 100644 --- a/profile.yaml +++ b/profile.yaml @@ -109,8 +109,20 @@ source: - xplane_dataref: sim/cockpit/gyros/the_ind_ahars_pilot_deg # pitch - xplane_dataref: sim/cockpit/gyros/phi_ind_ahars_pilot_deg # roll - - xplane_dataref: sim/cockpit2/radios/indicators/gps_hdef_dots_pilot + - xplane_dataref: sim/cockpit2/radios/actuators/HSI_source_select_pilot + - xplane_dataref: sim/cockpit2/radios/indicators/hsi_vdef_dots_pilot + - xplane_dataref: sim/cockpit2/radios/indicators/hsi_display_vertical_pilot + src: + 2: + def: 3 + received: 4 + 0: + def: 3 + received: 4 + 1: + def: 3 + received: 4 - display: type: alt freq: 24 @@ -138,39 +150,44 @@ - xplane_dataref: sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot - xplane_dataref: sim/cockpit2/autopilot/heading_dial_deg_mag_pilot - xplane_dataref: sim/cockpit2/radios/actuators/HSI_source_select_pilot + - xplane_dataref: sim/cockpit2/radios/indicators/hsi_hdef_dots_pilot + - xplane_dataref: sim/cockpit2/radios/indicators/hsi_display_horizontal_pilot - xplane_dataref: sim/cockpit/radios/gps_course_degtm - - xplane_dataref: sim/cockpit2/radios/indicators/gps_hdef_dots_pilot - xplane_dataref: sim/cockpit2/radios/actuators/nav1_obs_deg_mag_pilot - - xplane_dataref: sim/cockpit2/radios/indicators/nav1_hdef_dots_pilot - xplane_dataref: sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot - - xplane_dataref: sim/cockpit2/radios/indicators/nav2_hdef_dots_pilot hdg: 0 src: 1 navs: 2: - crs: 3 - def: 4 + crs: 5 + def: 3 + received: 4 color: magenta 0: - crs: 5 - def: 6 - color: green + crs: 6 + def: 3 + received: 4 + color: '#2dfe54' 1: crs: 7 - def: 8 - color: green + def: 3 + received: 4 + color: '#2dfe54' - display: type: text freq: 6 source: - xplane_dataref: sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot - xplane_dataref: sim/cockpit2/autopilot/heading_dial_deg_mag_pilot + - xplane_dataref: sim/cockpit2/radios/actuators/HSI_source_select_pilot - xplane_dataref: sim/cockpit/radios/gps_course_degtm + - xplane_dataref: sim/cockpit2/radios/actuators/nav1_obs_deg_mag_pilot + - xplane_dataref: sim/cockpit2/radios/actuators/nav2_obs_deg_mag_pilot formatter: '${$d[0] != null ? $d[0].toFixed(0).padStart(3, "0") : "xxx"}' formatter2: 'HDG ${$d[1] != null ? $d[1].toFixed(0).padStart(3, "0") : "xxx"}' - formatter3: 'CRS ${$d[2] != null ? $d[2].toFixed(0).padStart(3, "0") : "xxx"}' - color_fg2: '#1a62fd' - color_fg3: 'magenta' + formatter3: 'CRS ${($d[2] == 2 ? $d[3] : ($d[2] == 0 ? $d[4] : ($d[2] == 1 ? $d[5] : 0))).toFixed(0).padStart(3, "0")}' + color_fg2: 'cyan' + color_fg3: '${($d[2] == 2 ? "magenta" : ($d[2] == 0 ? "#2dfe54" : ($d[2] == 1 ? "#2dfe54" : "magenta")))}' size2: 16 size3: 16 - text: Brake |