aboutsummaryrefslogtreecommitdiff
path: root/cutter.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-05-02 21:05:41 +0200
committerDimitri Sokolyuk <demon@dim13.org>2015-05-02 21:05:41 +0200
commit6cac20d8bc57b6177d7054734242a2ab96ae368f (patch)
tree222c279011e0aa47c3ebde56d2ce361c30bc5f43 /cutter.go
parenteb5be8c003e1177da7171eaf16b88d8e99e8dd4a (diff)
Add Esc()
Diffstat (limited to 'cutter.go')
-rw-r--r--cutter.go31
1 files changed, 15 insertions, 16 deletions
diff --git a/cutter.go b/cutter.go
index ba290fe..d26d534 100644
--- a/cutter.go
+++ b/cutter.go
@@ -87,10 +87,6 @@ func (c Cutter) Send(a ...interface{}) {
c.Flush()
}
-func (c Cutter) TestCut() {
- c.Send("FH")
-}
-
type StepDirection byte
const (
@@ -101,13 +97,22 @@ const (
StepLeft
)
-func (c Cutter) Step(dir StepDirection) {
+func (c Cutter) Esc(bytes ...byte) {
c.WriteByte(ESC)
- c.WriteByte(NUL)
- c.WriteByte(byte(dir))
+ for _, b := range bytes {
+ c.WriteByte(b)
+ }
c.Flush()
}
+func (c Cutter) Step(dir StepDirection) {
+ c.Esc(NUL, byte(dir))
+}
+
+func (c Cutter) TestCut() {
+ c.Send("FH")
+}
+
// CR returns carret to home on same line
func (c Cutter) CR() {
c.Send("TT")
@@ -281,9 +286,7 @@ func (c Cutter) UnknownFA() Point {
// VersionUpgrade
func (c Cutter) BootVersion() (string, error) {
- c.WriteByte(ESC)
- c.WriteByte(1)
- c.Flush()
+ c.Esc(1)
return c.ReadString(' ')
}
@@ -297,15 +300,11 @@ func (c Cutter) Upgrade() (bool, error) {
// Initialize ???
func (c Cutter) Initialize() {
- c.WriteByte(ESC)
- c.WriteByte(4)
- c.Flush()
+ c.Esc(4)
}
func (c Cutter) Ready() bool {
- c.WriteByte(ESC)
- c.WriteByte(5)
- c.Flush()
+ c.Esc(5)
return c.parseDigit() == 0
}