Tools and documentation for EPSON TM-T88xx printers (particularly the TM-T88IV)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.0 KiB

1 year ago
#!/bin/bash
set -e
dev=/dev/usb/lp0
image="$(magick "$1" -resize 512x -dither FloydSteinberg -remap pattern:gray50 pbm:- | base64)"
1 year ago
data_header="$(echo "$image" | base64 -d | sed -n '2p')"
data="$(echo "$image" | base64 -d | tail -n +3 | base64)"
hex_size() {
printf '%04x' "$1" | sed -e 's/\(..\)\(..\)/\\x\2\\x\1/g'
}
size="$(echo "$data" | base64 -d | wc -c)"
size="$(hex_size "$(("$size" + 10))")"
size_x="$(hex_size "$(echo "$data_header" | cut -d' ' -f 1)")"
size_y="$(hex_size "$(echo "$data_header" | cut -d' ' -f 2)")"
# Initialize printer
printf '\x1B@' > $dev
# Set print speed
printf '\x1D(K\2\0' > $dev
printf '22' > $dev
1 year ago
# Upload graphics data
printf '\x1D(L' > $dev
printf "$size" > $dev
printf '0p0' > $dev
printf '\1\1' > $dev # bx, by (1 or 2)
printf '1' > $dev # color
1 year ago
printf "$size_x" > $dev # size x
printf "$size_y" > $dev # size y
echo "$data" | base64 -d > $dev
# Print graphics data
printf '\x1D(L\2\0' > $dev
printf '02' > $dev
1 year ago
# Cut paper
printf '\n\n\n' > $dev
printf '\x1DVA\0' > $dev