Node.js and Browser JavaScript Library


#1

Hey all! I’ve been poking at the Line-us’s new websocket interface for a bit and have finally published a JavaScript library that can be used in both the browser and Node.js:

It’s still quite in-progress but it works fine and makes connecting and drawing pretty simple and fun. Let me know if you have any questions or input!


#2

Had a very quick look last night and it looks great. We’re really hoping to see people writing browser based apps for Line-us and I think this will help greatly with that. I’ll put a link to your GitHub on our programming page if that’s ok.

Just one thing you might find interesting - in the documentation you quite rightly note:

The coordinate emitted will be the machine’s position when it finishes the current command . It is not the machine’s immediate position.

The reason that we echo it back to the sender is that multiple apps can connect to the Line-us at the same time (technically four for WebSockets if I remember correctly although not quite sure what performance would be like with four), so if another app has moved the arm you can find out the current position by sending an M114. Potentially this opens up some interesting possibilities for (for example) games so would be interested to see what you all can come up with!


#3

I’ll put a link to your GitHub on our programming page if that’s ok.

Certainly.

multiple apps can connect to the Line-us at the same time

Oooh, that is very interesting. I’ll have to test for that. Do the “buffer” mechanics stay the same eg: does each connection get to have one in-flight command and one unacknowledged command buffered?

Very happy to hear any other feedback. I need to handle Line-us’s error messages better, and do some testing and some documentation updates. I just updated things yesterday to use a more standard “0,0 is top left” coordinate grid on top of the same drawing area used by the app.

We’re really hoping to see people writing browser based apps for Line-us and I think this will help greatly with that.

I’m really jazzed about this websocket stuff. Very happy that y’all added the capability.

There’s no chance you have a Line-us emulator/simulator kicking around anywhere is there? I know it’d be overengineering things but I’ve been wishing I could connect to a simulated Line-us to run tests against.

In the meantime I’ve just been mocking up a naive js-based Line-us imposter.


#4

Do the “buffer” mechanics stay the same eg: does each connection get to have one in-flight command and one unacknowledged command buffered?

Yes, that’s right.

Very happy to hear any other feedback.

Will do, and similarly if you find any inconsistency in the error messages you get from Line-us (and there are some I’m sure) let me know. There will be a minor firmware update in the not distant future so I can put in anything you find.

Very happy that y’all added the capability.

Thanks. We actually did it for Scratch, and didn’t really realise how useful it was until we’d done it!

There’s no chance you have a Line-us emulator/simulator kicking around anywhere is there?

Unfortunately not. Have thought about it a few times but never managed to find the time to do it.


#5

From the docs:

The z axis is the pen height; 0 is down and 1000 is up.

If the pen is on the down position (z < 500) the pen will lift (z = 1000).

This gave me the impression that the actual 0-1000 scale of the z axis was a ruse, and anything < 500 would result in the pen being all the way down (0), and 500+ would result in the pen being all the way up (1000). This is not the case and upon re-reading i see that you never really said it is. Still, it was a point of confusion and creates some “interesting” edge cases for my library. Do you know of anybody using these variable heights?

Also it seems like I can send my Line-us a Z2000 command and create some very unhappy noises.