Skip to content

Commit 3769582

Browse files
committed
Breaking changes
* Renames `modalState` to `modal` * Renames `coordinate` to `wcs` * Use `module.exports` to export a ES6 class * deps: gcode-interpreter@^2.0.0
1 parent 9844463 commit 3769582

5 files changed

Lines changed: 752 additions & 615 deletions

File tree

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,43 @@
99
## Usage
1010

1111
```js
12-
var GCodeToolpath = require('gcode-toolpath').GCodeToolpath;
12+
const Toolpath = require('gcode-toolpath');
1313

14-
var toolpaths = [];
15-
var gcode = new GCodeToolpath({
16-
modalState: { // [optional] initial modal state
14+
const toolpaths = [];
15+
const gcode = new Toolpath({
16+
modal: { // [optional] initial modal state
1717
motion: 'G0', // G0, G1, G2, G3, G38.2, G38.3, G38.4, G38.5, G80
18-
coordinate: 'G54', // G54, G55, G56, G57, G58, G59
18+
wcs: 'G54', // G54, G55, G56, G57, G58, G59
1919
plane: 'G17', // G17: xy-plane, G18: xz-plane, G19: yz-plane
2020
units: 'G21', // G20: Inches, G21: Millimeters
2121
distance: 'G90', // G90: Absolute, G91: Relative
22-
feedrate: 'G94', // G93: Inverse Time Mode, G94: Units Per Minutes
23-
program: 'M0',
24-
spindle: 'M5',
25-
coolant: 'M9'
22+
feedrate: 'G94', // G93: Inverse time mode, G94: Units per minute, G95: Units per rev
23+
program: 'M0', // M0, M1, M2, M30
24+
spindle: 'M5', // M3, M4, M5
25+
coolant: 'M9' // M7, M8, M9
2626
},
27-
addLine: (modalState, v1, v2) => {
28-
var motion = modalState.motion;
27+
addLine: (modal, v1, v2) => {
28+
var motion = modal.motion;
2929
toolpaths.push({ motion: motion, v1: v1, v2: v2 });
3030
},
31-
addArcCurve: (modalState, v1, v2, v0) => {
32-
var motion = modalState.motion;
31+
addArcCurve: (modal, v1, v2, v0) => {
32+
var motion = modal.motion;
3333
toolpaths.push({ motion: motion, v1: v1, v2: v2, v0: v0 });
3434
}
3535
});
3636

3737
// Load G-code from file
38-
var file = 'example.nc';
38+
const file = 'example.nc';
3939
gcode.loadFromFile(file, function(err, data) {
4040
});
4141

4242
// Load G-code from stream
43-
var stream = fs.createReadStream(file, { encoding: 'utf8' });
43+
const stream = fs.createReadStream(file, { encoding: 'utf8' });
4444
gcode.loadFromStream(stream, function(err, data) {
4545
});
4646

4747
// Load G-code from string
48-
var str = fs.readFileSync(file, 'utf8');
48+
const str = fs.readFileSync(file, 'utf8');
4949
gcode.loadFromString(str, function(err, data) {
5050
});
5151
```
@@ -54,7 +54,7 @@ gcode.loadFromString(str, function(err, data) {
5454

5555
Run this example with babel-node:
5656
```js
57-
import { GCodeToolpath } from 'gcode-toolpath';
57+
import Toolpath from 'gcode-toolpath';
5858

5959
const GCODE = [
6060
'N1 G17 G20 G90 G94 G54',
@@ -70,14 +70,14 @@ const GCODE = [
7070
'N11 G00 X0. Y0. Z0.25'
7171
].join('\n');
7272

73-
let toolpaths = [];
74-
let gcode = new GCodeToolpath({
75-
addLine: (modalState, v1, v2) => {
76-
var motion = modalState.motion;
73+
const toolpaths = [];
74+
const gcode = new Toolpath({
75+
addLine: (modal, v1, v2) => {
76+
const motion = modal.motion;
7777
toolpaths.push({ motion: motion, v1: v1, v2: v2 });
7878
},
79-
addArcCurve: (modalState, v1, v2, v0) => {
80-
var motion = modalState.motion;
79+
addArcCurve: (modal, v1, v2, v0) => {
80+
const motion = modal.motion;
8181
toolpaths.push({ motion: motion, v1: v1, v2: v2, v0: v0 });
8282
}
8383
});

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gcode-toolpath",
3-
"version": "1.3.0",
3+
"version": "2.0.0",
44
"description": "G-code Toolpath Generator",
55
"author": "Cheton Wu <cheton@gmail.com>",
66
"homepage": "https://github.com/cncjs/gcode-toolpath",
@@ -25,7 +25,7 @@
2525
},
2626
"main": "lib/index.js",
2727
"dependencies": {
28-
"gcode-interpreter": "^1.3.0"
28+
"gcode-interpreter": "^2.0.0"
2929
},
3030
"devDependencies": {
3131
"babel-cli": "^6.26.0",
@@ -37,7 +37,7 @@
3737
"chai": "^4.1.2",
3838
"coveralls": "^3.0.0",
3939
"cross-env": "^5.0.5",
40-
"eslint": "^4.7.2",
40+
"eslint": "^4.8.0",
4141
"eslint-config-trendmicro": "^1.0.0",
4242
"eslint-plugin-import": "^2.7.0",
4343
"eslint-plugin-jsx-a11y": "^5.1.1",

0 commit comments

Comments
 (0)