Skip to content

Commit

Permalink
Fix last line of code
Browse files Browse the repository at this point in the history
  • Loading branch information
lupyuen committed Feb 21, 2024
1 parent f37ce9d commit 1244e4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
22 changes: 17 additions & 5 deletions docs/blockly/jslinux.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,30 @@ function start_vm(user, pwd)
}
//// End Test

//// Begin Test: Start QuickJS
//// Begin Test: Send a Command to Console Input, character by character
let send_str = "";
function send_command(cmd) {
if (cmd !== null) { send_str = cmd; }
if (send_str.length == 0) { return; }
console_write1(send_str.charCodeAt(0));

// Get the next character
const ch = send_str.substring(0, 1);
send_str = send_str.substring(1);
window.setTimeout(()=>{ send_command(null); }, 10);

// Slow down at the end of each line
const timeout = (ch === "\r")
? 1000
: 10;

// Send the character
console_write1(ch.charCodeAt(0));
window.setTimeout(()=>{ send_command(null); }, timeout);
}
// Send a command to serial port. Newlines become Carriage Returns.

// Send a Command to Console Input. Newlines become Carriage Returns.
const code = window.localStorage.getItem("runCode")
.split('\n').join(' \r');
.split("\n").join("\r")
.split("\r\r").join("\r");
const cmd = [
`qjs`,
code,
Expand Down
3 changes: 2 additions & 1 deletion docs/webserial/webserial.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ async function control_device() {

// Send a command to serial port. Newlines become Carriage Returns.
const code = window.localStorage.getItem("runCode")
.split('\n').join('\r');
.split("\n").join("\r")
.split("\r\r").join("\r");
const cmd = [
`qjs`,
code,
Expand Down

0 comments on commit 1244e4a

Please sign in to comment.