gcode

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 7 Imported by: 2

README

gcode

Test GoDoc Release

A G-Code parser and generator for Go.

Installation

Get the package using the go tool:

$ go get -u github.com/256dpi/gcode

Usage

The included command line application can be used to post-process g-code files:

gcode.

Usage:
  gcode info <input>
  gcode strip <input> <output>
  gcode offset <input> <output> <x> <y> <z>
  gcode svg <input> <output>

Options:
  -h --help  Show this screen.

License

The MIT License (MIT)

Copyright (c) 2016 Joël Gähwiler

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToSVG

func ConvertToSVG(f *File) string

ConvertToSVG returns the SVG code for the passed G-Code file.

func OffsetXYZ

func OffsetXYZ(f *File, x, y, z float64)

OffsetXYZ will offset all X, Y and Z G-Code values by the specified values.

func StripComments

func StripComments(f *File)

StripComments will remove all inline and line comments from file.

func WriteFile

func WriteFile(w io.Writer, f *File) error

WriteFile will write the specified G-Code file to the passed writer.

Types

type File

type File struct {
	Lines []Line
}

A File contains multiple lines of G-Codes.

func ParseFile

func ParseFile(r io.Reader) (*File, error)

ParseFile will parse a whole G-Code file from the passed reader.

type GCode

type GCode struct {
	Letter  string
	Value   float64
	Comment string
}

A GCode is either a single G-Code like "X12.3" or an in line comment in the form of "(Comment)".

func (*GCode) String

func (c *GCode) String() string

String will return a G-Code formatted string.

type Line

type Line struct {
	Codes   []GCode
	Comment string
}

A Line consists of multiple G-Codes and a potential line comment.

func ParseLine

func ParseLine(s string) (Line, error)

ParseLine will parse the specified string as a line of G-Codes.

func (*Line) String

func (l *Line) String() string

String will return a G-Code formatted string.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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