gcode-core

module
v0.1.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2022 License: MIT

README ΒΆ

gcode-core

Β 

logo

Manipulate and edit G-code commands, blocks and files.

Β 

Β 

πŸ‘‹ Introducing gcode-core

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.

πŸ’» Use gcode-core

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.

πŸ”₯ Features

With gcode-core you can do the following

Model Gcode commands and blocks

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.

Validate blocks

  • 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.

Manage gcode addressable and gcode unaddressable separately way

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.

Dependency Injection

The packages provide the interfaces needed you can use to implement within your own dependency injection strategy.

Customizable interfaces

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.

πŸš€ Upcomming Features

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.

πŸ— How to Set up gcode-core for Development?

You set up gcode-core locally with a few easy steps.

  1. Clone the repository
git clone https://github.com/mauroalderete/gcode-core
  1. Change the working directory
cd gcode-core
  1. Restore module
go mod tidy
  1. You can run all unit tests and examples to check it's working
go test ./...
  1. Optionally, if you have godocs installed, You can run a server to access documentation via website at localhost.
GOROOT=$GOPATH godoc -http=localhost:9090

πŸ” Built With

πŸ›‘ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing to gcode-core

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 our CODE OF CONDUCT, and the process for submitting pull requests to us.

πŸ™ Support

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.

Β 

Invitame un cafΓ© en cafecito.app

Directories ΒΆ

Path Synopsis
block package contains structs and methods to manage a gcode block
block package contains structs and methods to manage a gcode block
gcodeblock
gcodeblock is an implementation of block package.
gcodeblock is an implementation of block package.
internal/gcodefactory
gcodefactory implements gcode.GcoderFactory interface to create new instances Gcoder and AddressableGcoder using the implementations from unaddressablegcode and addressablegcode packages
gcodefactory implements gcode.GcoderFactory interface to create new instances Gcoder and AddressableGcoder using the implementations from unaddressablegcode and addressablegcode packages
checksum package implement the checksum algorithm used by Marlin and RepRap firmwares.
checksum package implement the checksum algorithm used by Marlin and RepRap firmwares.
gcode package contains the model to represent a single gcode expression.
gcode package contains the model to represent a single gcode expression.
addressablegcode
addressablegcode package implements gcode.AddressableGcoder interface to model a gcode with an address element.
addressablegcode package implements gcode.AddressableGcoder interface to model a gcode with an address element.
unaddressablegcode
unaddressablegcode package implements gcode.Gcoder interface to model a gcode without address element.
unaddressablegcode package implements gcode.Gcoder interface to model a gcode without address element.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL