From 209c4a812356717c401c6e635e134cdca478ad49 Mon Sep 17 00:00:00 2001 From: MikeCAT Date: Sun, 13 Aug 2023 07:25:05 +0900 Subject: [PATCH] have LED use ioManager --- docs/Commands.js | 14 ++++++-------- docs/OneFiveCrowd.js | 13 +++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/docs/Commands.js b/docs/Commands.js index 9d79588..fa5beb4 100644 --- a/docs/Commands.js +++ b/docs/Commands.js @@ -87,15 +87,13 @@ async function commandINPUT(prompt, varIdx) { } } -function commandLED(args) { +async function commandLED(args) { // LEDの点灯/消灯を切り替える - const isOn = args[0] !== 0; - const ledElement = document.getElementById("ledPane"); - if (isOn) { - ledElement.classList.add("lighting"); - } else { - ledElement.classList.remove("lighting"); - } + await ioManager.setPortStatus({ + "id": "led", + "status": "output_binary", + "binaryValue": args[0] !== 0 ? 1 : 0, + }); } async function commandWAIT(args) { diff --git a/docs/OneFiveCrowd.js b/docs/OneFiveCrowd.js index 6ba4ecd..6824636 100644 --- a/docs/OneFiveCrowd.js +++ b/docs/OneFiveCrowd.js @@ -1139,6 +1139,19 @@ async function initSystem() { } // I/Oポートを設定する + { + const ledElement = document.getElementById("ledPane"); + ioManager.registerDevice("LED", function(notifyDataSet) { + if ("led" in notifyDataSet) { + const ledData = notifyDataSet.led; + if (ledData.status === "output_binary" && ledData.binaryValue) { + ledElement.classList.add("lighting"); + } else { + ledElement.classList.remove("lighting"); + } + } + }, null); + } ioManager.initialize(); // 各種初期化を行う