diff options
author | Přemysl Janouch <p@janouch.name> | 2019-04-12 04:52:03 +0200 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2019-04-12 04:52:03 +0200 |
commit | 8c0a5195fc32f885140fd812b66f1bcd42220f47 (patch) | |
tree | 4e9e625c990dfdf3af144f9f9be9464d31319aeb /ql/ql.go | |
parent | 43b5536c4d6f90fdd0125928a0c2a44c89122c8b (diff) | |
download | sklad-8c0a5195fc32f885140fd812b66f1bcd42220f47.tar.gz sklad-8c0a5195fc32f885140fd812b66f1bcd42220f47.tar.xz sklad-8c0a5195fc32f885140fd812b66f1bcd42220f47.zip |
Add a media size information table
Diffstat (limited to 'ql/ql.go')
-rw-r--r-- | ql/ql.go | 50 |
1 files changed, 47 insertions, 3 deletions
@@ -192,10 +192,54 @@ func (p *Printer) Close() error { // ----------------------------------------------------------------------------- +type mediaSize struct { + WidthMM int + HeightMM int +} + +type mediaInfo struct { + // Note that these are approximates, many pins within the margins will work + SideMarginPins int + PrintAreaPins int +} + +var media = map[mediaSize]mediaInfo{ + // Continuous length tape + {12, 0}: {29, 106}, + {29, 0}: {6, 306}, + {38, 0}: {12, 413}, + {50, 0}: {12, 554}, + {54, 0}: {0, 590}, + {62, 0}: {12, 696}, + + // Die-cut labels + {17, 54}: {0, 165}, + {17, 87}: {0, 165}, + {23, 23}: {42, 236}, + {29, 42}: {6, 306}, + {29, 90}: {6, 306}, + {38, 90}: {12, 413}, + {39, 48}: {6, 425}, + {52, 29}: {0, 578}, + {54, 29}: {59, 602}, + {60, 86}: {24, 672}, + {62, 29}: {12, 696}, + {62, 100}: {12, 696}, + + // Die-cut diameter labels + {12, 12}: {113, 94}, + {24, 24}: {42, 236}, + {58, 58}: {51, 618}, +} + type Status struct { - errors []string + MediaWidthMM int + MediaLengthMM int + Errors []string } +// ----------------------------------------------------------------------------- + func decodeBitfieldErrors(b byte, errors [8]string) []string { var result []string for i := uint(0); i < 8; i++ { @@ -209,10 +253,10 @@ func decodeBitfieldErrors(b byte, errors [8]string) []string { // TODO: What exactly do we need? Probably extend as needed. func decodeStatusInformation(d []byte) Status { var status Status - status.errors = append(status.errors, decodeBitfieldErrors(d[8], [8]string{ + status.Errors = append(status.Errors, decodeBitfieldErrors(d[8], [8]string{ "no media", "end of media", "cutter jam", "?", "printer in use", "printer turned off", "high-voltage adapter", "fan motor error"})...) - status.errors = append(status.errors, decodeBitfieldErrors(d[9], [8]string{ + status.Errors = append(status.Errors, decodeBitfieldErrors(d[9], [8]string{ "replace media", "expansion buffer full", "communication error", "communication buffer full", "cover open", "cancel key", "media cannot be fed", "system error"})...) |