gcode-core
is a Golang library to model, manipulate and edit G-code commands, blocks and files. Easily, you can open gcode files and apply them to all kinds of massive operations that come to mind.
- Do you need to apply skew correction to files before sending to your CNC machine them?
- Do you wish to insert gcode snippets to change the temperature or a tool regularly?
- Do you like to verify each gcode line?
- Or calculate extra info in your files simply?
gcode-core
gives you a set of interfaces and objects to help you accomplish your goals simplifying manipulating your gcode files at a low level.
Simply add an import statement into your project to start using.
Some like that:
import (
"fmt"
"log"
"https://github.com/mauroalderete/gcode-core/block/gcodeblock"
)
Later, use it:
func main() {
// we define a gcode line to parse
const source = "N7 G1 X2.0 Y2.0 F3000.0"
// convert a string statement into a gcode block model
block, err := gcodeblock.Parse(source)
if err != nil {
log.Fatal(err)
}
// calculate and get the checksum gcode of our new block
gcode, err := b.CalculateChecksum()
if err != nil {
log.Fatal(err)
}
// show the checksum!
fmt.Printf("the gcode checksum is: %s\n", gcode)
// Output:
// the gcode checksum is: *85
}
There are many packages you can import. Some export concrete implementations that you can start to interact with your files speedily. Instead, others export interfaces and constructors that allow you to use them with dependency injection patterns.
Please, feel free to examine the documentation
and contribute
by writing any question, suggestion or issue using our discussion channels
or creating a new issue
.
With gcode-core
you can do the following
It implements many ways to get gcode or block instances. With them, you can get a summary or modify his values and apply some logic or math operations.
- Allow you to review if a block is valid or not
- Update checksum
- Change the validation algorithm
- Add a checksum gcode if your slicer does not do it.
Most gcode commands use an address element to add some information about that do it. However, some circumstantial gcode commands do not require an address element like the gcodes M
or G
when used without an address value.
gcode-core
provide interfaces and implementations to handle both situations discriminately.
The packages provide the interfaces needed you can use to implement within your own dependency injection strategy.
Sometimes the implementations exported maybe not be enough. For these cases, all packages give you interfaces with which you can implement your own 'gcode' and 'block' models or extend them exists.
gcode-core
has all the potential to grow further. Here are some of the upcoming features planned (not in any order),
- ✔️ Handle files.
- ✔️ Mapping gcode commands and improving validating block.
- ✔️ Cloning blocks and gcode.
- ✔️ Convert gcode data types.
- ✔️ Improve compatibility with
RFCRS274NGC
.
You set up gcode-core
locally with a few easy steps.
- Clone the repository
git clone https://github.com/mauroalderete/gcode-core
- Change the working directory
cd gcode-core
- Restore module
go mod tidy
- You can run all unit tests and examples to check it's working
go test ./...
- Optionally, if you have godocs installed, You can run a server to access documentation via website at localhost.
GOROOT=$GOPATH godoc -http=localhost:9090
- Golang 1.18
This project is licensed under the MIT License - see the LICENSE
file for details.
Any kind of positive contribution is welcome! Please help us to grow by contributing to the project.
If you wish to contribute, you can work on any features listed here or create one on your own. After adding your code, please send us a Pull Request.
Please read
CONTRIBUTING
for details on ourCODE OF CONDUCT
, and the process for submitting pull requests to us.
We all need support and motivation. gcode-core
is not an exception. Please give this project a ⭐ start to encourage and show that you liked it. Don't forget to leave a ⭐ star before you move away.
If you found the app helpful, consider supporting us with a coffee.