aboutsummaryrefslogtreecommitdiff
path: root/plot.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-09-25 14:30:18 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-09-25 14:30:18 +0200
commit91489f1134568813fd5fac1e651d21cfd91e4ccd (patch)
tree23ed18304426d6f64a0e781b0b2315e56e4ecc9d /plot.go
parentdf0f1c3f0ca7264c44012ac657d1f7168f864965 (diff)
wip
Diffstat (limited to 'plot.go')
-rw-r--r--plot.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/plot.go b/plot.go
index 7993885..d939b7f 100644
--- a/plot.go
+++ b/plot.go
@@ -2,9 +2,26 @@ package robo
import (
"fmt"
+ "log"
"strings"
)
+type Robo struct {
+ dev Device
+}
+
+func NewRobo() (Robo, error) {
+ dev, err := Open()
+ if err != nil {
+ return Robo{}, err
+ }
+ return Robo{dev}, nil
+}
+
+func (r Robo) Close() error {
+ return r.dev.Close()
+}
+
type Plotter interface {
Plot() []byte
}
@@ -39,3 +56,20 @@ func CuttingArea(p Point) string { return "FU" + p.String() }
//func Calibration(p Point) string { return "TB72" + p.String() }
func Curve(a int, p ...Point) string { return fmt.Sprintf("Y%d,%v", a, Path(p)) }
+
+func (r Robo) Version() string {
+ r.dev.WriteString("FG")
+ resp, _ := r.dev.ReadString()
+ return resp
+}
+
+func (r Robo) Init() {
+ r.dev.Command([]byte{4})
+}
+
+func (r Robo) Ready() bool {
+ r.dev.Command([]byte{5})
+ resp, _ := r.dev.ReadString()
+ log.Printf("ready %q", resp)
+ return resp == "0"
+}