-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update renderer to use readline parser and tagged serial data #1
base: main
Are you sure you want to change the base?
Update renderer to use readline parser and tagged serial data #1
Conversation
Oh and my editor reformatted the whole thing. If you have a preferred style I can switch to that. |
initializePort(event.target.value); | ||
}); | ||
}); | ||
const ports = await serialport.list(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you await
stuff you don't need to .then()
it anymore. It's a little confusing but it automatically does that in the background so that you can pretend it's blocking code even though Javascript can't block.
activePort = new serialport(portName, { | ||
baudRate: baudRate, | ||
}); | ||
parser = activePort.pipe(new Readline({ delimiter: "\n" })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parser
bit is new. Incoming data goes through parser
but outgoing data still goes through activePort
.
let intervalHandle; | ||
|
||
// HTML elements | ||
let stepDivElements = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed all these to make it clear that they're HTML elements.
canvas.width, | ||
3 | ||
); | ||
let canvasWidth = canvas.clientWidth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the canvas sizes are dynamic now, we can fetch them with this instead of using their default values which won't ever scale.
Also sets the style of the bars to fill up the screen space, though it could probably be done a little better using flexbox or something.
It also sets the baud rate to 115200 because 9600 isn't fast enough to keep up.
The arduino firmware will end up needing these changes to match: