Skip to content

Commit

Permalink
* Fixed button press issue.
Browse files Browse the repository at this point in the history
* Updated Command library

* Updated branch to latest `master`
  • Loading branch information
dcyoung-dev committed May 8, 2022
1 parent 7ce18a0 commit 296b9e7
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 31 deletions.
35 changes: 19 additions & 16 deletions js/commandController.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,25 @@ async function readLoop() {
}

function writeToStream(...lines) {
// Stops data being written to nonexistent port if using emulator
let stream = emulatorClass
if (port) {
stream = outputStream.getWriter();
}

lines.forEach((line) => {
if (line == "\x03" || line == "echo(false);") {

} else {
displayLog('[SEND]'+line.toString());
}
const packet = `<${line}>\n`;
stream.write(packet)
console.log(packet)
});
const commandLines = lines.map(line => `<${line}>\n`)
writeRawToStream(...commandLines)
}

function writeRawToStream(...lines) {
let stream = emulatorClass
if (port) {
stream = outputStream.getWriter();
}

lines.forEach((line) => {
if (line == "\x03" || line == "echo(false);") {

} else {
displayLog('[SEND]'+line.toString());
}
stream.write(line)
console.log(line)
});
}

// Transformer for the Web Serial API. Data comes in as a stream so we
Expand Down
5 changes: 2 additions & 3 deletions js/ui/functionButtons.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {cabCommand} from "../vendor/dcc-ex--commands-v0.3.0.js"

import {cabCommand} from "../vendor/dcc-ex--commands-0.10.0.js"

function sendCabCommand(fn, value) {
setFunCurrentVal(fn, value);
Expand All @@ -16,7 +15,7 @@ function generateFnCommand(funcName, btnPressed) {
}

function toggleButtonState(previousBtnState, buttonElement) {
const newBtnState = !previousBtnState
const newBtnState = previousBtnState === 'false'
buttonElement.ariaPressed = newBtnState
buttonElement.setAttribute("aria-pressed", newBtnState) // Firefox support https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaPressed
return newBtnState;
Expand Down
Loading

0 comments on commit 296b9e7

Please sign in to comment.