aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2024-09-07 16:59:47 -0700
committerDeterminant <[email protected]>2024-09-07 16:59:47 -0700
commitd5bd5ef20f2966e3aa18be6ff2c86f1d66c6df2b (patch)
treee2c2cc3de52edfdc6a95b74837e3a58fd926cd5f
parent616df6f543a5d90f377214197c0acd96cf65e575 (diff)
parent7135e9af4926e5086419edb8c6d6e3864be5edd2 (diff)
Merge branch 'pressable-gauge'
-rwxr-xr-xapp.mjs15
-rw-r--r--profile.yaml4
2 files changed, 15 insertions, 4 deletions
diff --git a/app.mjs b/app.mjs
index 389b656..a558885 100755
--- a/app.mjs
+++ b/app.mjs
@@ -1,13 +1,15 @@
#!/usr/bin/env node
import { registerFont } from "canvas";
+
+const defaultFont = "OCR A Extended";
if (process.platform == "linux") {
console.warn(
"node-canvas does not support directly using font file in Linux (see https://github.com/Automattic/node-canvas/issues/2097#issuecomment-1803950952), please copy ./ocr-a-ext.ttf in this folder to your local font folder (~/.fonts/) or install it system-wide.",
);
} else {
registerFont(`${import.meta.dirname}/ocr-a-ext.ttf`, {
- family: "OCR A Extended",
+ family: defaultFont,
});
}
@@ -17,7 +19,6 @@ import { parse } from "yaml";
import { queue } from "async";
import { XPlane } from "./xplane.mjs";
-const defaultFont = "OCR A Extended";
const defaultTextSize = 22;
const xplane = new XPlane();
@@ -220,8 +221,9 @@ const renderMultiLineText = (c, x0, y0, w, h, text, styles, conf) => {
};
const drawKey = async (id, conf, pressed) => {
- if (conf && conf.display != null) {
+ if (conf && isObject(conf.display)) {
// not an input, but a display gauge
+ conf.display.pressed = pressed;
return;
}
@@ -761,6 +763,10 @@ const renderHSI = (c, display, values) => {
if (!isObject(src)) {
src = null;
}
+ if (display.pressed && src) {
+ display.pressed = false;
+ xplane.sendCommand(src.next.toString());
+ }
const crs = src ? deg2Rad(values[src.crs]) : null;
const fromto = src ? values[src.fromto] : null;
let def = src ? Math.min(Math.max(values[src.def], -3), 3) : null;
@@ -931,7 +937,7 @@ const drawGauge = (key, label, values) => {
if (types[display.type]) {
renderTasks.push({
key,
- func: (c) => types[display.type](c, display, values),
+ func: (c) => types[display.type](c, display, values, pressed),
});
}
};
@@ -1003,6 +1009,7 @@ device.on("connect", async () => {
: 1;
const msPerFrame = 1000 / freq;
+ conf.display.pressed = false;
conf.renderStart = () => {
let enabled = true;
let startTime = new Date();
diff --git a/profile.yaml b/profile.yaml
index 4d28e65..bcf9780 100644
--- a/profile.yaml
+++ b/profile.yaml
@@ -202,18 +202,22 @@
def: 3
received: 4
color: magenta
+ next: sim/autopilot/hsi_select_nav_1
0:
crs: 7
fromto: 8
def: 3
received: 4
color: '#2dfe54'
+ next: sim/autopilot/hsi_select_nav_2
1:
crs: 9
fromto: 10
def: 3
received: 4
color: '#2dfe54'
+ next: sim/autopilot/hsi_select_gps
+ pressed: {}
- display:
type: text
freq: 6