1.0.3 • Published 3 years ago

node-cricut v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

node-cricut

Finally, an open-source library for communicating with Cricut devices! Don't let your creativity be limited by proprietary software, send whatever cutting commands you darn want!

DISCLAIMER: This project is completely unaffiliated with Cricut Inc. It was written by @vexcat after reverse engineering the Cricut software. Cricut is not responsible for any problems caused by this library.

How to use

Create a new CricutDevice from a serial port:

const { CricutDevice } = require('./client');
let dev = new CricutDevice('/dev/rfcomm0', require('./keys'));

Do a crypto handshake, then wait for the device to be ready.

dev.handshake();
dev.on('ready', async () => {
    //...
})

Let's load a mat!

await dev.setMaterialParams(0, 4.8, 6.5);      // Mat has 4.8" x 6.5" of cuttable area
await dev.enableSensor();                      // Enable mat loading
await dev.setLEDAnimation(4);                  // Make LED blink
console.log('Waiting for paper load...');
while(true) {
    let status = await dev.getStatus();        // Get status of device
    if(status.matLoaded) break;
}
console.log('Paper loaded! Now measuring...');
console.log(await dev.startMeasuring(6.5));    // Start measuring the mat
console.log(await dev.getMeasurement());       // Wait until the mat is measured and print the length
await dev.setLEDAnimation(2);                  // Stop LED blinking

and now cut out a circle!

await dev.setMaterialParams(0, 4.8, 6.5); // On mat, 4.8" x 6.5"
await dev.setHeadState(0, 1200, 2);       // Head #0, 1200 units of pressure, 2nd pressureTable (not sure what a pressure table is, but you can set it with this library! Yay!)
await dev.setSpeedState({                 // Set speeds of all axes
    x:  { cutVel:  3, moveVel:  3, cutAccel: 10, moveAccel: 10 },
    y:  { cutVel:  3, moveVel:  3, cutAccel: 10, moveAccel: 10 },
    za: { cutVel:  4, moveVel:  4, cutAccel: 20, moveAccel: 38.60 },
    zb: { cutVel:  4, moveVel:  4, cutAccel: 20, moveAccel: 38.60 },
    t:  { cutVel: 10, moveVel: 10, cutAccel: 25, moveAccel: 250 }
});
await dev.setToolState();                 // Default tool state
let vecs = [];
for(let i = 0; i <= 100; i++) {
    let type = i === 0 ? 2 : 0;           // 2: Move to, 0: Line to
    vecs.push([type, 2 + Math.sin((i * 2 * Math.PI) / 100), 4 + Math.cos((i * 2 * Math.PI) / 100)]);
}
await dev.drawBatch(vecs);                // Draw vectors and wait for cutting to finish
await dev.getFinalPosition();             // Wait for all motion to end
await dev.unload();                       // Unload mat

keys.js

You'll need a keys.js file to use this library. This file has a key that allows this library to encrypt/decrypt messages to be sent/received from the cricut device. This file is not provided with the library for legal reasons. However, you can find the key within your very own legally-owned copy of Cricut Design Space if you are skilled with Ghidra or another binary reverse engineering tool. (Or you can copy the keys.json from somebody else, this library has no way to tell the difference.)

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago