aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-12 19:47:05 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-12 19:47:05 +0200
commit80507f9418805e886a1ea0ab6e61fb247fb2330c (patch)
treeefc4a2d5f803e50c6d0ece554ae2796c14b2058a
parent39aaa6d018aff5dd4e8ab13df74fe4b1a0cf62dc (diff)
Add more commands
-rw-r--r--cutter.go68
1 files changed, 52 insertions, 16 deletions
diff --git a/cutter.go b/cutter.go
index 16b35cc..50f544c 100644
--- a/cutter.go
+++ b/cutter.go
@@ -9,9 +9,9 @@ import (
/*
A4 Cutting area
- 5mm y 5mm
+ 10mm y 10mm
+-----------------+
- | | 5mm
+ | | 10mm
| +-------------+ |
| | | |
. . . . x
@@ -78,12 +78,16 @@ const (
func (c Cutter) Add(a ...interface{}) {
fmt.Fprint(c, a...)
+}
+
+func (c Cutter) EOT() {
c.WriteByte(ETX)
+ c.Flush()
}
func (c Cutter) Send(a ...interface{}) {
c.Add(a...)
- c.Flush()
+ c.EOT()
}
type StepDirection byte
@@ -134,14 +138,30 @@ func (c Cutter) SetOrigin(n int) {
c.Send("SO", n)
}
-func (c Cutter) Draw(p Point) {
- c.Send("D", p)
+func (c Cutter) Draw(pts ...Point) {
+ c.Add("D")
+ for _, p := range pts {
+ c.Add(p, ",")
+ }
+ c.EOT()
+}
+
+func (c Cutter) DrawRelative(pts ...Point) {
+ c.Add("E")
+ for _, p := range pts {
+ c.Add(p, ",")
+ }
+ c.EOT()
}
func (c Cutter) Move(p Point) {
c.Send("M", p)
}
+func (c Cutter) MoveRelative(p Point) {
+ c.Send("O", p)
+}
+
type LineStyle int
const (
@@ -331,10 +351,6 @@ func (c Cutter) Wait() {
}
}
-func (c Cutter) Bezier(a int, p0, p1, p2, p3 Point) {
- c.Send("BZ", a, ",", p0, ",", p1, ",", p2, ",", p3)
-}
-
type Orientation int
const (
@@ -381,19 +397,35 @@ func (c Cutter) ManualSearchMarks(p Point) bool {
return c.returnUnit() == 0
}
+func (c Cutter) Curve(a int, pts ...Point) {
+ c.Add("Y", a, ",")
+ for _, p := range pts {
+ c.Add(p, ",")
+ }
+ c.EOT()
+}
+
+func (c Cutter) CurveRelative(a int, pts ...Point) {
+ c.Add("_", a, ",")
+ for _, p := range pts {
+ c.Add(p, ",")
+ }
+ c.EOT()
+}
+
func (c Cutter) Circle(p Point, start, end Polar) {
c.Send("W", p, ",",
start.R, ",", end.R, ",",
start.Theta, ",", end.Theta)
}
-// Not supported?
-func (c Cutter) Curve(a int, ph Path) {
- c.Add("Y", a)
- for _, p := range ph {
- c.Add(",", p)
- }
- c.Flush()
+func (c Cutter) CircleRelative(start, end Polar) {
+ c.Send("]", start.R, ",", end.R, ",",
+ start.Theta, ",", end.Theta)
+}
+
+func (c Cutter) Circle3P(p1, p2, p3 Point) {
+ c.Send("WP", p1, ",", p2, ",", p3)
}
func (c Cutter) Ellipse(a int, p Point, start, end Polar, theta Unit) {
@@ -401,6 +433,10 @@ func (c Cutter) Ellipse(a int, p Point, start, end Polar, theta Unit) {
start.Theta, ",", end.Theta, ",", theta)
}
+func (c Cutter) Bezier(a int, p0, p1, p2, p3 Point) {
+ c.Send("BZ", a, ",", p0, ",", p1, ",", p2, ",", p3)
+}
+
func (c Cutter) Gin() Triple {
c.Send("G")
return c.returnTriple()