Skip to content

Commit

Permalink
have LED use ioManager
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecat committed Aug 12, 2023
1 parent 180d1f8 commit 209c4a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
14 changes: 6 additions & 8 deletions docs/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
13 changes: 13 additions & 0 deletions docs/OneFiveCrowd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

// 各種初期化を行う
Expand Down

0 comments on commit 209c4a8

Please sign in to comment.