commit 9d6e35143b0e7f4f529b6ecbc555cd0f30e2342a Author: mid-kid Date: Sat Oct 21 16:40:20 2023 +0200 Initial commit diff --git a/docs/Programming+manual+ESCPOS_receipt.pdf b/docs/Programming+manual+ESCPOS_receipt.pdf new file mode 100644 index 0000000..0354124 Binary files /dev/null and b/docs/Programming+manual+ESCPOS_receipt.pdf differ diff --git a/docs/TM-T88IV Technical Reference Guide.pdf b/docs/TM-T88IV Technical Reference Guide.pdf new file mode 100644 index 0000000..0ce8e23 Binary files /dev/null and b/docs/TM-T88IV Technical Reference Guide.pdf differ diff --git a/print_barcode.sh b/print_barcode.sh new file mode 100755 index 0000000..6fc515e --- /dev/null +++ b/print_barcode.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +printf '\x1Dk\x05'$1'\0' > /dev/usb/lp0 diff --git a/print_image.sh b/print_image.sh new file mode 100755 index 0000000..b2003e2 --- /dev/null +++ b/print_image.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e +dev=/dev/usb/lp0 + +image="$(magick "$1" -resize 256x -dither FloydSteinberg -remap pattern:gray50 pbm:- | base64)" +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)")" + +# Upload graphics data +printf '\x1D(L' > $dev +printf "$size" > $dev +printf '\x30\x70\x30' > $dev +printf '\x02\x02' > $dev # bx, by (1 or 2) +printf '\x31' > $dev # color +printf "$size_x" > $dev # size x +printf "$size_y" > $dev # size y +echo "$data" | base64 -d > $dev + +# Print graphics data +printf '\x1D(L\x02\0\x30\x02' > $dev + +# Cut paper +printf '\n\n\x1DVA\0' > $dev diff --git a/print_qrcode.sh b/print_qrcode.sh new file mode 100755 index 0000000..c51b398 --- /dev/null +++ b/print_qrcode.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e +dev=/dev/usb/lp0 + +text="$1" +size="$(printf '%s' "$text" | wc -c)" +size="$(expr "$size" + 3)" +size="$(printf '%04x' "$size" | sed -e 's/\(..\)\(..\)/\\x\2\\x\1/g')" + +# Store data +printf '\x1D(k' > $dev +printf "$size" > $dev +printf '\x31\x50\x30' > $dev +printf '%s' "$text" > $dev + +# Print data +printf '\x1D(k' > $dev +printf '\x03\0\x31\x51\x30' > $dev + +# Cut paper +printf '\x1DVA\0' > $dev