DevTerm/Code/thermal_printer
Mike Sizov 6fc08fded2 Add command for printing 4 shades of grayscale image.
It works in a similar way as a monochrome print, but with few differences:
1. User needs to send 3 rows of color bitstrings for each image row.
2. Printer will stay in place while printing all 3 non-white 'colors',
it will feed the paper each third line.
3. User must multiply height by 3.
4. Command is different: cmd[0] == ASCII_GS && cmd[1] == 118 && cmd[2] == 49

E.g.
For image 200x200, user needs to send header with width 200, height 600.
Image data is arranged the following way (fourth color is blank):
25 bytes (200bits) of 1st color for first row
25 bytes (200bits) of 2nd color for first row
25 bytes (200bits) of 3rd color for first row
25 bytes (200bits) of 1st color for second row
25 bytes (200bits) of 2nd color for second row
...etc...
2023-04-17 00:44:13 +07:00
..
2022-05-22 10:20:25 +08:00
2022-01-26 15:04:11 +08:00
2022-03-11 06:00:10 -06:00
2021-03-29 19:32:40 +08:00
2022-03-18 00:08:05 +00:00

DevTerm Thermal printer

Console commands example

echo "Hello DevTerm" > /tmp/DEVTERM_PRINTER_IN

echo -e "Hello DevTerm\n\n\n\n\n\n" > /tmp/DEVTERM_PRINTER_IN

cat file.txt > /tmp/DEVTERM_PRINTER_IN

ncal -hb | tee > /tmp/DEVTERM_PRINTER_IN

Eos/Pos commands example

ESC ! n

set printer font index,n:0-4
echo -en "\x1d\x21\x0" > /tmp/DEVTERM_PRINTER_IN
echo -en "\x1d\x21\x1" > /tmp/DEVTERM_PRINTER_IN
echo -en "\x1d\x21\x2" > /tmp/DEVTERM_PRINTER_IN
echo -en "\x1d\x21\x3" > /tmp/DEVTERM_PRINTER_IN
echo -en "\x1d\x21\x4" > /tmp/DEVTERM_PRINTER_IN

ascii font size
  1. 0 = 8x16
  2. 1 = 5x7
  3. 2 = 6x12
  4. 3 = 7x14
  5. 4 = 8x16
unicode font size
  1. 0 = 12x12
  2. 1 = 14x14
  3. 2 = 16x16
  4. 3 = 18x18
  5. 4 = 20x20

81addc7f4b/Code/thermal_printer/devterm_thermal_printer.c (L381)

DC2 # n

n:0-F, set printer printing density

echo -en "\x12\x23\x8" > /tmp/DEVTERM_PRINTER_IN

DC2 T

print the test page
echo -en "\x12\x54" > /tmp/DEVTERM_PRINTER_IN

UNICODE

Edit /usr/local/etc/devterm-printer ,point to an existed ttf file,eg: TTF=/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc

then restart devterm-printer.service with

sudo systemctl restart devterm-printer

devterm-printer daemon will auto detect the ttf font file

switch to UNICODE MODE

echo -en "\x1b\x21\x1" > /tmp/DEVTERM_PRINTER_IN  

switch back to default ASCII mode

echo -en "\x1b\x21\x0" > /tmp/DEVTERM_PRINTER_IN  

then

echo "日月火水木金土 ΕΙΝΑΙ Ο ΘΕΟΣ ΓΕΩΜΕΤΡΗΣ" > /tmp/DEVTERM_PRINTER_IN

to print unicode characters

ESC V n rotation command,unicode mode only

echo -en "\x1b\x56\x0" >/tmp/DEVTERM_PRINTER_IN disable rotation

echo -en "\x1b\x56\x1" >/tmp/DEVTERM_PRINTER_IN 90 degree
echo -en "\x1b\x56\x2" >/tmp/DEVTERM_PRINTER_IN 180 degree
echo -en "\x1b\x56\x3" >/tmp/DEVTERM_PRINTER_IN 270 degree

How to run it from source

  • make
  • sudo systemctl stop devterm-printer
  • sudo cp -rf devterm_thermal_printer.elf /usr/local/bin
  • sudo systemctl start devterm-printer