Add a media size information table

This commit is contained in:
Přemysl Eric Janouch 2019-04-12 04:52:03 +02:00
parent 43b5536c4d
commit 8c0a5195fc
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 48 additions and 4 deletions

View File

@ -192,10 +192,54 @@ func (p *Printer) Close() error {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
type Status struct { type mediaSize struct {
errors []string 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 {
MediaWidthMM int
MediaLengthMM int
Errors []string
}
// -----------------------------------------------------------------------------
func decodeBitfieldErrors(b byte, errors [8]string) []string { func decodeBitfieldErrors(b byte, errors [8]string) []string {
var result []string var result []string
for i := uint(0); i < 8; i++ { 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. // TODO: What exactly do we need? Probably extend as needed.
func decodeStatusInformation(d []byte) Status { func decodeStatusInformation(d []byte) Status {
var status 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", "no media", "end of media", "cutter jam", "?", "printer in use",
"printer turned off", "high-voltage adapter", "fan motor error"})...) "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", "replace media", "expansion buffer full", "communication error",
"communication buffer full", "cover open", "cancel key", "communication buffer full", "cover open", "cancel key",
"media cannot be fed", "system error"})...) "media cannot be fed", "system error"})...)