aboutsummaryrefslogtreecommitdiff
path: root/app.mjs
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2024-08-17 00:57:11 -0700
committerDeterminant <[email protected]>2024-08-17 00:57:11 -0700
commitda5bf38841ba2ae3abe070b4f237e6cb7029c253 (patch)
tree01ec61c24abc744cb87a10bbc66f39757f7ed65c /app.mjs
parent72aac1a777bedce325de10e9f11633e0243c362e (diff)
...
Diffstat (limited to 'app.mjs')
-rwxr-xr-xapp.mjs21
1 files changed, 11 insertions, 10 deletions
diff --git a/app.mjs b/app.mjs
index f297fa5..215961a 100755
--- a/app.mjs
+++ b/app.mjs
@@ -309,8 +309,8 @@ const drawGauge = (key, label, value) => {
});
};
-const loadPage = (page) => {
- const { left, right, keys } = page || {};
+const loadPage = (page) => { // page is not null
+ const { left, right, keys } = page;
drawSideKnobs("left", left);
drawSideKnobs("right", right);
for (let i = 0; i < 12; i++) {
@@ -326,25 +326,26 @@ const loadPage = (page) => {
device.on("connect", async () => {
console.info("connected");
for (let i = 0; i < pages.length; i++) {
- const page = pages[i];
+ const page = pages[i] || {};
+ const keys = page.keys;
const color =
isObject(page) && page.color != null ? page.color : "white";
await device.setButtonColor({ id: i, color });
// subscribe the data feeds
- const { keys } = page || {};
for (let j = 0; j < 12; j++) {
- const key = Array.isArray(keys) && keys.length > j ? keys[j] : null;
+ const conf =
+ Array.isArray(keys) && keys.length > j ? keys[j] : null;
if (
- key &&
- key.display != null &&
- key.display.xplane_dataref != null
+ isObject(conf) &&
+ conf.display != null &&
+ conf.display.xplane_dataref != null
) {
await xplane.subscribeDataRef(
- key.display.xplane_dataref,
+ conf.display.xplane_dataref,
10,
(v) => {
if (currentPage == i) {
- drawGauge(j, key, v);
+ drawGauge(j, conf, v);
}
},
);