Skip to content

Commit 7a9c168

Browse files
first public release
0 parents  commit 7a9c168

File tree

9 files changed

+647
-0
lines changed

9 files changed

+647
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target
2+
Cargo.lock
3+
simple.gcode
4+
test_transformed.gcode
5+
test.gcode

Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "gcodeplot"
3+
version = "0.1.0"
4+
authors = ["ludwig-austermann <ludwig.austermann@outlook.com>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
nannou = "0.16.0"
11+
clap = "3.0.0-beta.2"
12+
pest = "2.1.3"
13+
pest_derive = "2.1"

img/v0.2_screenshot.png

27.1 KB
Loading

img/v0.2_screenshot_debugging.png

10.1 KB
Loading

readme.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# gcodeplot
2+
3+
*Note that this app purposely supports only a very minimal subset of g-code features, since it is primarily supposed for educational purposes.*
4+
5+
![Screenshot of version 0.2](v0.2_screenshot.png)
6+
![Screenshot of debugging features 0.2](v0.2_screenshot_debugging.png)
7+
*The pictures show a screenshot without debugging features and a zoomed screenshot of debugging features.*
8+
9+
## Description
10+
11+
`gcodeplot` is a simulated plotter of [G-code](http://en.wikipedia.org/wiki/G-code) files. It supports only
12+
- `G28`: **return to home** position
13+
- `G1 X{} Y{}`: **linear move**, move directly to `(X,Y)` (from current position)
14+
- `G2 X{} Y{} I{} J{}`: (part-)**circular move in clockwise direction**, move to `(X,Y)` (from current position) along a circle with center in `CURRENTPOS + (I,J)`
15+
- `G3 X{} Y{} I{} J{}`: (part-)**circular move in anticlockwise direction**, move to `(X,Y)` (from current position) along a circle with center in `CURRENTPOS + (I,J)`
16+
- `M280 P0 S{}`: **Set the pen** as follows, if `S>=40` down (which means it can draw) and else up
17+
- `;{}`: **comment**, which can be put on seperate line or after a regular command
18+
19+
## Arguments and features
20+
21+
The application is programmed in rust with the [nannou library](https://nannou.cc/) for displaying and the [pest library](https://pest.rs/) for parsing. It supports the following command line arguments:
22+
- `INPUT` (required): sets the gcode file to plot
23+
- `-d {}`, `--debug {}`: This enables debugging and can take values up to 3. While running, this can be changed with the key <kbd>D</kbd>
24+
- `-s {}`, `--scale {}`: This scales the whole view. While running you can access it with the <kbd>+</kbd>(might be <kbd>=</kbd> on your PC) and <kbd>-</kbd> keys
25+
- `-g {}`, `--gridsize`: This describes the gridsize used. While running you can access it with the key <kbd>G</kbd>
26+
- the flag `--hot`, for hot reloading of the gcode file. Alternatively you can update in the app with <kbd>R</kbd>
27+
- and other arguments as `--treshold`, `--wwidth` and `-wheight`.
28+
29+
It furthermore supports a subcommand `transform`, which
30+
allows you to transform a file by translation and dilation.
31+
32+
In the graphical app, a few keyboard commands are enabled. To increase a value corresponding to a <kbd>key</kbd>, just press <kbd>key</kbd> and to decrease press <kbd>shift</kbd> + <kbd>key</kbd>. For bigger steps combine these combination with a further <kbd>ctrl</kbd>.
33+
34+
## Room to improve
35+
36+
While the app can be used for many purposes, it is in a early development phase. Tests are missing and not everything is programmed the clever way. If you want to improve it feel welcome to contribute.
37+
38+
TODO:
39+
- [ ] better loop management for hot reloading
40+
- [ ] more file maniplulation features
41+
- [ ] move in grid support
42+
- [ ] draw mode?
43+
- [ ] more debug options, e.g. show coordinates

src/gcode.pest

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
num = @{ int ~ ("." ~ ASCII_DIGIT*)? ~ (^"e" ~ int)? }
2+
int = { ("+" | "-")? ~ ASCII_DIGIT+ }
3+
4+
expr = { cmd? ~ COMMENT? }
5+
cmd = _{ HOME | MOVE | PEN | ARC }
6+
HOME = { "G28" }
7+
MOVE = { "G1" ~ ((X ~ Y) | (Y ~ X)) }
8+
ARC = { (CLKW | ANTICLKW) ~ (
9+
(X ~ (
10+
(Y ~ ((I ~ J) | (J ~ I))) |
11+
(I ~ ((Y ~ J) | (J ~ Y))) |
12+
(J ~ ((Y ~ I) | (I ~ Y)))
13+
)) | (Y ~ (
14+
(X ~ ((I ~ J) | (J ~ I))) |
15+
(I ~ ((X ~ J) | (J ~ X))) |
16+
(J ~ ((X ~ I) | (I ~ X)))
17+
)) | ( I ~ (
18+
(J ~ ((X ~ Y) | (Y ~ X))) |
19+
(X ~ ((J ~ Y) | (Y ~ J))) |
20+
(Y ~ ((J ~ X) | (X ~ J)))
21+
)) | ( J ~ (
22+
(I ~ ((X ~ Y) | (Y ~ X))) |
23+
(X ~ ((I ~ Y) | (Y ~ I))) |
24+
(Y ~ ((I ~ X) | (X ~ I)))
25+
))
26+
) }
27+
CLKW = { "G2" }
28+
ANTICLKW = { "G3" }
29+
PEN = { "M280 P0 S" ~ num }
30+
31+
X = { "X" ~ num }
32+
Y = { "Y" ~ num }
33+
I = { "I" ~ num }
34+
J = { "J" ~ num }
35+
36+
file = _{ SOI ~ (expr ~ NEWLINE)* ~ expr? ~ EOI }
37+
38+
WHITESPACE = _{ " " | "\t" }
39+
COMMENT = { ";" ~ (!NEWLINE ~ ANY)* }

0 commit comments

Comments
 (0)