aboutsummaryrefslogtreecommitdiff
path: root/cutter.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-04 23:19:46 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-04 23:19:46 +0200
commit91d3472be75004b6e937cd57ad27a8a6f6872b09 (patch)
tree1c331bbc67feabc754cee1e21b084f55de6647b4 /cutter.go
parent957ef9104e09477186bd39faa35f21ec3485e937 (diff)
More functions
Diffstat (limited to 'cutter.go')
-rw-r--r--cutter.go54
1 files changed, 46 insertions, 8 deletions
diff --git a/cutter.go b/cutter.go
index 500cfd0..de12352 100644
--- a/cutter.go
+++ b/cutter.go
@@ -52,6 +52,10 @@ type Path []Point
Usable: 4000x5440 pt
*/
+type Triple struct {
+ U, V, W float64
+}
+
var (
A4 = Point{5440, 4000} // Portrait
Origin = Point{0, 0}
@@ -61,6 +65,10 @@ func (p Point) String() string {
return fmt.Sprintf("%v,%v", p.X, p.Y)
}
+func (t Triple) String() string {
+ return fmt.Sprintf("%v,%v,%v", t.U, t.V, t.W)
+}
+
type Cutter struct {
*bufio.ReadWriter
}
@@ -146,10 +154,14 @@ func (c Cutter) Home() {
c.Send("H")
}
-func (c Cutter) SetOrigin() {
+func (c Cutter) SetCurrentOrigin() {
c.Send("FJ")
}
+func (c Cutter) SetOrigin(p Point) {
+ c.Send("SO", p)
+}
+
func (c Cutter) Draw(p Point) {
c.Send("D", p)
}
@@ -180,8 +192,8 @@ func (c Cutter) LineScale(n int) {
c.Send("B", n)
}
-func (c Cutter) Factor(n int) {
- c.Send("&", n, ",", n, ",", n)
+func (c Cutter) Factor(t Triple) {
+ c.Send("&", t)
}
func (c Cutter) Offset(p Point) {
@@ -220,11 +232,6 @@ func (c Cutter) MediaType(n int) {
c.Send("FW", n)
}
-func (c Cutter) ReadUpperRight() (string, error) {
- c.Send("U")
- return c.readResponse()
-}
-
// Speed 10..100 mm/s
func (c Cutter) Speed(n int) {
if n >= 1 && n <= 10 {
@@ -262,6 +269,12 @@ func (c Cutter) parsePoint() (p Point) {
return
}
+func (c Cutter) parseTriple() (t Triple) {
+ s, _ := c.readResponse()
+ fmt.Sscanf(s, "%v,%v,%v", &t.U, &t.V, &t.W)
+ return
+}
+
func (c Cutter) RegMarkLen(n int) {
c.Send("TB51,", n)
}
@@ -395,3 +408,28 @@ func (c Cutter) Ellipse(a int, p Point, start, end Polar, theta float64) {
c.Send(")", a, ",", p, ",", start.R, ",", end.R, ",",
start.Theta, ",", end.Theta, ",", theta)
}
+
+func (c Cutter) Gin() Triple {
+ c.Send("G")
+ return c.parseTriple()
+}
+
+func (c Cutter) CallGin() Triple {
+ c.Send("C")
+ return c.parseTriple()
+}
+
+func (c Cutter) ReadOffset() Point {
+ c.Send("?")
+ return c.parsePoint()
+}
+
+func (c Cutter) ReadLowerLeft() Point {
+ c.Send("[")
+ return c.parsePoint()
+}
+
+func (c Cutter) ReadUpperRight() Point {
+ c.Send("U")
+ return c.parsePoint()
+}