-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
big changes for async API; still resend problems; better gcode parsin…
…g and serial handling on back end
- Loading branch information
Evan Raskob
committed
Sep 14, 2019
1 parent
ee907b0
commit dddbda3
Showing
6 changed files
with
2,056 additions
and
1,827 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,62 @@ | ||
// hilbert curve | ||
// https://github.com/nylki/lindenmayer | ||
// L-systems test | ||
// Uses a modified verion of the Lindenmayer library for JavaScript that uses ES6 Generators | ||
// https://github.com/pixelpusher/lindenmayer | ||
|
||
|
||
await lp.start(195); | ||
|
||
attachScript("http://localhost:8888/static/lib/linden/linden.js"); | ||
|
||
// Now initialize the L-System to generate the tree | ||
var tree = new LSystem({ | ||
await lp.moveto({ x: 40, y: 80, z: 80, speed: 80 }); | ||
|
||
await lp.retract(); | ||
|
||
await lp.ext({ e: 10, speed: 8 }) | ||
|
||
// Now initialize the L-System to generate the Hilbert curve | ||
global hilbert = new LSystem({ | ||
axiom: 'L', | ||
ignoredSymbols: "", | ||
productions: { | ||
'L': "+RF-LFL-FR+", | ||
'R': "-LF+RFR+FL-", | ||
}, | ||
finals: { | ||
'F': () => { lp.dist(20).go(1); }, | ||
'+': () => { lp.turn(90); }, | ||
'-': () => { lp.turn(-90); } | ||
'F': async () => { await lp.dist(4).go(1, false); }, | ||
'+': async () => { lp.turn(-90); return true; }, | ||
'-': async () => { lp.turn(90); return true; } | ||
} | ||
}); | ||
|
||
// Run the 5 iterations of the L-System | ||
tree.iterate(4); | ||
console.log(tree); | ||
tree.final(); | ||
// Run the 1 iterations of the L-System | ||
hilbert.iterate(1); | ||
|
||
console.log(window.hilbert.getFuncs()) | ||
console.log(window.hilbert.axiom) | ||
|
||
loginfo(hilbert.getString()) | ||
loginfo(totalsteps) | ||
|
||
|
||
// draw each layer of the Hilbert curve (as a block, or manually) | ||
{ | ||
lp.lh = 0.25; // make it thick | ||
let layer = 1; // current index of layer we're printing | ||
await lp.moveto({ x: 120, y: 100, z: 0.2 + 0.2 * layer, speed: 80 }); // set this to where you want to print and how high | ||
|
||
lp.speed(10); // set speed conservatively | ||
await lp.unretract(); // unretract material for printing | ||
lp.turnto(0); // turn to initial angle (facing right) | ||
//await hilbert.run(); | ||
|
||
for await (let f of hilbert.getFuncs()) { | ||
const func = f[0]; | ||
const index = f[1]; | ||
const part = f[2]; | ||
await func({ index, part }); | ||
} | ||
|
||
await lp.retract(); // unretract material for printing | ||
await lp.up(90).go(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
dddbda3
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 is an almost-finished re-implementation of async tornado for #29
It needs https://www.npmjs.com/package/bottleneck implemented in the front-end for queuing. Also, it fixes #45